diff --git a/BUILD.gn b/BUILD.gn index 2d7bea5ef..d4ee0be46 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -411,6 +411,8 @@ static_library("libcef_static") { "libcef/browser/alloy/alloy_browser_context.h", "libcef/browser/alloy/alloy_browser_main.cc", "libcef/browser/alloy/alloy_browser_main.h", + "libcef/browser/alloy/browser_platform_delegate_alloy.cc", + "libcef/browser/alloy/browser_platform_delegate_alloy.h", "libcef/browser/alloy/chrome_browser_process_alloy.cc", "libcef/browser/alloy/chrome_browser_process_alloy.h", "libcef/browser/alloy/chrome_profile_manager_alloy.cc", diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.cc b/libcef/browser/alloy/browser_platform_delegate_alloy.cc new file mode 100644 index 000000000..c6b898583 --- /dev/null +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.cc @@ -0,0 +1,427 @@ +// Copyright 2015 The Chromium Embedded Framework Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "libcef/browser/alloy/browser_platform_delegate_alloy.h" + +#include "libcef/browser/browser_host_impl.h" +#include "libcef/browser/extensions/browser_extensions_util.h" +#include "libcef/browser/extensions/extension_background_host.h" +#include "libcef/browser/extensions/extension_system.h" +#include "libcef/browser/extensions/extension_view_host.h" +#include "libcef/browser/extensions/extension_web_contents_observer.h" +#include "libcef/browser/printing/print_view_manager.h" +#include "libcef/common/extensions/extensions_util.h" + +#include "base/logging.h" +#include "chrome/browser/printing/print_view_manager.h" +#include "chrome/browser/ui/prefs/prefs_tab_helper.h" +#include "components/zoom/zoom_controller.h" +#include "content/browser/renderer_host/render_widget_host_impl.h" +#include "content/browser/web_contents/web_contents_impl.h" +#include "content/public/browser/render_view_host.h" +#include "content/public/browser/render_widget_host.h" +#include "extensions/browser/process_manager.h" +#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h" + +CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy() + : weak_ptr_factory_(this) {} + +content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents( + CefBrowserHostImpl::CreateParams& create_params, + bool& own_web_contents) { + // Get or create the request context and browser context. + CefRefPtr request_context_impl = + CefRequestContextImpl::GetOrCreateForRequestContext( + create_params.request_context); + CHECK(request_context_impl); + auto cef_browser_context = request_context_impl->GetBrowserContext(); + CHECK(cef_browser_context); + auto browser_context = cef_browser_context->AsBrowserContext(); + + if (!create_params.request_context) { + // Using the global request context. + create_params.request_context = request_context_impl.get(); + } + + scoped_refptr site_instance; + if (extensions::ExtensionsEnabled() && !create_params.url.is_empty()) { + if (!create_params.extension) { + // We might be loading an extension app view where the extension URL is + // provided by the client. + create_params.extension = + extensions::GetExtensionForUrl(browser_context, create_params.url); + } + if (create_params.extension) { + if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) { + // Default to dialog behavior. + create_params.extension_host_type = + extensions::VIEW_TYPE_EXTENSION_DIALOG; + } + + // Extension resources will fail to load if we don't use a SiteInstance + // associated with the extension. + // (AlloyContentBrowserClient::SiteInstanceGotProcess won't find the + // extension to register with InfoMap, and AllowExtensionResourceLoad in + // ExtensionProtocolHandler::MaybeCreateJob will return false resulting in + // ERR_BLOCKED_BY_CLIENT). + site_instance = extensions::ProcessManager::Get(browser_context) + ->GetSiteInstanceForURL(create_params.url); + DCHECK(site_instance); + } + } + + content::WebContents::CreateParams wc_create_params(browser_context, + site_instance); + + if (IsWindowless()) { + // Create the OSR view for the WebContents. + CreateViewForWebContents(&wc_create_params.view, + &wc_create_params.delegate_view); + } + + auto web_contents = content::WebContents::Create(wc_create_params); + CHECK(web_contents); + + own_web_contents = true; + return web_contents.release(); +} + +void CefBrowserPlatformDelegateAlloy::WebContentsCreated( + content::WebContents* web_contents, + bool owned) { + CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned); + + if (owned) { + SetOwnedWebContents(web_contents); + } +} + +void CefBrowserPlatformDelegateAlloy::AddNewContents( + content::WebContents* source, + std::unique_ptr new_contents, + const GURL& target_url, + WindowOpenDisposition disposition, + const gfx::Rect& initial_rect, + bool user_gesture, + bool* was_blocked) { + CefRefPtr owner = + CefBrowserHostImpl::GetBrowserForContents(new_contents.get()); + if (owner) { + // Taking ownership of |new_contents|. + static_cast( + owner->platform_delegate_.get()) + ->SetOwnedWebContents(new_contents.release()); + return; + } + + if (extension_host_) { + extension_host_->AddNewContents(source, std::move(new_contents), target_url, + disposition, initial_rect, user_gesture, + was_blocked); + } +} + +bool CefBrowserPlatformDelegateAlloy::ShouldTransferNavigation( + bool is_main_frame_navigation) { + if (extension_host_) { + return extension_host_->ShouldTransferNavigation(is_main_frame_navigation); + } + return true; +} + +void CefBrowserPlatformDelegateAlloy::RenderViewCreated( + content::RenderViewHost* render_view_host) { + // Indicate that the view has an external parent (namely us). This changes the + // default view behavior in some cases (e.g. focus handling on Linux). + if (!IsViewsHosted() && render_view_host->GetWidget()->GetView()) + render_view_host->GetWidget()->GetView()->SetHasExternalParent(true); +} + +void CefBrowserPlatformDelegateAlloy::RenderViewReady() { + ConfigureAutoResize(); +} + +void CefBrowserPlatformDelegateAlloy::BrowserCreated( + CefBrowserHostImpl* browser) { + CefBrowserPlatformDelegate::BrowserCreated(browser); + + web_contents_->SetDelegate(browser); + + PrefsTabHelper::CreateForWebContents(web_contents_); + printing::CefPrintViewManager::CreateForWebContents(web_contents_); + + if (extensions::ExtensionsEnabled()) { + extensions::CefExtensionWebContentsObserver::CreateForWebContents( + web_contents_); + + // Used by the tabs extension API. + zoom::ZoomController::CreateForWebContents(web_contents_); + } + + if (IsPrintPreviewSupported()) { + web_contents_dialog_helper_.reset( + new CefWebContentsDialogHelper(web_contents_, this)); + } +} + +void CefBrowserPlatformDelegateAlloy::CreateExtensionHost( + const extensions::Extension* extension, + const GURL& url, + extensions::ViewType host_type) { + // Should get WebContentsCreated and BrowserCreated calls first. + DCHECK(web_contents_); + DCHECK(browser_); + DCHECK(!extension_host_); + + if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG || + host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) { + // Create an extension host that we own. + extension_host_ = new extensions::CefExtensionViewHost( + browser_, extension, web_contents_, url, host_type); + // Trigger load of the extension URL. + extension_host_->CreateRenderViewSoon(); + } else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + is_background_host_ = true; + browser_->is_background_host_ = true; + // Create an extension host that will be owned by ProcessManager. + extension_host_ = new extensions::CefExtensionBackgroundHost( + browser_, + base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted, + weak_ptr_factory_.GetWeakPtr()), + extension, web_contents_, url, host_type); + // Load will be triggered by ProcessManager::CreateBackgroundHost. + } else { + NOTREACHED() << " Unsupported extension host type: " << host_type; + } +} + +extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost() + const { + return extension_host_; +} + +void CefBrowserPlatformDelegateAlloy::BrowserDestroyed( + CefBrowserHostImpl* browser) { + DestroyExtensionHost(); + owned_web_contents_.reset(); + + CefBrowserPlatformDelegate::BrowserDestroyed(browser); +} + +void CefBrowserPlatformDelegateAlloy::SendCaptureLostEvent() { + content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From( + browser_->web_contents()->GetRenderViewHost()->GetWidget()); + if (widget) + widget->LostCapture(); +} + +#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) +void CefBrowserPlatformDelegateAlloy::NotifyMoveOrResizeStarted() { + // Dismiss any existing popups. + content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost(); + if (host) + host->NotifyMoveOrResizeStarted(); +} +#endif + +bool CefBrowserPlatformDelegateAlloy::PreHandleGestureEvent( + content::WebContents* source, + const blink::WebGestureEvent& event) { + if (extension_host_) + return extension_host_->PreHandleGestureEvent(source, event); + return false; +} + +bool CefBrowserPlatformDelegateAlloy::IsNeverComposited( + content::WebContents* web_contents) { + if (extension_host_) + return extension_host_->IsNeverComposited(web_contents); + return false; +} + +void CefBrowserPlatformDelegateAlloy::SetAutoResizeEnabled( + bool enabled, + const CefSize& min_size, + const CefSize& max_size) { + if (enabled == auto_resize_enabled_) + return; + + auto_resize_enabled_ = enabled; + if (enabled) { + auto_resize_min_ = gfx::Size(min_size.width, min_size.height); + auto_resize_max_ = gfx::Size(max_size.width, max_size.height); + } else { + auto_resize_min_ = auto_resize_max_ = gfx::Size(); + } + ConfigureAutoResize(); +} + +void CefBrowserPlatformDelegateAlloy::ConfigureAutoResize() { + if (!web_contents_ || !web_contents_->GetRenderWidgetHostView()) { + return; + } + + if (auto_resize_enabled_) { + web_contents_->GetRenderWidgetHostView()->EnableAutoResize( + auto_resize_min_, auto_resize_max_); + } else { + web_contents_->GetRenderWidgetHostView()->DisableAutoResize(gfx::Size()); + } +} + +void CefBrowserPlatformDelegateAlloy::SetAccessibilityState( + cef_state_t accessibility_state) { + // Do nothing if state is set to default. It'll be disabled by default and + // controlled by the commmand-line flags "force-renderer-accessibility" and + // "disable-renderer-accessibility". + if (accessibility_state == STATE_DEFAULT) + return; + + content::WebContentsImpl* web_contents_impl = + static_cast(web_contents_); + + if (!web_contents_impl) + return; + + ui::AXMode accMode; + // In windowless mode set accessibility to TreeOnly mode. Else native + // accessibility APIs, specific to each platform, are also created. + if (accessibility_state == STATE_ENABLED) { + accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete; + } + web_contents_impl->SetAccessibilityMode(accMode); +} + +bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const { + auto actionable_contents = GetActionableWebContents(); + if (!actionable_contents) + return false; + + auto cef_browser_context = CefBrowserContext::FromBrowserContext( + actionable_contents->GetBrowserContext()); + if (!cef_browser_context->IsPrintPreviewSupported()) { + return false; + } + + // Print preview is not currently supported with OSR. + return !IsWindowless(); +} + +void CefBrowserPlatformDelegateAlloy::Print() { + auto actionable_contents = GetActionableWebContents(); + if (!actionable_contents) + return; + + auto rfh = actionable_contents->GetMainFrame(); + + if (IsPrintPreviewSupported()) { + printing::CefPrintViewManager::FromWebContents(actionable_contents) + ->PrintPreviewNow(rfh, false); + } else { + printing::PrintViewManager::FromWebContents(actionable_contents) + ->PrintNow(rfh); + } +} + +void CefBrowserPlatformDelegateAlloy::PrintToPDF( + const CefString& path, + const CefPdfPrintSettings& settings, + CefRefPtr callback) { + content::WebContents* actionable_contents = GetActionableWebContents(); + if (!actionable_contents) + return; + printing::CefPrintViewManager::PdfPrintCallback pdf_callback; + if (callback.get()) { + pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished, + callback.get(), path); + } + printing::CefPrintViewManager::FromWebContents(actionable_contents) + ->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path), + settings, pdf_callback); +} + +void CefBrowserPlatformDelegateAlloy::Find(int identifier, + const CefString& searchText, + bool forward, + bool matchCase, + bool findNext) { + if (!web_contents_) + return; + + // Every find request must have a unique ID and these IDs must strictly + // increase so that newer requests always have greater IDs than older + // requests. + if (identifier <= find_request_id_counter_) + identifier = ++find_request_id_counter_; + else + find_request_id_counter_ = identifier; + + auto options = blink::mojom::FindOptions::New(); + options->forward = forward; + options->match_case = matchCase; + options->find_next = findNext; + web_contents_->Find(identifier, searchText, std::move(options)); +} + +void CefBrowserPlatformDelegateAlloy::StopFinding(bool clearSelection) { + if (!web_contents_) + return; + + content::StopFindAction action = + clearSelection ? content::STOP_FIND_ACTION_CLEAR_SELECTION + : content::STOP_FIND_ACTION_KEEP_SELECTION; + web_contents_->StopFinding(action); +} + +base::RepeatingClosure +CefBrowserPlatformDelegateAlloy::GetBoundsChangedCallback() { + if (web_contents_dialog_helper_) { + return web_contents_dialog_helper_->GetBoundsChangedCallback(); + } + + return base::RepeatingClosure(); +} + +content::WebContents* +CefBrowserPlatformDelegateAlloy::GetActionableWebContents() const { + if (web_contents_ && extensions::ExtensionsEnabled()) { + content::WebContents* guest_contents = + extensions::GetFullPageGuestForOwnerContents(web_contents_); + if (guest_contents) + return guest_contents; + } + return web_contents_; +} + +void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents( + content::WebContents* owned_contents) { + // Should not currently own a WebContents. + CHECK(!owned_web_contents_); + owned_web_contents_.reset(owned_contents); +} + +void CefBrowserPlatformDelegateAlloy::DestroyExtensionHost() { + if (!extension_host_) + return; + if (extension_host_->extension_host_type() == + extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { + DCHECK(is_background_host_); + // Close notification for background pages arrives via CloseContents. + // The extension host will be deleted by + // ProcessManager::CloseBackgroundHost and OnExtensionHostDeleted will be + // called to notify us. + extension_host_->Close(); + } else { + DCHECK(!is_background_host_); + // We own the extension host and must delete it. + delete extension_host_; + extension_host_ = nullptr; + } +} + +void CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted() { + DCHECK(is_background_host_); + DCHECK(extension_host_); + extension_host_ = nullptr; +} diff --git a/libcef/browser/alloy/browser_platform_delegate_alloy.h b/libcef/browser/alloy/browser_platform_delegate_alloy.h new file mode 100644 index 000000000..7a989538a --- /dev/null +++ b/libcef/browser/alloy/browser_platform_delegate_alloy.h @@ -0,0 +1,106 @@ +// Copyright (c) 2015 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_ +#define CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_ + +#include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/web_contents_dialog_helper.h" + +#include "base/memory/weak_ptr.h" + +// Implementation of Alloy-based browser functionality. +class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate { + public: + content::WebContents* CreateWebContents( + CefBrowserHostImpl::CreateParams& create_params, + bool& own_web_contents) override; + void WebContentsCreated(content::WebContents* web_contents, + bool owned) override; + void AddNewContents(content::WebContents* source, + std::unique_ptr new_contents, + const GURL& target_url, + WindowOpenDisposition disposition, + const gfx::Rect& initial_rect, + bool user_gesture, + bool* was_blocked) override; + bool ShouldTransferNavigation(bool is_main_frame_navigation) override; + void RenderViewCreated(content::RenderViewHost* render_view_host) override; + void RenderViewReady() override; + void BrowserCreated(CefBrowserHostImpl* browser) override; + void CreateExtensionHost(const extensions::Extension* extension, + const GURL& url, + extensions::ViewType host_type) override; + extensions::ExtensionHost* GetExtensionHost() const override; + void BrowserDestroyed(CefBrowserHostImpl* browser) override; + void SendCaptureLostEvent() override; +#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) + void NotifyMoveOrResizeStarted() override; +#endif + bool PreHandleGestureEvent(content::WebContents* source, + const blink::WebGestureEvent& event) override; + bool IsNeverComposited(content::WebContents* web_contents) override; + void SetAutoResizeEnabled(bool enabled, + const CefSize& min_size, + const CefSize& max_size) override; + void SetAccessibilityState(cef_state_t accessibility_state) override; + bool IsPrintPreviewSupported() const override; + void Print() override; + void PrintToPDF(const CefString& path, + const CefPdfPrintSettings& settings, + CefRefPtr callback) override; + void Find(int identifier, + const CefString& searchText, + bool forward, + bool matchCase, + bool findNext) override; + void StopFinding(bool clearSelection) override; + + protected: + CefBrowserPlatformDelegateAlloy(); + + base::RepeatingClosure GetBoundsChangedCallback(); + + // Returns the WebContents most likely to handle an action. If extensions are + // enabled and this browser has a full-page guest (for example, a full-page + // PDF viewer extension) then the guest's WebContents will be returned. + // Otherwise, the browser's WebContents will be returned. + content::WebContents* GetActionableWebContents() const; + + private: + void SetOwnedWebContents(content::WebContents* owned_contents); + + void DestroyExtensionHost(); + void OnExtensionHostDeleted(); + + void ConfigureAutoResize(); + + // Non-nullptr if this object owns the WebContents. Will be nullptr for popup + // browsers between the calls to WebContentsCreated() and AddNewContents(), + // and may never be set if the parent browser is destroyed during popup + // creation. + std::unique_ptr owned_web_contents_; + + // Used for the print preview dialog. + std::unique_ptr web_contents_dialog_helper_; + + // Used to provide unique incremental IDs for each find request. + int find_request_id_counter_ = 0; + + // Used when the browser is hosting an extension. + extensions::ExtensionHost* extension_host_ = nullptr; + bool is_background_host_ = false; + + // Used with auto-resize. + bool auto_resize_enabled_ = false; + gfx::Size auto_resize_min_; + gfx::Size auto_resize_max_; + + base::WeakPtrFactory weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy); +}; + +#endif // CEF_LIBCEF_BROWSER_ALLOY_BROWSER_PLATFORM_DELEGATE_ALLOY_H_ diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index db251db85..b6e41f35b 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -1658,7 +1658,7 @@ content::BrowserContext* CefBrowserHostImpl::GetBrowserContext() const { extensions::ExtensionHost* CefBrowserHostImpl::GetExtensionHost() const { CEF_REQUIRE_UIT(); DCHECK(platform_delegate_); - return platform_delegate_->extension_host(); + return platform_delegate_->GetExtensionHost(); } void CefBrowserHostImpl::OnSetFocus(cef_focus_source_t source) { @@ -2490,7 +2490,7 @@ void CefBrowserHostImpl::RenderViewDeleted( } void CefBrowserHostImpl::RenderViewReady() { - platform_delegate_->ConfigureAutoResize(); + platform_delegate_->RenderViewReady(); if (client_.get()) { CefRefPtr handler = client_->GetRequestHandler(); diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index 7f50dc481..5fee920bb 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -523,7 +523,7 @@ class CefBrowserHostImpl : public CefBrowserHost, std::unique_ptr CreateNavigationLock(); private: - friend class CefBrowserPlatformDelegate; + friend class CefBrowserPlatformDelegateAlloy; static CefRefPtr CreateInternal( const CefBrowserSettings& settings, diff --git a/libcef/browser/browser_platform_delegate.cc b/libcef/browser/browser_platform_delegate.cc index 882f8040e..1e209d0b3 100644 --- a/libcef/browser/browser_platform_delegate.cc +++ b/libcef/browser/browser_platform_delegate.cc @@ -5,97 +5,15 @@ #include "libcef/browser/browser_platform_delegate.h" #include "libcef/browser/browser_host_impl.h" -#include "libcef/browser/extensions/browser_extensions_util.h" -#include "libcef/browser/extensions/extension_background_host.h" -#include "libcef/browser/extensions/extension_system.h" -#include "libcef/browser/extensions/extension_view_host.h" -#include "libcef/browser/extensions/extension_web_contents_observer.h" -#include "libcef/browser/printing/print_view_manager.h" -#include "libcef/browser/web_contents_dialog_helper.h" -#include "libcef/common/extensions/extensions_util.h" -#include "libcef/features/runtime_checks.h" #include "base/logging.h" -#include "chrome/browser/printing/print_view_manager.h" -#include "chrome/browser/ui/prefs/prefs_tab_helper.h" -#include "components/zoom/zoom_controller.h" -#include "content/browser/renderer_host/render_widget_host_impl.h" -#include "content/browser/web_contents/web_contents_impl.h" -#include "content/public/browser/render_view_host.h" -#include "content/public/browser/render_widget_host.h" -#include "extensions/browser/process_manager.h" -#include "third_party/blink/public/mojom/frame/find_in_page.mojom.h" -CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() - : weak_ptr_factory_(this) {} +CefBrowserPlatformDelegate::CefBrowserPlatformDelegate() = default; CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() { DCHECK(!browser_); } -content::WebContents* CefBrowserPlatformDelegate::CreateWebContents( - CefBrowserHostImpl::CreateParams& create_params, - bool& own_web_contents) { - // TODO(chrome-runtime): Add a path to create a Browser. - REQUIRE_ALLOY_RUNTIME(); - - // Get or create the request context and browser context. - CefRefPtr request_context_impl = - CefRequestContextImpl::GetOrCreateForRequestContext( - create_params.request_context); - CHECK(request_context_impl); - auto cef_browser_context = request_context_impl->GetBrowserContext(); - CHECK(cef_browser_context); - auto browser_context = cef_browser_context->AsBrowserContext(); - - if (!create_params.request_context) { - // Using the global request context. - create_params.request_context = request_context_impl.get(); - } - - scoped_refptr site_instance; - if (extensions::ExtensionsEnabled() && !create_params.url.is_empty()) { - if (!create_params.extension) { - // We might be loading an extension app view where the extension URL is - // provided by the client. - create_params.extension = - extensions::GetExtensionForUrl(browser_context, create_params.url); - } - if (create_params.extension) { - if (create_params.extension_host_type == extensions::VIEW_TYPE_INVALID) { - // Default to dialog behavior. - create_params.extension_host_type = - extensions::VIEW_TYPE_EXTENSION_DIALOG; - } - - // Extension resources will fail to load if we don't use a SiteInstance - // associated with the extension. - // (AlloyContentBrowserClient::SiteInstanceGotProcess won't find the - // extension to register with InfoMap, and AllowExtensionResourceLoad in - // ExtensionProtocolHandler::MaybeCreateJob will return false resulting in - // ERR_BLOCKED_BY_CLIENT). - site_instance = extensions::ProcessManager::Get(browser_context) - ->GetSiteInstanceForURL(create_params.url); - DCHECK(site_instance); - } - } - - content::WebContents::CreateParams wc_create_params(browser_context, - site_instance); - - if (IsWindowless()) { - // Create the OSR view for the WebContents. - CreateViewForWebContents(&wc_create_params.view, - &wc_create_params.delegate_view); - } - - auto web_contents = content::WebContents::Create(wc_create_params); - CHECK(web_contents); - - own_web_contents = true; - return web_contents.release(); -} - void CefBrowserPlatformDelegate::CreateViewForWebContents( content::WebContentsView** view, content::RenderViewHostDelegateView** delegate_view) { @@ -110,9 +28,6 @@ void CefBrowserPlatformDelegate::WebContentsCreated( DCHECK(!web_contents_); web_contents_ = web_contents; - if (owned) { - SetOwnedWebContents(web_contents); - } } void CefBrowserPlatformDelegate::AddNewContents( @@ -123,21 +38,7 @@ void CefBrowserPlatformDelegate::AddNewContents( const gfx::Rect& initial_rect, bool user_gesture, bool* was_blocked) { - REQUIRE_ALLOY_RUNTIME(); - - CefRefPtr owner = - CefBrowserHostImpl::GetBrowserForContents(new_contents.get()); - if (owner) { - // Taking ownership of |new_contents|. - owner->platform_delegate_->SetOwnedWebContents(new_contents.release()); - return; - } - - if (extension_host_) { - extension_host_->AddNewContents(source, std::move(new_contents), target_url, - disposition, initial_rect, user_gesture, - was_blocked); - } + NOTREACHED(); } void CefBrowserPlatformDelegate::WebContentsDestroyed( @@ -148,19 +49,13 @@ void CefBrowserPlatformDelegate::WebContentsDestroyed( bool CefBrowserPlatformDelegate::ShouldTransferNavigation( bool is_main_frame_navigation) { - if (extension_host_) { - return extension_host_->ShouldTransferNavigation(is_main_frame_navigation); - } return true; } void CefBrowserPlatformDelegate::RenderViewCreated( - content::RenderViewHost* render_view_host) { - // Indicate that the view has an external parent (namely us). This changes the - // default view behavior in some cases (e.g. focus handling on Linux). - if (!IsViewsHosted() && render_view_host->GetWidget()->GetView()) - render_view_host->GetWidget()->GetView()->SetHasExternalParent(true); -} + content::RenderViewHost* render_view_host) {} + +void CefBrowserPlatformDelegate::RenderViewReady() {} void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) { // We should have an associated WebContents at this point. @@ -169,55 +64,19 @@ void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostImpl* browser) { DCHECK(!browser_); DCHECK(browser); browser_ = browser; - - web_contents_->SetDelegate(browser); - - PrefsTabHelper::CreateForWebContents(web_contents_); - printing::CefPrintViewManager::CreateForWebContents(web_contents_); - - if (extensions::ExtensionsEnabled()) { - extensions::CefExtensionWebContentsObserver::CreateForWebContents( - web_contents_); - - // Used by the tabs extension API. - zoom::ZoomController::CreateForWebContents(web_contents_); - } - - if (IsPrintPreviewSupported()) { - web_contents_dialog_helper_.reset( - new CefWebContentsDialogHelper(web_contents_, this)); - } } void CefBrowserPlatformDelegate::CreateExtensionHost( const extensions::Extension* extension, const GURL& url, extensions::ViewType host_type) { - // Should get WebContentsCreated and BrowserCreated calls first. - DCHECK(web_contents_); - DCHECK(browser_); - DCHECK(!extension_host_); + NOTREACHED(); +} - if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG || - host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) { - // Create an extension host that we own. - extension_host_ = new extensions::CefExtensionViewHost( - browser_, extension, web_contents_, url, host_type); - // Trigger load of the extension URL. - extension_host_->CreateRenderViewSoon(); - } else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { - is_background_host_ = true; - browser_->is_background_host_ = true; - // Create an extension host that will be owned by ProcessManager. - extension_host_ = new extensions::CefExtensionBackgroundHost( - browser_, - base::BindOnce(&CefBrowserPlatformDelegate::OnExtensionHostDeleted, - weak_ptr_factory_.GetWeakPtr()), - extension, web_contents_, url, host_type); - // Load will be triggered by ProcessManager::CreateBackgroundHost. - } else { - NOTREACHED() << " Unsupported extension host type: " << host_type; - } +extensions::ExtensionHost* CefBrowserPlatformDelegate::GetExtensionHost() + const { + NOTREACHED(); + return nullptr; } void CefBrowserPlatformDelegate::NotifyBrowserCreated() {} @@ -228,9 +87,6 @@ void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostImpl* browser) { // WebContentsDestroyed should already be called. DCHECK(!web_contents_); - DestroyExtensionHost(); - owned_web_contents_.reset(); - DCHECK(browser_ && browser_ == browser); browser_ = nullptr; } @@ -268,19 +124,11 @@ void CefBrowserPlatformDelegate::PopupBrowserCreated( bool is_devtools) {} void CefBrowserPlatformDelegate::SendCaptureLostEvent() { - content::RenderWidgetHostImpl* widget = content::RenderWidgetHostImpl::From( - browser_->web_contents()->GetRenderViewHost()->GetWidget()); - if (widget) - widget->LostCapture(); + NOTIMPLEMENTED(); } #if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MACOSX)) -void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() { - // Dismiss any existing popups. - content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost(); - if (host) - host->NotifyMoveOrResizeStarted(); -} +void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {} void CefBrowserPlatformDelegate::SizeTo(int width, int height) {} #endif @@ -288,25 +136,23 @@ void CefBrowserPlatformDelegate::SizeTo(int width, int height) {} bool CefBrowserPlatformDelegate::PreHandleGestureEvent( content::WebContents* source, const blink::WebGestureEvent& event) { - if (extension_host_) - return extension_host_->PreHandleGestureEvent(source, event); return false; } bool CefBrowserPlatformDelegate::IsNeverComposited( content::WebContents* web_contents) { - if (extension_host_) - return extension_host_->IsNeverComposited(web_contents); return false; } std::unique_ptr CefBrowserPlatformDelegate::CreateFileDialogRunner() { + NOTIMPLEMENTED(); return nullptr; } std::unique_ptr CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() { + NOTIMPLEMENTED(); return nullptr; } @@ -424,102 +270,27 @@ gfx::Size CefBrowserPlatformDelegate::GetMaximumDialogSize() { void CefBrowserPlatformDelegate::SetAutoResizeEnabled(bool enabled, const CefSize& min_size, const CefSize& max_size) { - if (enabled == auto_resize_enabled_) - return; - - auto_resize_enabled_ = enabled; - if (enabled) { - auto_resize_min_ = gfx::Size(min_size.width, min_size.height); - auto_resize_max_ = gfx::Size(max_size.width, max_size.height); - } else { - auto_resize_min_ = auto_resize_max_ = gfx::Size(); - } - ConfigureAutoResize(); -} - -void CefBrowserPlatformDelegate::ConfigureAutoResize() { - if (!web_contents_ || !web_contents_->GetRenderWidgetHostView()) { - return; - } - - if (auto_resize_enabled_) { - web_contents_->GetRenderWidgetHostView()->EnableAutoResize( - auto_resize_min_, auto_resize_max_); - } else { - web_contents_->GetRenderWidgetHostView()->DisableAutoResize(gfx::Size()); - } + NOTIMPLEMENTED(); } void CefBrowserPlatformDelegate::SetAccessibilityState( cef_state_t accessibility_state) { - // Do nothing if state is set to default. It'll be disabled by default and - // controlled by the commmand-line flags "force-renderer-accessibility" and - // "disable-renderer-accessibility". - if (accessibility_state == STATE_DEFAULT) - return; - - content::WebContentsImpl* web_contents_impl = - static_cast(web_contents_); - - if (!web_contents_impl) - return; - - ui::AXMode accMode; - // In windowless mode set accessibility to TreeOnly mode. Else native - // accessibility APIs, specific to each platform, are also created. - if (accessibility_state == STATE_ENABLED) { - accMode = IsWindowless() ? ui::kAXModeWebContentsOnly : ui::kAXModeComplete; - } - web_contents_impl->SetAccessibilityMode(accMode); + NOTIMPLEMENTED(); } bool CefBrowserPlatformDelegate::IsPrintPreviewSupported() const { - CEF_REQUIRE_UIT(); - auto actionable_contents = GetActionableWebContents(); - if (!actionable_contents) - return false; - - auto cef_browser_context = CefBrowserContext::FromBrowserContext( - actionable_contents->GetBrowserContext()); - if (!cef_browser_context->IsPrintPreviewSupported()) { - return false; - } - - // Print preview is not currently supported with OSR. - return !IsWindowless(); + return true; } void CefBrowserPlatformDelegate::Print() { - auto actionable_contents = GetActionableWebContents(); - if (!actionable_contents) - return; - - auto rfh = actionable_contents->GetMainFrame(); - - if (IsPrintPreviewSupported()) { - printing::CefPrintViewManager::FromWebContents(actionable_contents) - ->PrintPreviewNow(rfh, false); - } else { - printing::PrintViewManager::FromWebContents(actionable_contents) - ->PrintNow(rfh); - } + NOTIMPLEMENTED(); } void CefBrowserPlatformDelegate::PrintToPDF( const CefString& path, const CefPdfPrintSettings& settings, CefRefPtr callback) { - content::WebContents* actionable_contents = GetActionableWebContents(); - if (!actionable_contents) - return; - printing::CefPrintViewManager::PdfPrintCallback pdf_callback; - if (callback.get()) { - pdf_callback = base::Bind(&CefPdfPrintCallback::OnPdfPrintFinished, - callback.get(), path); - } - printing::CefPrintViewManager::FromWebContents(actionable_contents) - ->PrintToPDF(actionable_contents->GetMainFrame(), base::FilePath(path), - settings, pdf_callback); + NOTIMPLEMENTED(); } void CefBrowserPlatformDelegate::Find(int identifier, @@ -527,40 +298,11 @@ void CefBrowserPlatformDelegate::Find(int identifier, bool forward, bool matchCase, bool findNext) { - if (!web_contents_) - return; - - // Every find request must have a unique ID and these IDs must strictly - // increase so that newer requests always have greater IDs than older - // requests. - if (identifier <= find_request_id_counter_) - identifier = ++find_request_id_counter_; - else - find_request_id_counter_ = identifier; - - auto options = blink::mojom::FindOptions::New(); - options->forward = forward; - options->match_case = matchCase; - options->find_next = findNext; - web_contents_->Find(identifier, searchText, std::move(options)); + NOTIMPLEMENTED(); } void CefBrowserPlatformDelegate::StopFinding(bool clearSelection) { - if (!web_contents_) - return; - - content::StopFindAction action = - clearSelection ? content::STOP_FIND_ACTION_CLEAR_SELECTION - : content::STOP_FIND_ACTION_KEEP_SELECTION; - web_contents_->StopFinding(action); -} - -base::RepeatingClosure CefBrowserPlatformDelegate::GetBoundsChangedCallback() { - if (web_contents_dialog_helper_) { - return web_contents_dialog_helper_->GetBoundsChangedCallback(); - } - - return base::RepeatingClosure(); + NOTIMPLEMENTED(); } // static @@ -594,48 +336,3 @@ int CefBrowserPlatformDelegate::TranslateWebEventModifiers( result |= blink::WebInputEvent::kIsKeyPad; return result; } - -content::WebContents* CefBrowserPlatformDelegate::GetActionableWebContents() - const { - if (web_contents_ && extensions::ExtensionsEnabled()) { - content::WebContents* guest_contents = - extensions::GetFullPageGuestForOwnerContents(web_contents_); - if (guest_contents) - return guest_contents; - } - return web_contents_; -} - -void CefBrowserPlatformDelegate::SetOwnedWebContents( - content::WebContents* owned_contents) { - REQUIRE_ALLOY_RUNTIME(); - - // Should not currently own a WebContents. - CHECK(!owned_web_contents_); - owned_web_contents_.reset(owned_contents); -} - -void CefBrowserPlatformDelegate::DestroyExtensionHost() { - if (!extension_host_) - return; - if (extension_host_->extension_host_type() == - extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { - DCHECK(is_background_host_); - // Close notification for background pages arrives via CloseContents. - // The extension host will be deleted by - // ProcessManager::CloseBackgroundHost and OnExtensionHostDeleted will be - // called to notify us. - extension_host_->Close(); - } else { - DCHECK(!is_background_host_); - // We own the extension host and must delete it. - delete extension_host_; - extension_host_ = nullptr; - } -} - -void CefBrowserPlatformDelegate::OnExtensionHostDeleted() { - DCHECK(is_background_host_); - DCHECK(extension_host_); - extension_host_ = nullptr; -} diff --git a/libcef/browser/browser_platform_delegate.h b/libcef/browser/browser_platform_delegate.h index 1282afd56..0e269498c 100644 --- a/libcef/browser/browser_platform_delegate.h +++ b/libcef/browser/browser_platform_delegate.h @@ -16,7 +16,6 @@ #include "libcef/browser/browser_host_impl.h" #include "base/callback_forward.h" -#include "base/memory/weak_ptr.h" #include "content/public/browser/web_contents.h" namespace blink { @@ -43,11 +42,9 @@ class Widget; } #endif -class CefBrowserInfo; class CefFileDialogRunner; class CefJavaScriptDialogRunner; class CefMenuRunner; -class CefWebContentsDialogHelper; // Provides platform-specific implementations of browser functionality. All // methods are called on the browser process UI thread unless otherwise @@ -64,7 +61,7 @@ class CefBrowserPlatformDelegate { // of the resulting WebContents object. virtual content::WebContents* CreateWebContents( CefBrowserHostImpl::CreateParams& create_params, - bool& own_web_contents); + bool& own_web_contents) = 0; // Called to create the view objects for a new WebContents. Will only be // called a single time per instance. May be called on multiple threads. Only @@ -103,15 +100,21 @@ class CefBrowserPlatformDelegate { // Called after the RenderViewHost is created. virtual void RenderViewCreated(content::RenderViewHost* render_view_host); + // See WebContentsObserver documentation. + virtual void RenderViewReady(); + // Called after the owning CefBrowserHostImpl is created. Will only be called // a single time per instance. Do not send any client notifications from this // method. virtual void BrowserCreated(CefBrowserHostImpl* browser); // Called from CefBrowserHostImpl::Create. - void CreateExtensionHost(const extensions::Extension* extension, - const GURL& url, - extensions::ViewType host_type); + virtual void CreateExtensionHost(const extensions::Extension* extension, + const GURL& url, + extensions::ViewType host_type); + + // Returns the current extension host. + virtual extensions::ExtensionHost* GetExtensionHost() const; // Send any notifications related to browser creation. Called after // BrowserCreated(). @@ -181,9 +184,6 @@ class CefBrowserPlatformDelegate { // enable transparency. virtual SkColor GetBackgroundColor() const = 0; - virtual bool CanUseSharedTexture() const = 0; - virtual bool CanUseExternalBeginFrame() const = 0; - // Notify the window that it was resized. virtual void WasResized() = 0; @@ -271,6 +271,7 @@ class CefBrowserPlatformDelegate { // Invalidate the view. Only used with windowless rendering. virtual void Invalidate(cef_paint_element_type_t type); + // Send the external begin frame message. Only used with windowless rendering. virtual void SendExternalBeginFrame(); // Set the windowless frame rate. Only used with windowless rendering. @@ -315,10 +316,9 @@ class CefBrowserPlatformDelegate { virtual gfx::Size GetMaximumDialogSize(); // See CefBrowserHost documentation. - void SetAutoResizeEnabled(bool enabled, - const CefSize& min_size, - const CefSize& max_size); - virtual void ConfigureAutoResize(); + virtual void SetAutoResizeEnabled(bool enabled, + const CefSize& min_size, + const CefSize& max_size); virtual void SetAccessibilityState(cef_state_t accessibility_state); virtual bool IsPrintPreviewSupported() const; virtual void Print(); @@ -332,8 +332,6 @@ class CefBrowserPlatformDelegate { bool findNext); virtual void StopFinding(bool clearSelection); - extensions::ExtensionHost* extension_host() const { return extension_host_; } - protected: // Allow deletion via scoped_ptr only. friend std::default_delete; @@ -341,49 +339,12 @@ class CefBrowserPlatformDelegate { CefBrowserPlatformDelegate(); virtual ~CefBrowserPlatformDelegate(); - base::RepeatingClosure GetBoundsChangedCallback(); - static int TranslateWebEventModifiers(uint32 cef_modifiers); - // Returns the WebContents most likely to handle an action. If extensions are - // enabled and this browser has a full-page guest (for example, a full-page - // PDF viewer extension) then the guest's WebContents will be returned. - // Otherwise, the browser's WebContents will be returned. - content::WebContents* GetActionableWebContents() const; - // Not owned by this object. content::WebContents* web_contents_ = nullptr; CefBrowserHostImpl* browser_ = nullptr; - private: - void SetOwnedWebContents(content::WebContents* owned_contents); - - void DestroyExtensionHost(); - void OnExtensionHostDeleted(); - - // Non-nullptr if this object owns the WebContents. Will be nullptr for popup - // browsers between the calls to WebContentsCreated() and AddNewContents(), - // and may never be set if the parent browser is destroyed during popup - // creation. - std::unique_ptr owned_web_contents_; - - // Used for the print preview dialog. - std::unique_ptr web_contents_dialog_helper_; - - // Used to provide unique incremental IDs for each find request. - int find_request_id_counter_ = 0; - - // Used when the browser is hosting an extension. - extensions::ExtensionHost* extension_host_ = nullptr; - bool is_background_host_ = false; - - // Used with auto-resize. - bool auto_resize_enabled_ = false; - gfx::Size auto_resize_min_; - gfx::Size auto_resize_max_; - - base::WeakPtrFactory weak_ptr_factory_; - DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate); }; diff --git a/libcef/browser/browser_platform_delegate_create.cc b/libcef/browser/browser_platform_delegate_create.cc index 44364bbd8..954581e91 100644 --- a/libcef/browser/browser_platform_delegate_create.cc +++ b/libcef/browser/browser_platform_delegate_create.cc @@ -36,33 +36,32 @@ namespace { std::unique_ptr CreateNativeDelegate( const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame) { + SkColor background_color) { #if defined(OS_WIN) return std::make_unique( - window_info, background_color, use_shared_texture, - use_external_begin_frame); + window_info, background_color); #elif defined(OS_MACOSX) return std::make_unique( window_info, background_color); #elif defined(OS_LINUX) return std::make_unique( - window_info, background_color, use_external_begin_frame); + window_info, background_color); #endif } std::unique_ptr CreateOSRDelegate( - std::unique_ptr native_delegate) { + std::unique_ptr native_delegate, + bool use_shared_texture, + bool use_external_begin_frame) { #if defined(OS_WIN) return std::make_unique( - std::move(native_delegate)); + std::move(native_delegate), use_shared_texture, use_external_begin_frame); #elif defined(OS_MACOSX) return std::make_unique( std::move(native_delegate)); #elif defined(OS_LINUX) return std::make_unique( - std::move(native_delegate)); + std::move(native_delegate), use_external_begin_frame); #endif } @@ -78,37 +77,34 @@ std::unique_ptr CefBrowserPlatformDelegate::Create( const SkColor background_color = CefContext::Get()->GetBackgroundColor( &create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED); - bool use_shared_texture = false; - bool use_external_begin_frame = false; - - if (is_windowless) { - REQUIRE_ALLOY_RUNTIME(); - - use_shared_texture = create_params.window_info && - create_params.window_info->shared_texture_enabled; - - use_external_begin_frame = - create_params.window_info && - create_params.window_info->external_begin_frame_enabled; - } - if (cef::IsChromeRuntimeEnabled()) { return std::make_unique(background_color); } if (create_params.window_info) { std::unique_ptr native_delegate = - CreateNativeDelegate(*create_params.window_info.get(), background_color, - use_shared_texture, use_external_begin_frame); - if (is_windowless) - return CreateOSRDelegate(std::move(native_delegate)); + CreateNativeDelegate(*create_params.window_info.get(), + background_color); + if (is_windowless) { + REQUIRE_ALLOY_RUNTIME(); + + const bool use_shared_texture = + create_params.window_info && + create_params.window_info->shared_texture_enabled; + + const bool use_external_begin_frame = + create_params.window_info && + create_params.window_info->external_begin_frame_enabled; + + return CreateOSRDelegate(std::move(native_delegate), use_shared_texture, + use_external_begin_frame); + } return std::move(native_delegate); } else if (create_params.extension_host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) { // Creating a background extension host without a window. std::unique_ptr native_delegate = - CreateNativeDelegate(CefWindowInfo(), background_color, - use_shared_texture, use_external_begin_frame); + CreateNativeDelegate(CefWindowInfo(), background_color); return std::make_unique( std::move(native_delegate)); } @@ -116,8 +112,7 @@ std::unique_ptr CefBrowserPlatformDelegate::Create( else { // CefWindowInfo is not used in this case. std::unique_ptr native_delegate = - CreateNativeDelegate(CefWindowInfo(), background_color, - use_shared_texture, use_external_begin_frame); + CreateNativeDelegate(CefWindowInfo(), background_color); return std::make_unique( std::move(native_delegate), static_cast(create_params.browser_view.get())); diff --git a/libcef/browser/chrome/browser_platform_delegate_chrome.cc b/libcef/browser/chrome/browser_platform_delegate_chrome.cc index 53a8c2be8..a8bd9a249 100644 --- a/libcef/browser/chrome/browser_platform_delegate_chrome.cc +++ b/libcef/browser/chrome/browser_platform_delegate_chrome.cc @@ -4,6 +4,7 @@ #include "libcef/browser/chrome/browser_platform_delegate_chrome.h" +#include "base/logging.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_window.h" @@ -81,14 +82,6 @@ SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const { return background_color_; } -bool CefBrowserPlatformDelegateChrome::CanUseSharedTexture() const { - return false; -} - -bool CefBrowserPlatformDelegateChrome::CanUseExternalBeginFrame() const { - return false; -} - void CefBrowserPlatformDelegateChrome::WasResized() {} void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {} @@ -132,6 +125,7 @@ CefEventHandle CefBrowserPlatformDelegateChrome::GetEventHandle( std::unique_ptr CefBrowserPlatformDelegateChrome::CreateMenuRunner() { + NOTIMPLEMENTED(); return nullptr; } diff --git a/libcef/browser/chrome/browser_platform_delegate_chrome.h b/libcef/browser/chrome/browser_platform_delegate_chrome.h index 581442d19..a19855b97 100644 --- a/libcef/browser/chrome/browser_platform_delegate_chrome.h +++ b/libcef/browser/chrome/browser_platform_delegate_chrome.h @@ -24,8 +24,6 @@ class CefBrowserPlatformDelegateChrome : public CefBrowserPlatformDelegate { void CloseHostWindow() override; CefWindowHandle GetHostWindowHandle() const override; SkColor GetBackgroundColor() const override; - bool CanUseSharedTexture() const override; - bool CanUseExternalBeginFrame() const override; void WasResized() override; void SendKeyEvent(const CefKeyEvent& event) override; void SendMouseClickEvent(const CefMouseEvent& event, diff --git a/libcef/browser/extensions/browser_platform_delegate_background.cc b/libcef/browser/extensions/browser_platform_delegate_background.cc index ac542b9bf..ca3d80cae 100644 --- a/libcef/browser/extensions/browser_platform_delegate_background.cc +++ b/libcef/browser/extensions/browser_platform_delegate_background.cc @@ -35,14 +35,6 @@ CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle() return kNullWindowHandle; } -bool CefBrowserPlatformDelegateBackground::CanUseSharedTexture() const { - return native_delegate_->CanUseSharedTexture(); -} - -bool CefBrowserPlatformDelegateBackground::CanUseExternalBeginFrame() const { - return native_delegate_->CanUseExternalBeginFrame(); -} - SkColor CefBrowserPlatformDelegateBackground::GetBackgroundColor() const { return native_delegate_->GetBackgroundColor(); } diff --git a/libcef/browser/extensions/browser_platform_delegate_background.h b/libcef/browser/extensions/browser_platform_delegate_background.h index 2ded3736c..2aaf2a055 100644 --- a/libcef/browser/extensions/browser_platform_delegate_background.h +++ b/libcef/browser/extensions/browser_platform_delegate_background.h @@ -5,12 +5,12 @@ #ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_ #define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_BACKGROUND_H_ -#include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/alloy/browser_platform_delegate_alloy.h" #include "libcef/browser/native/browser_platform_delegate_native.h" // Implementation of browser functionality for background script hosts. class CefBrowserPlatformDelegateBackground - : public CefBrowserPlatformDelegate, + : public CefBrowserPlatformDelegateAlloy, public CefBrowserPlatformDelegateNative::WindowlessHandler { public: // Platform-specific behaviors will be delegated to |native_delegate|. @@ -22,8 +22,6 @@ class CefBrowserPlatformDelegateBackground void CloseHostWindow() override; CefWindowHandle GetHostWindowHandle() const override; SkColor GetBackgroundColor() const override; - bool CanUseSharedTexture() const override; - bool CanUseExternalBeginFrame() const override; void WasResized() override; void SendKeyEvent(const CefKeyEvent& event) override; void SendMouseClickEvent(const CefMouseEvent& event, diff --git a/libcef/browser/native/browser_platform_delegate_native.cc b/libcef/browser/native/browser_platform_delegate_native.cc index b26ee3e1f..0fb83cf01 100644 --- a/libcef/browser/native/browser_platform_delegate_native.cc +++ b/libcef/browser/native/browser_platform_delegate_native.cc @@ -12,27 +12,15 @@ CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative( const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame) + SkColor background_color) : window_info_(window_info), background_color_(background_color), - use_shared_texture_(use_shared_texture), - use_external_begin_frame_(use_external_begin_frame), windowless_handler_(nullptr) {} SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const { return background_color_; } -bool CefBrowserPlatformDelegateNative::CanUseSharedTexture() const { - return use_shared_texture_; -} - -bool CefBrowserPlatformDelegateNative::CanUseExternalBeginFrame() const { - return use_external_begin_frame_; -} - void CefBrowserPlatformDelegateNative::WasResized() { content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost(); if (host) diff --git a/libcef/browser/native/browser_platform_delegate_native.h b/libcef/browser/native/browser_platform_delegate_native.h index a7c3003ca..e3e608818 100644 --- a/libcef/browser/native/browser_platform_delegate_native.h +++ b/libcef/browser/native/browser_platform_delegate_native.h @@ -5,10 +5,11 @@ #ifndef CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ #define CEF_LIBCEF_BROWSER_NATIVE_BROWSER_PLATFORM_DELEGATE_NATIVE_H_ -#include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/alloy/browser_platform_delegate_alloy.h" // Base implementation of native browser functionality. -class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate { +class CefBrowserPlatformDelegateNative + : public CefBrowserPlatformDelegateAlloy { public: // Used by the windowless implementation to override specific functionality // when delegating to the native implementation. @@ -25,8 +26,6 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate { }; // CefBrowserPlatformDelegate methods: - bool CanUseSharedTexture() const override; - bool CanUseExternalBeginFrame() const override; SkColor GetBackgroundColor() const override; void WasResized() override; bool IsWindowless() const override; @@ -57,9 +56,7 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate { friend class CefBrowserPlatformDelegateViews; CefBrowserPlatformDelegateNative(const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame); + SkColor background_color); // Methods used by delegates that can wrap a native delegate. void set_windowless_handler(WindowlessHandler* handler) { @@ -69,8 +66,6 @@ class CefBrowserPlatformDelegateNative : public CefBrowserPlatformDelegate { CefWindowInfo window_info_; const SkColor background_color_; - const bool use_shared_texture_; - const bool use_external_begin_frame_; WindowlessHandler* windowless_handler_; // Not owned by this object. }; diff --git a/libcef/browser/native/browser_platform_delegate_native_aura.cc b/libcef/browser/native/browser_platform_delegate_native_aura.cc index db5ceb1ea..e9f5a1d24 100644 --- a/libcef/browser/native/browser_platform_delegate_native_aura.cc +++ b/libcef/browser/native/browser_platform_delegate_native_aura.cc @@ -13,13 +13,8 @@ CefBrowserPlatformDelegateNativeAura::CefBrowserPlatformDelegateNativeAura( const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame) - : CefBrowserPlatformDelegateNative(window_info, - background_color, - use_shared_texture, - use_external_begin_frame) {} + SkColor background_color) + : CefBrowserPlatformDelegateNative(window_info, background_color) {} void CefBrowserPlatformDelegateNativeAura::SendKeyEvent( const CefKeyEvent& event) { diff --git a/libcef/browser/native/browser_platform_delegate_native_aura.h b/libcef/browser/native/browser_platform_delegate_native_aura.h index 96b5a41d7..63d9546b8 100644 --- a/libcef/browser/native/browser_platform_delegate_native_aura.h +++ b/libcef/browser/native/browser_platform_delegate_native_aura.h @@ -22,9 +22,7 @@ class CefBrowserPlatformDelegateNativeAura : public CefBrowserPlatformDelegateNative { public: CefBrowserPlatformDelegateNativeAura(const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame); + SkColor background_color); // CefBrowserPlatformDelegate methods: void SendKeyEvent(const CefKeyEvent& event) override; diff --git a/libcef/browser/native/browser_platform_delegate_native_linux.cc b/libcef/browser/native/browser_platform_delegate_native_linux.cc index b6364b2f0..2784d30e5 100644 --- a/libcef/browser/native/browser_platform_delegate_native_linux.cc +++ b/libcef/browser/native/browser_platform_delegate_native_linux.cc @@ -44,18 +44,14 @@ long GetSystemUptime() { CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux( const CefWindowInfo& window_info, - SkColor background_color, - bool use_external_begin_frame) - : CefBrowserPlatformDelegateNativeAura(window_info, - background_color, - false, - use_external_begin_frame), + SkColor background_color) + : CefBrowserPlatformDelegateNativeAura(window_info, background_color), host_window_created_(false), window_widget_(nullptr) {} void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserDestroyed(browser); + CefBrowserPlatformDelegateNative::BrowserDestroyed(browser); if (host_window_created_) { // Release the reference added in CreateHostWindow(). @@ -166,7 +162,7 @@ void CefBrowserPlatformDelegateNativeLinux::SendFocusEvent(bool setFocus) { void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() { // Call the parent method to dismiss any existing popups. - CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted(); + CefBrowserPlatformDelegateNative::NotifyMoveOrResizeStarted(); #if defined(USE_X11) if (!window_x11_) diff --git a/libcef/browser/native/browser_platform_delegate_native_linux.h b/libcef/browser/native/browser_platform_delegate_native_linux.h index 7f1834a3d..cb8a235c2 100644 --- a/libcef/browser/native/browser_platform_delegate_native_linux.h +++ b/libcef/browser/native/browser_platform_delegate_native_linux.h @@ -16,8 +16,7 @@ class CefBrowserPlatformDelegateNativeLinux : public CefBrowserPlatformDelegateNativeAura { public: CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info, - SkColor background_color, - bool use_external_begin_frame); + SkColor background_color); // CefBrowserPlatformDelegate methods: void BrowserDestroyed(CefBrowserHostImpl* browser) override; diff --git a/libcef/browser/native/browser_platform_delegate_native_mac.mm b/libcef/browser/native/browser_platform_delegate_native_mac.mm index 34569ca82..9dc266618 100644 --- a/libcef/browser/native/browser_platform_delegate_native_mac.mm +++ b/libcef/browser/native/browser_platform_delegate_native_mac.mm @@ -146,15 +146,12 @@ NSUInteger NativeModifiers(int cef_modifiers) { CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac( const CefWindowInfo& window_info, SkColor background_color) - : CefBrowserPlatformDelegateNative(window_info, - background_color, - false, - false), + : CefBrowserPlatformDelegateNative(window_info, background_color), host_window_created_(false) {} void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserDestroyed(browser); + CefBrowserPlatformDelegateNative::BrowserDestroyed(browser); if (host_window_created_) { // Release the reference added in CreateHostWindow(). diff --git a/libcef/browser/native/browser_platform_delegate_native_win.cc b/libcef/browser/native/browser_platform_delegate_native_win.cc index 4c923c971..23e9ee2d1 100644 --- a/libcef/browser/native/browser_platform_delegate_native_win.cc +++ b/libcef/browser/native/browser_platform_delegate_native_win.cc @@ -126,19 +126,14 @@ float GetWindowScaleFactor(HWND hwnd) { CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin( const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame) - : CefBrowserPlatformDelegateNativeAura(window_info, - background_color, - use_shared_texture, - use_external_begin_frame), + SkColor background_color) + : CefBrowserPlatformDelegateNativeAura(window_info, background_color), host_window_created_(false), window_widget_(nullptr) {} void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserDestroyed(browser); + CefBrowserPlatformDelegateNative::BrowserDestroyed(browser); if (host_window_created_) { // Release the reference added in CreateHostWindow(). @@ -295,7 +290,7 @@ void CefBrowserPlatformDelegateNativeWin::SendFocusEvent(bool setFocus) { void CefBrowserPlatformDelegateNativeWin::NotifyMoveOrResizeStarted() { // Call the parent method to dismiss any existing popups. - CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted(); + CefBrowserPlatformDelegateNative::NotifyMoveOrResizeStarted(); if (!window_widget_) return; diff --git a/libcef/browser/native/browser_platform_delegate_native_win.h b/libcef/browser/native/browser_platform_delegate_native_win.h index e1dd0a097..c2ab6b3cc 100644 --- a/libcef/browser/native/browser_platform_delegate_native_win.h +++ b/libcef/browser/native/browser_platform_delegate_native_win.h @@ -14,9 +14,7 @@ class CefBrowserPlatformDelegateNativeWin : public CefBrowserPlatformDelegateNativeAura { public: CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info, - SkColor background_color, - bool use_shared_texture, - bool use_external_begin_frame); + SkColor background_color); // CefBrowserPlatformDelegate methods: void BrowserDestroyed(CefBrowserHostImpl* browser) override; diff --git a/libcef/browser/osr/browser_platform_delegate_osr.cc b/libcef/browser/osr/browser_platform_delegate_osr.cc index 829ae8b63..22d01b9ec 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr.cc @@ -20,8 +20,12 @@ #include "ui/events/base_event_utils.h" CefBrowserPlatformDelegateOsr::CefBrowserPlatformDelegateOsr( - std::unique_ptr native_delegate) - : native_delegate_(std::move(native_delegate)), view_osr_(nullptr) { + std::unique_ptr native_delegate, + bool use_shared_texture, + bool use_external_begin_frame) + : native_delegate_(std::move(native_delegate)), + use_shared_texture_(use_shared_texture), + use_external_begin_frame_(use_external_begin_frame) { native_delegate_->set_windowless_handler(this); } @@ -32,7 +36,7 @@ void CefBrowserPlatformDelegateOsr::CreateViewForWebContents( // Use the OSR view instead of the default platform view. view_osr_ = new CefWebContentsViewOSR( - GetBackgroundColor(), CanUseSharedTexture(), CanUseExternalBeginFrame()); + GetBackgroundColor(), use_shared_texture_, use_external_begin_frame_); *view = view_osr_; *delegate_view = view_osr_; } @@ -40,7 +44,7 @@ void CefBrowserPlatformDelegateOsr::CreateViewForWebContents( void CefBrowserPlatformDelegateOsr::WebContentsCreated( content::WebContents* web_contents, bool owned) { - CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned); + CefBrowserPlatformDelegateAlloy::WebContentsCreated(web_contents, owned); DCHECK(view_osr_); DCHECK(!view_osr_->web_contents()); @@ -51,7 +55,7 @@ void CefBrowserPlatformDelegateOsr::WebContentsCreated( void CefBrowserPlatformDelegateOsr::BrowserCreated( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserCreated(browser); + CefBrowserPlatformDelegateAlloy::BrowserCreated(browser); if (browser->IsPopup()) { // Associate the RenderWidget host view with the browser now because the @@ -69,19 +73,11 @@ void CefBrowserPlatformDelegateOsr::BrowserCreated( void CefBrowserPlatformDelegateOsr::BrowserDestroyed( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserDestroyed(browser); + CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser); view_osr_ = nullptr; } -bool CefBrowserPlatformDelegateOsr::CanUseSharedTexture() const { - return native_delegate_->CanUseSharedTexture(); -} - -bool CefBrowserPlatformDelegateOsr::CanUseExternalBeginFrame() const { - return native_delegate_->CanUseExternalBeginFrame(); -} - SkColor CefBrowserPlatformDelegateOsr::GetBackgroundColor() const { return native_delegate_->GetBackgroundColor(); } diff --git a/libcef/browser/osr/browser_platform_delegate_osr.h b/libcef/browser/osr/browser_platform_delegate_osr.h index 4dc3fcd44..6537915b4 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr.h +++ b/libcef/browser/osr/browser_platform_delegate_osr.h @@ -5,7 +5,7 @@ #ifndef CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_ #define CEF_LIBCEF_BROWSER_OSR_BROWSER_PLATFORM_DELEGATE_OSR_H_ -#include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/alloy/browser_platform_delegate_alloy.h" #include "libcef/browser/native/browser_platform_delegate_native.h" class CefRenderWidgetHostViewOSR; @@ -17,7 +17,7 @@ class RenderWidgetHostImpl; // Base implementation of windowless browser functionality. class CefBrowserPlatformDelegateOsr - : public CefBrowserPlatformDelegate, + : public CefBrowserPlatformDelegateAlloy, public CefBrowserPlatformDelegateNative::WindowlessHandler { public: // CefBrowserPlatformDelegate methods: @@ -29,8 +29,6 @@ class CefBrowserPlatformDelegateOsr void BrowserCreated(CefBrowserHostImpl* browser) override; void BrowserDestroyed(CefBrowserHostImpl* browser) override; SkColor GetBackgroundColor() const override; - bool CanUseSharedTexture() const override; - bool CanUseExternalBeginFrame() const override; void WasResized() override; void SendKeyEvent(const CefKeyEvent& event) override; void SendMouseClickEvent(const CefMouseEvent& event, @@ -97,8 +95,10 @@ class CefBrowserPlatformDelegateOsr protected: // Platform-specific behaviors will be delegated to |native_delegate|. - explicit CefBrowserPlatformDelegateOsr( - std::unique_ptr native_delegate); + CefBrowserPlatformDelegateOsr( + std::unique_ptr native_delegate, + bool use_shared_texture, + bool use_external_begin_frame); // Returns the primary OSR host view for the underlying browser. If a // full-screen host view currently exists then it will be returned. Otherwise, @@ -106,7 +106,10 @@ class CefBrowserPlatformDelegateOsr CefRenderWidgetHostViewOSR* GetOSRHostView() const; std::unique_ptr native_delegate_; - CefWebContentsViewOSR* view_osr_; // Not owned by this class. + const bool use_shared_texture_; + const bool use_external_begin_frame_; + + CefWebContentsViewOSR* view_osr_ = nullptr; // Not owned by this class. // Pending drag/drop data. CefRefPtr drag_data_; diff --git a/libcef/browser/osr/browser_platform_delegate_osr_linux.cc b/libcef/browser/osr/browser_platform_delegate_osr_linux.cc index fda16ef30..2f7fef111 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_linux.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr_linux.cc @@ -9,8 +9,11 @@ #include "libcef/browser/browser_host_impl.h" CefBrowserPlatformDelegateOsrLinux::CefBrowserPlatformDelegateOsrLinux( - std::unique_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) {} + std::unique_ptr native_delegate, + bool use_external_begin_frame) + : CefBrowserPlatformDelegateOsr(std::move(native_delegate), + /*use_shared_texture=*/false, + use_external_begin_frame) {} CefWindowHandle CefBrowserPlatformDelegateOsrLinux::GetHostWindowHandle() const { diff --git a/libcef/browser/osr/browser_platform_delegate_osr_linux.h b/libcef/browser/osr/browser_platform_delegate_osr_linux.h index 4dc86ff3d..071a2cdd4 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_linux.h +++ b/libcef/browser/osr/browser_platform_delegate_osr_linux.h @@ -11,8 +11,9 @@ class CefBrowserPlatformDelegateOsrLinux : public CefBrowserPlatformDelegateOsr { public: - explicit CefBrowserPlatformDelegateOsrLinux( - std::unique_ptr native_delegate); + CefBrowserPlatformDelegateOsrLinux( + std::unique_ptr native_delegate, + bool use_external_begin_frame); // CefBrowserPlatformDelegate methods: CefWindowHandle GetHostWindowHandle() const override; diff --git a/libcef/browser/osr/browser_platform_delegate_osr_mac.mm b/libcef/browser/osr/browser_platform_delegate_osr_mac.mm index a1f4afe4f..a2fa7b268 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_mac.mm +++ b/libcef/browser/osr/browser_platform_delegate_osr_mac.mm @@ -11,7 +11,9 @@ CefBrowserPlatformDelegateOsrMac::CefBrowserPlatformDelegateOsrMac( std::unique_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) {} + : CefBrowserPlatformDelegateOsr(std::move(native_delegate), + /*use_shared_texture=*/false, + /*use_external_begin_frame=*/false) {} CefWindowHandle CefBrowserPlatformDelegateOsrMac::GetHostWindowHandle() const { return native_delegate_->window_info().parent_view; diff --git a/libcef/browser/osr/browser_platform_delegate_osr_win.cc b/libcef/browser/osr/browser_platform_delegate_osr_win.cc index c09e79ccd..b9f624c31 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_win.cc +++ b/libcef/browser/osr/browser_platform_delegate_osr_win.cc @@ -9,8 +9,12 @@ #include "libcef/browser/browser_host_impl.h" CefBrowserPlatformDelegateOsrWin::CefBrowserPlatformDelegateOsrWin( - std::unique_ptr native_delegate) - : CefBrowserPlatformDelegateOsr(std::move(native_delegate)) {} + std::unique_ptr native_delegate, + bool use_shared_texture, + bool use_external_begin_frame) + : CefBrowserPlatformDelegateOsr(std::move(native_delegate), + use_shared_texture, + use_external_begin_frame) {} CefWindowHandle CefBrowserPlatformDelegateOsrWin::GetHostWindowHandle() const { return native_delegate_->window_info().parent_window; diff --git a/libcef/browser/osr/browser_platform_delegate_osr_win.h b/libcef/browser/osr/browser_platform_delegate_osr_win.h index bcc9d8b86..8c07a1530 100644 --- a/libcef/browser/osr/browser_platform_delegate_osr_win.h +++ b/libcef/browser/osr/browser_platform_delegate_osr_win.h @@ -11,7 +11,9 @@ class CefBrowserPlatformDelegateOsrWin : public CefBrowserPlatformDelegateOsr { public: explicit CefBrowserPlatformDelegateOsrWin( - std::unique_ptr native_delegate); + std::unique_ptr native_delegate, + bool use_shared_texture, + bool use_external_begin_frame); // CefBrowserPlatformDelegate methods: CefWindowHandle GetHostWindowHandle() const override; diff --git a/libcef/browser/views/browser_platform_delegate_views.cc b/libcef/browser/views/browser_platform_delegate_views.cc index ae4b615b9..e7bb11ff4 100644 --- a/libcef/browser/views/browser_platform_delegate_views.cc +++ b/libcef/browser/views/browser_platform_delegate_views.cc @@ -68,14 +68,14 @@ void CefBrowserPlatformDelegateViews::SetBrowserView( void CefBrowserPlatformDelegateViews::WebContentsCreated( content::WebContents* web_contents, bool owned) { - CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned); + CefBrowserPlatformDelegateAlloy::WebContentsCreated(web_contents, owned); browser_view_->WebContentsCreated(web_contents); } void CefBrowserPlatformDelegateViews::BrowserCreated( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserCreated(browser); + CefBrowserPlatformDelegateAlloy::BrowserCreated(browser); native_delegate_->set_browser(browser); browser_view_->BrowserCreated(browser, GetBoundsChangedCallback()); @@ -97,7 +97,7 @@ void CefBrowserPlatformDelegateViews::NotifyBrowserDestroyed() { void CefBrowserPlatformDelegateViews::BrowserDestroyed( CefBrowserHostImpl* browser) { - CefBrowserPlatformDelegate::BrowserDestroyed(browser); + CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser); native_delegate_->set_browser(nullptr); browser_view_->BrowserDestroyed(browser); @@ -173,14 +173,6 @@ void CefBrowserPlatformDelegateViews::PopupBrowserCreated( } } -bool CefBrowserPlatformDelegateViews::CanUseSharedTexture() const { - return native_delegate_->CanUseSharedTexture(); -} - -bool CefBrowserPlatformDelegateViews::CanUseExternalBeginFrame() const { - return native_delegate_->CanUseExternalBeginFrame(); -} - SkColor CefBrowserPlatformDelegateViews::GetBackgroundColor() const { return native_delegate_->GetBackgroundColor(); } diff --git a/libcef/browser/views/browser_platform_delegate_views.h b/libcef/browser/views/browser_platform_delegate_views.h index ce23f4c18..62d6904de 100644 --- a/libcef/browser/views/browser_platform_delegate_views.h +++ b/libcef/browser/views/browser_platform_delegate_views.h @@ -5,13 +5,13 @@ #ifndef CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_VIEWS_H_ #define CEF_LIBCEF_BROWSER_VIEWS_BROWSER_PLATFORM_DELEGATE_VIEWS_H_ -#include "libcef/browser/browser_platform_delegate.h" +#include "libcef/browser/alloy/browser_platform_delegate_alloy.h" #include "libcef/browser/native/browser_platform_delegate_native.h" #include "libcef/browser/views/browser_view_impl.h" // Implementation of Views-based browser functionality. class CefBrowserPlatformDelegateViews - : public CefBrowserPlatformDelegate, + : public CefBrowserPlatformDelegateAlloy, public CefBrowserPlatformDelegateNative::WindowlessHandler { public: // Platform-specific behaviors will be delegated to |native_delegate|. @@ -40,8 +40,6 @@ class CefBrowserPlatformDelegateViews bool is_devtools) override; void PopupBrowserCreated(CefBrowserHostImpl* new_browser, bool is_devtools) override; - bool CanUseSharedTexture() const override; - bool CanUseExternalBeginFrame() const override; SkColor GetBackgroundColor() const override; void WasResized() override; void SendKeyEvent(const CefKeyEvent& event) override;