mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-19 21:50:42 +01:00
Add chrome runtime support for more callbacks and ceftests (see issue #2969)
This change adds support for: - Protocol and request handling. - Loading and navigation events. - Display and focus events. - Mouse/keyboard events. - Popup browsers. - Callbacks in the renderer process. - Misc. functionality required for ceftests. This change also adds a new CefBrowserProcessHandler::GetCookieableSchemes callback for configuring global state that will be applied to all CefCookieManagers by default. This global callback is currently required by the chrome runtime because the primary ProfileImpl is created via ChromeBrowserMainParts::PreMainMessageLoopRun (CreatePrimaryProfile) before OnContextCreated can be called. ProfileImpl will use the "C:\Users\[user]\AppData\Local\CEF\User Data\Default" directory by default (on Windows). Cookies may persist in this directory when running ceftests and may need to be manually deleted if those tests fail. Remaining work includes: - Support for client-created request contexts. - Embedding the browser in a Views hierarchy (cefclient support). - TryCloseBrowser and DoClose support. - Most of the CefSettings configuration. - DevTools protocol and window control (ShowDevTools, ExecuteDevToolsMethod). - CEF-specific WebUI pages (about, license, webui-hosts). - Context menu customization (CefContextMenuHandler). - Auto resize (SetAutoResizeEnabled). - Zoom settings (SetZoomLevel). - File dialog runner (RunFileDialog). - File and JS dialog handlers (CefDialogHandler, CefJSDialogHandler). - Extension loading (LoadExtension, etc). - Plugin loading (OnBeforePluginLoad). - Widevine loading (CefRegisterWidevineCdm). - PDF and print preview does not display. - Crash reporting is untested. - Mac: Web content loads but does not display. The following ceftests are now passing when run with the "--enable-chrome-runtime" command-line flag: CorsTest.* DisplayTest.*:-DisplayTest.AutoResize DOMTest.* DraggableRegionsTest.* ImageTest.* MessageRouterTest.* NavigationTest.* ParserTest.* RequestContextTest.*Global* RequestTest.* ResourceManagerTest.* ResourceRequestHandlerTest.* ResponseTest.* SchemeHandlerTest.* ServerTest.* StreamResourceHandlerTest.* StreamTest.* StringTest.* TaskTest.* TestServerTest.* ThreadTest.* URLRequestTest.*Global* V8Test.*:-V8Test.OnUncaughtExceptionDevTools ValuesTest.* WaitableEventTest.* XmlReaderTest.* ZipReaderTest.*
This commit is contained in:
parent
e94a261bf5
commit
4fbd247231
16
BUILD.gn
16
BUILD.gn
@ -448,6 +448,8 @@ static_library("libcef_static") {
|
|||||||
"libcef/browser/browser_util.cc",
|
"libcef/browser/browser_util.cc",
|
||||||
"libcef/browser/browser_util.h",
|
"libcef/browser/browser_util.h",
|
||||||
"libcef/browser/chrome/browser_delegate.h",
|
"libcef/browser/chrome/browser_delegate.h",
|
||||||
|
"libcef/browser/chrome/browser_platform_delegate_chrome.cc",
|
||||||
|
"libcef/browser/chrome/browser_platform_delegate_chrome.h",
|
||||||
"libcef/browser/chrome/chrome_browser_context.cc",
|
"libcef/browser/chrome/chrome_browser_context.cc",
|
||||||
"libcef/browser/chrome/chrome_browser_context.h",
|
"libcef/browser/chrome/chrome_browser_context.h",
|
||||||
"libcef/browser/chrome/chrome_browser_delegate.cc",
|
"libcef/browser/chrome/chrome_browser_delegate.cc",
|
||||||
@ -567,6 +569,8 @@ static_library("libcef_static") {
|
|||||||
"libcef/browser/net/internal_scheme_handler.h",
|
"libcef/browser/net/internal_scheme_handler.h",
|
||||||
"libcef/browser/net/scheme_handler.cc",
|
"libcef/browser/net/scheme_handler.cc",
|
||||||
"libcef/browser/net/scheme_handler.h",
|
"libcef/browser/net/scheme_handler.h",
|
||||||
|
"libcef/browser/net/throttle_handler.cc",
|
||||||
|
"libcef/browser/net/throttle_handler.h",
|
||||||
"libcef/browser/net_service/browser_urlrequest_impl.cc",
|
"libcef/browser/net_service/browser_urlrequest_impl.cc",
|
||||||
"libcef/browser/net_service/browser_urlrequest_impl.h",
|
"libcef/browser/net_service/browser_urlrequest_impl.h",
|
||||||
"libcef/browser/net_service/cookie_helper.cc",
|
"libcef/browser/net_service/cookie_helper.cc",
|
||||||
@ -759,8 +763,18 @@ static_library("libcef_static") {
|
|||||||
"libcef/features/runtime_checks.h",
|
"libcef/features/runtime_checks.h",
|
||||||
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
|
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
|
||||||
"libcef/renderer/alloy/alloy_content_renderer_client.h",
|
"libcef/renderer/alloy/alloy_content_renderer_client.h",
|
||||||
|
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
|
||||||
|
"libcef/renderer/alloy/alloy_render_frame_observer.h",
|
||||||
|
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
|
||||||
|
"libcef/renderer/alloy/alloy_render_thread_observer.h",
|
||||||
|
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
|
||||||
|
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
|
||||||
"libcef/renderer/browser_impl.cc",
|
"libcef/renderer/browser_impl.cc",
|
||||||
"libcef/renderer/browser_impl.h",
|
"libcef/renderer/browser_impl.h",
|
||||||
|
"libcef/renderer/browser_manager.cc",
|
||||||
|
"libcef/renderer/browser_manager.h",
|
||||||
|
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
|
||||||
|
"libcef/renderer/chrome/chrome_content_renderer_client_cef.h",
|
||||||
"libcef/renderer/dom_document_impl.cc",
|
"libcef/renderer/dom_document_impl.cc",
|
||||||
"libcef/renderer/dom_document_impl.h",
|
"libcef/renderer/dom_document_impl.h",
|
||||||
"libcef/renderer/dom_node_impl.cc",
|
"libcef/renderer/dom_node_impl.cc",
|
||||||
@ -782,8 +796,6 @@ static_library("libcef_static") {
|
|||||||
"libcef/renderer/render_urlrequest_impl.cc",
|
"libcef/renderer/render_urlrequest_impl.cc",
|
||||||
"libcef/renderer/render_urlrequest_impl.h",
|
"libcef/renderer/render_urlrequest_impl.h",
|
||||||
"libcef/renderer/thread_util.h",
|
"libcef/renderer/thread_util.h",
|
||||||
"libcef/renderer/url_loader_throttle_provider_impl.cc",
|
|
||||||
"libcef/renderer/url_loader_throttle_provider_impl.h",
|
|
||||||
"libcef/renderer/v8_impl.cc",
|
"libcef/renderer/v8_impl.cc",
|
||||||
"libcef/renderer/v8_impl.h",
|
"libcef/renderer/v8_impl.h",
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
// by hand. See the translator.README.txt file in the tools directory for
|
// by hand. See the translator.README.txt file in the tools directory for
|
||||||
// more information.
|
// more information.
|
||||||
//
|
//
|
||||||
// $hash=17e60bfb954ddf6c40b90b9a117d90a0fe3f08d6$
|
// $hash=d56cbf83d6faefa9f716c7308bf7007dad98697d$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||||
@ -61,6 +61,25 @@ typedef struct _cef_browser_process_handler_t {
|
|||||||
///
|
///
|
||||||
cef_base_ref_counted_t base;
|
cef_base_ref_counted_t base;
|
||||||
|
|
||||||
|
///
|
||||||
|
// Called on the browser process UI thread to retrieve the list of schemes
|
||||||
|
// that should support cookies. If |include_defaults| is true (1) the default
|
||||||
|
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
||||||
|
// an NULL |schemes| value and setting |include_defaults| to false (0) will
|
||||||
|
// disable all loading and saving of cookies.
|
||||||
|
//
|
||||||
|
// This state will apply to the cef_cookie_manager_t associated with the
|
||||||
|
// global cef_request_context_t. It will also be used as the initial state for
|
||||||
|
// any new cef_request_context_ts created by the client. After creating a new
|
||||||
|
// cef_request_context_t the cef_cookie_manager_t::SetSupportedSchemes
|
||||||
|
// function may be called on the associated cef_cookie_manager_t to futher
|
||||||
|
// override these values.
|
||||||
|
///
|
||||||
|
void(CEF_CALLBACK* get_cookieable_schemes)(
|
||||||
|
struct _cef_browser_process_handler_t* self,
|
||||||
|
cef_string_list_t schemes,
|
||||||
|
int* include_defaults);
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
// Called on the browser process UI thread immediately after the CEF context
|
||||||
// has been initialized.
|
// has been initialized.
|
||||||
|
@ -42,13 +42,13 @@
|
|||||||
// way that may cause binary incompatibility with other builds. The universal
|
// way that may cause binary incompatibility with other builds. The universal
|
||||||
// hash value will change if any platform is affected whereas the platform hash
|
// hash value will change if any platform is affected whereas the platform hash
|
||||||
// values will change only if that particular platform is affected.
|
// values will change only if that particular platform is affected.
|
||||||
#define CEF_API_HASH_UNIVERSAL "c148b1a4fd1d29c2e14b1ab8ce1c04f29013de73"
|
#define CEF_API_HASH_UNIVERSAL "988c60ace9a075ec0d6d5439f8a845296549f666"
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#define CEF_API_HASH_PLATFORM "1f380ef6bde94cd7331d090b7aee0a08f2515541"
|
#define CEF_API_HASH_PLATFORM "9928400d4500073e22954f2793c9ab78749b7b67"
|
||||||
#elif defined(OS_MAC)
|
#elif defined(OS_MAC)
|
||||||
#define CEF_API_HASH_PLATFORM "c42f0866e58d3f96183e1f8931a4d01a7900b0b4"
|
#define CEF_API_HASH_PLATFORM "1c49b8f3d13ac6dd5b04d827f283ede33c7aba7b"
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
#define CEF_API_HASH_PLATFORM "92824ced77603246263f1f2ecf95ff4fad73885d"
|
#define CEF_API_HASH_PLATFORM "7634bb7366cf7be31efdbf7c86815ad47b412317"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -51,6 +51,23 @@
|
|||||||
/*--cef(source=client,no_debugct_check)--*/
|
/*--cef(source=client,no_debugct_check)--*/
|
||||||
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||||
public:
|
public:
|
||||||
|
///
|
||||||
|
// Called on the browser process UI thread to retrieve the list of schemes
|
||||||
|
// that should support cookies. If |include_defaults| is true the default
|
||||||
|
// schemes ("http", "https", "ws" and "wss") will also be supported. Providing
|
||||||
|
// an empty |schemes| value and setting |include_defaults| to false will
|
||||||
|
// disable all loading and saving of cookies.
|
||||||
|
//
|
||||||
|
// This state will apply to the CefCookieManager associated with the global
|
||||||
|
// CefRequestContext. It will also be used as the initial state for any new
|
||||||
|
// CefRequestContexts created by the client. After creating a new
|
||||||
|
// CefRequestContext the CefCookieManager::SetSupportedSchemes method may be
|
||||||
|
// called on the associated CefCookieManager to futher override these values.
|
||||||
|
///
|
||||||
|
/*--cef()--*/
|
||||||
|
virtual void GetCookieableSchemes(std::vector<CefString>& schemes,
|
||||||
|
bool& include_defaults) {}
|
||||||
|
|
||||||
///
|
///
|
||||||
// Called on the browser process UI thread immediately after the CEF context
|
// Called on the browser process UI thread immediately after the CEF context
|
||||||
// has been initialized.
|
// has been initialized.
|
||||||
|
@ -103,9 +103,6 @@ class AlloyBrowserContext : public ChromeProfileAlloy,
|
|||||||
bool ShouldPersistSessionCookies() const override {
|
bool ShouldPersistSessionCookies() const override {
|
||||||
return !!settings_.persist_session_cookies;
|
return !!settings_.persist_session_cookies;
|
||||||
}
|
}
|
||||||
base::Optional<std::vector<std::string>> GetCookieableSchemes() override {
|
|
||||||
return cookieable_schemes();
|
|
||||||
}
|
|
||||||
|
|
||||||
// visitedlink::VisitedLinkDelegate methods.
|
// visitedlink::VisitedLinkDelegate methods.
|
||||||
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
void RebuildTable(const scoped_refptr<URLEnumerator>& enumerator) override;
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "libcef/browser/browser_info.h"
|
#include "libcef/browser/browser_info.h"
|
||||||
#include "libcef/browser/browser_info_manager.h"
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
#include "libcef/browser/browser_platform_delegate.h"
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
#include "libcef/browser/browser_util.h"
|
|
||||||
#include "libcef/browser/context.h"
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/devtools/devtools_manager.h"
|
#include "libcef/browser/devtools/devtools_manager.h"
|
||||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||||
@ -42,15 +41,13 @@
|
|||||||
#include "content/public/browser/native_web_keyboard_event.h"
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "content/public/browser/navigation_controller.h"
|
#include "content/public/browser/navigation_controller.h"
|
||||||
#include "content/public/browser/navigation_handle.h"
|
#include "content/public/browser/navigation_handle.h"
|
||||||
#include "content/public/browser/notification_details.h"
|
|
||||||
#include "content/public/browser/notification_source.h"
|
|
||||||
#include "content/public/browser/notification_types.h"
|
|
||||||
#include "content/public/browser/render_frame_host.h"
|
#include "content/public/browser/render_frame_host.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
#include "content/public/browser/render_widget_host.h"
|
#include "content/public/browser/render_widget_host.h"
|
||||||
#include "content/public/browser/render_widget_host_observer.h"
|
#include "content/public/browser/render_widget_host_observer.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
#include "extensions/common/constants.h"
|
||||||
#include "extensions/common/extension.h"
|
#include "extensions/common/extension.h"
|
||||||
#include "net/base/net_errors.h"
|
#include "net/base/net_errors.h"
|
||||||
#include "third_party/blink/public/mojom/page/widget.mojom-test-utils.h"
|
#include "third_party/blink/public/mojom/page/widget.mojom-test-utils.h"
|
||||||
@ -137,7 +134,7 @@ static constexpr base::TimeDelta kRecentlyAudibleTimeout =
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
||||||
CreateParams& create_params) {
|
CefBrowserCreateParams& create_params) {
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate =
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate =
|
||||||
CefBrowserPlatformDelegate::Create(create_params);
|
CefBrowserPlatformDelegate::Create(create_params);
|
||||||
CHECK(platform_delegate);
|
CHECK(platform_delegate);
|
||||||
@ -182,9 +179,11 @@ CefRefPtr<AlloyBrowserHostImpl> AlloyBrowserHostImpl::Create(
|
|||||||
create_params.extension, create_params.url,
|
create_params.extension, create_params.url,
|
||||||
create_params.extension_host_type);
|
create_params.extension_host_type);
|
||||||
} else if (!create_params.url.is_empty()) {
|
} else if (!create_params.url.is_empty()) {
|
||||||
browser->LoadMainFrameURL(create_params.url.spec(), content::Referrer(),
|
content::OpenURLParams params(create_params.url, content::Referrer(),
|
||||||
|
WindowOpenDisposition::CURRENT_TAB,
|
||||||
CefFrameHostImpl::kPageTransitionExplicit,
|
CefFrameHostImpl::kPageTransitionExplicit,
|
||||||
std::string());
|
/*is_renderer_initiated=*/false);
|
||||||
|
browser->LoadMainFrameURL(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
return browser.get();
|
return browser.get();
|
||||||
@ -733,67 +732,6 @@ void AlloyBrowserHostImpl::SendExternalBeginFrame() {
|
|||||||
platform_delegate_->SendExternalBeginFrame();
|
platform_delegate_->SendExternalBeginFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SendKeyEvent,
|
|
||||||
this, event));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platform_delegate_)
|
|
||||||
platform_delegate_->SendKeyEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
|
|
||||||
MouseButtonType type,
|
|
||||||
bool mouseUp,
|
|
||||||
int clickCount) {
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT,
|
|
||||||
base::BindOnce(&AlloyBrowserHostImpl::SendMouseClickEvent,
|
|
||||||
this, event, type, mouseUp, clickCount));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platform_delegate_) {
|
|
||||||
platform_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
|
|
||||||
bool mouseLeave) {
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(
|
|
||||||
CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::SendMouseMoveEvent, this,
|
|
||||||
event, mouseLeave));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platform_delegate_) {
|
|
||||||
platform_delegate_->SendMouseMoveEvent(event, mouseLeave);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
|
|
||||||
int deltaX,
|
|
||||||
int deltaY) {
|
|
||||||
if (deltaX == 0 && deltaY == 0) {
|
|
||||||
// Nothing to do.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT,
|
|
||||||
base::BindOnce(&AlloyBrowserHostImpl::SendMouseWheelEvent,
|
|
||||||
this, event, deltaX, deltaY));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (platform_delegate_) {
|
|
||||||
platform_delegate_->SendMouseWheelEvent(event, deltaX, deltaY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
|
void AlloyBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
|
||||||
if (!IsWindowless()) {
|
if (!IsWindowless()) {
|
||||||
NOTREACHED() << "Window rendering is not disabled";
|
NOTREACHED() << "Window rendering is not disabled";
|
||||||
@ -864,90 +802,6 @@ void AlloyBrowserHostImpl::SetWindowlessFrameRate(int frame_rate) {
|
|||||||
platform_delegate_->SetWindowlessFrameRate(frame_rate);
|
platform_delegate_->SetWindowlessFrameRate(frame_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CefBrowser methods.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::GoBack() {
|
|
||||||
auto callback = base::BindOnce(&AlloyBrowserHostImpl::GoBack, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wc = web_contents();
|
|
||||||
if (wc && wc->GetController().CanGoBack()) {
|
|
||||||
wc->GetController().GoBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::GoForward() {
|
|
||||||
auto callback = base::BindOnce(&AlloyBrowserHostImpl::GoForward, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wc = web_contents();
|
|
||||||
if (wc && wc->GetController().CanGoForward()) {
|
|
||||||
wc->GetController().GoForward();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::Reload() {
|
|
||||||
auto callback = base::BindOnce(&AlloyBrowserHostImpl::Reload, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wc = web_contents();
|
|
||||||
if (wc) {
|
|
||||||
wc->GetController().Reload(content::ReloadType::NORMAL, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::ReloadIgnoreCache() {
|
|
||||||
auto callback =
|
|
||||||
base::BindOnce(&AlloyBrowserHostImpl::ReloadIgnoreCache, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wc = web_contents();
|
|
||||||
if (wc) {
|
|
||||||
wc->GetController().Reload(content::ReloadType::BYPASSING_CACHE, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::StopLoad() {
|
|
||||||
auto callback = base::BindOnce(&AlloyBrowserHostImpl::StopLoad, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto wc = web_contents();
|
|
||||||
if (wc) {
|
|
||||||
wc->Stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlloyBrowserHostImpl public methods.
|
// AlloyBrowserHostImpl public methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -1007,8 +861,6 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
|
|||||||
// Disassociate the platform delegate from this browser.
|
// Disassociate the platform delegate from this browser.
|
||||||
platform_delegate_->BrowserDestroyed(this);
|
platform_delegate_->BrowserDestroyed(this);
|
||||||
|
|
||||||
registrar_.reset(nullptr);
|
|
||||||
|
|
||||||
// Delete objects created by the platform delegate that may be referenced by
|
// Delete objects created by the platform delegate that may be referenced by
|
||||||
// the WebContents.
|
// the WebContents.
|
||||||
file_dialog_manager_.reset(nullptr);
|
file_dialog_manager_.reset(nullptr);
|
||||||
@ -1021,9 +873,6 @@ void AlloyBrowserHostImpl::DestroyBrowser() {
|
|||||||
|
|
||||||
devtools_manager_.reset(nullptr);
|
devtools_manager_.reset(nullptr);
|
||||||
|
|
||||||
// Delete the platform delegate.
|
|
||||||
platform_delegate_.reset(nullptr);
|
|
||||||
|
|
||||||
CefBrowserHostBase::DestroyBrowser();
|
CefBrowserHostBase::DestroyBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1049,15 +898,24 @@ void AlloyBrowserHostImpl::CancelContextMenu() {
|
|||||||
menu_manager_->CancelContextMenu();
|
menu_manager_->CancelContextMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::ViewText(const std::string& text) {
|
bool AlloyBrowserHostImpl::MaybeAllowNavigation(
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
content::RenderFrameHost* opener,
|
||||||
CEF_POST_TASK(CEF_UIT,
|
bool is_guest_view,
|
||||||
base::BindOnce(&AlloyBrowserHostImpl::ViewText, this, text));
|
const content::OpenURLParams& params) {
|
||||||
return;
|
if (is_guest_view && !params.url.SchemeIs(extensions::kExtensionScheme) &&
|
||||||
|
!params.url.SchemeIs(content::kChromeUIScheme)) {
|
||||||
|
// The PDF viewer will load the PDF extension in the guest view, and print
|
||||||
|
// preview will load chrome://print in the guest view. All other navigations
|
||||||
|
// are passed to the owner browser.
|
||||||
|
CEF_POST_TASK(
|
||||||
|
CEF_UIT,
|
||||||
|
base::Bind(base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
|
||||||
|
this, nullptr, params));
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (platform_delegate_)
|
return true;
|
||||||
platform_delegate_->ViewText(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SkColor AlloyBrowserHostImpl::GetBackgroundColor() const {
|
SkColor AlloyBrowserHostImpl::GetBackgroundColor() const {
|
||||||
@ -1073,29 +931,17 @@ extensions::ExtensionHost* AlloyBrowserHostImpl::GetExtensionHost() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
void AlloyBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||||
if (CEF_CURRENTLY_ON_UIT()) {
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
// SetFocus() might be called while inside the OnSetFocus() callback. If
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::OnSetFocus,
|
||||||
// so, don't re-enter the callback.
|
this, source));
|
||||||
if (!is_in_onsetfocus_) {
|
|
||||||
if (client_.get()) {
|
|
||||||
CefRefPtr<CefFocusHandler> handler = client_->GetFocusHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
is_in_onsetfocus_ = true;
|
|
||||||
bool handled = handler->OnSetFocus(this, source);
|
|
||||||
is_in_onsetfocus_ = false;
|
|
||||||
|
|
||||||
if (handled)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
if (contents_delegate_->OnSetFocus(source))
|
||||||
|
return;
|
||||||
|
|
||||||
if (platform_delegate_)
|
if (platform_delegate_)
|
||||||
platform_delegate_->SendFocusEvent(true);
|
platform_delegate_->SendFocusEvent(true);
|
||||||
} else {
|
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(&AlloyBrowserHostImpl::OnSetFocus,
|
|
||||||
this, source));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::RunFileChooser(
|
void AlloyBrowserHostImpl::RunFileChooser(
|
||||||
@ -1372,32 +1218,18 @@ bool AlloyBrowserHostImpl::IsAudioMuted() {
|
|||||||
// content::WebContentsDelegate methods.
|
// content::WebContentsDelegate methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// |source| may be NULL if the navigation originates from a guest view via
|
|
||||||
// AlloyContentBrowserClient::CanCreateWindow.
|
|
||||||
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
content::WebContents* AlloyBrowserHostImpl::OpenURLFromTab(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::OpenURLParams& params) {
|
const content::OpenURLParams& params) {
|
||||||
bool cancel = false;
|
auto target_contents = contents_delegate_->OpenURLFromTab(source, params);
|
||||||
|
if (target_contents) {
|
||||||
if (client_.get()) {
|
|
||||||
CefRefPtr<CefRequestHandler> handler = client_->GetRequestHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
cancel = handler->OnOpenURLFromTab(
|
|
||||||
this, GetFrame(params.frame_tree_node_id), params.url.spec(),
|
|
||||||
static_cast<cef_window_open_disposition_t>(params.disposition),
|
|
||||||
params.user_gesture);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cancel) {
|
|
||||||
// Start a navigation in the current browser that will result in the
|
// Start a navigation in the current browser that will result in the
|
||||||
// creation of a new render process.
|
// creation of a new render process.
|
||||||
LoadMainFrameURL(params.url.spec(), params.referrer, params.transition,
|
LoadMainFrameURL(params);
|
||||||
params.extra_headers);
|
return target_contents;
|
||||||
return source;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't know where the navigation, if any, will occur.
|
// Cancel the navigation.
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,26 +1342,7 @@ bool AlloyBrowserHostImpl::HandleContextMenu(
|
|||||||
KeyboardEventProcessingResult AlloyBrowserHostImpl::PreHandleKeyboardEvent(
|
KeyboardEventProcessingResult AlloyBrowserHostImpl::PreHandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
if (platform_delegate_ && client_.get()) {
|
return contents_delegate_->PreHandleKeyboardEvent(source, event);
|
||||||
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
CefKeyEvent cef_event;
|
|
||||||
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
|
||||||
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
|
||||||
|
|
||||||
CefEventHandle event_handle = platform_delegate_->GetEventHandle(event);
|
|
||||||
bool is_keyboard_shortcut = false;
|
|
||||||
bool result = handler->OnPreKeyEvent(this, cef_event, event_handle,
|
|
||||||
&is_keyboard_shortcut);
|
|
||||||
if (result)
|
|
||||||
return KeyboardEventProcessingResult::HANDLED;
|
|
||||||
else if (is_keyboard_shortcut)
|
|
||||||
return KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return KeyboardEventProcessingResult::NOT_HANDLED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
||||||
@ -1539,24 +1352,12 @@ bool AlloyBrowserHostImpl::HandleKeyboardEvent(
|
|||||||
if (event.skip_in_browser)
|
if (event.skip_in_browser)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!platform_delegate_)
|
if (contents_delegate_->HandleKeyboardEvent(source, event))
|
||||||
return false;
|
|
||||||
|
|
||||||
if (client_.get()) {
|
|
||||||
CefRefPtr<CefKeyboardHandler> handler = client_->GetKeyboardHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
CefKeyEvent cef_event;
|
|
||||||
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
|
||||||
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
|
||||||
|
|
||||||
CefEventHandle event_handle = platform_delegate_->GetEventHandle(event);
|
|
||||||
if (handler->OnKeyEvent(this, cef_event, event_handle))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (platform_delegate_)
|
||||||
return platform_delegate_->HandleKeyboardEvent(event);
|
return platform_delegate_->HandleKeyboardEvent(event);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlloyBrowserHostImpl::PreHandleGestureEvent(
|
bool AlloyBrowserHostImpl::PreHandleGestureEvent(
|
||||||
@ -1787,30 +1588,11 @@ void AlloyBrowserHostImpl::ExitPictureInPicture() {
|
|||||||
|
|
||||||
void AlloyBrowserHostImpl::RenderViewCreated(
|
void AlloyBrowserHostImpl::RenderViewCreated(
|
||||||
content::RenderViewHost* render_view_host) {
|
content::RenderViewHost* render_view_host) {
|
||||||
// May be already registered if the renderer crashed previously.
|
|
||||||
if (!registrar_->IsRegistered(
|
|
||||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
|
||||||
content::Source<content::RenderViewHost>(render_view_host))) {
|
|
||||||
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
|
||||||
content::Source<content::RenderViewHost>(render_view_host));
|
|
||||||
}
|
|
||||||
|
|
||||||
new CefWidgetHostInterceptor(this, render_view_host);
|
new CefWidgetHostInterceptor(this, render_view_host);
|
||||||
|
|
||||||
platform_delegate_->RenderViewCreated(render_view_host);
|
platform_delegate_->RenderViewCreated(render_view_host);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::RenderViewDeleted(
|
|
||||||
content::RenderViewHost* render_view_host) {
|
|
||||||
if (registrar_->IsRegistered(
|
|
||||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
|
||||||
content::Source<content::RenderViewHost>(render_view_host))) {
|
|
||||||
registrar_->Remove(
|
|
||||||
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
|
||||||
content::Source<content::RenderViewHost>(render_view_host));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::RenderViewReady() {
|
void AlloyBrowserHostImpl::RenderViewReady() {
|
||||||
platform_delegate_->RenderViewReady();
|
platform_delegate_->RenderViewReady();
|
||||||
}
|
}
|
||||||
@ -1895,25 +1677,6 @@ void AlloyBrowserHostImpl::StartAudioCapturer() {
|
|||||||
audio_capturer_.reset(new CefAudioCapturer(params, this, audio_handler));
|
audio_capturer_.reset(new CefAudioCapturer(params, this, audio_handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
// content::NotificationObserver methods.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void AlloyBrowserHostImpl::Observe(
|
|
||||||
int type,
|
|
||||||
const content::NotificationSource& source,
|
|
||||||
const content::NotificationDetails& details) {
|
|
||||||
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
|
|
||||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
|
|
||||||
|
|
||||||
if (type == content::NOTIFICATION_LOAD_STOP) {
|
|
||||||
content::NavigationController* controller =
|
|
||||||
content::Source<content::NavigationController>(source).ptr();
|
|
||||||
contents_delegate_->OnTitleChange(controller->GetWebContents()->GetTitle());
|
|
||||||
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
|
|
||||||
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// AlloyBrowserHostImpl private methods.
|
// AlloyBrowserHostImpl private methods.
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -1926,10 +1689,13 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
|||||||
CefRefPtr<CefRequestContextImpl> request_context,
|
CefRefPtr<CefRequestContextImpl> request_context,
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
CefRefPtr<CefExtension> extension)
|
CefRefPtr<CefExtension> extension)
|
||||||
: CefBrowserHostBase(settings, client, browser_info, request_context),
|
: CefBrowserHostBase(settings,
|
||||||
|
client,
|
||||||
|
std::move(platform_delegate),
|
||||||
|
browser_info,
|
||||||
|
request_context),
|
||||||
content::WebContentsObserver(web_contents),
|
content::WebContentsObserver(web_contents),
|
||||||
opener_(kNullWindowHandle),
|
opener_(kNullWindowHandle),
|
||||||
platform_delegate_(std::move(platform_delegate)),
|
|
||||||
is_windowless_(platform_delegate_->IsWindowless()),
|
is_windowless_(platform_delegate_->IsWindowless()),
|
||||||
is_views_hosted_(platform_delegate_->IsViewsHosted()),
|
is_views_hosted_(platform_delegate_->IsViewsHosted()),
|
||||||
extension_(extension) {
|
extension_(extension) {
|
||||||
@ -1941,17 +1707,6 @@ AlloyBrowserHostImpl::AlloyBrowserHostImpl(
|
|||||||
opener_ = opener->GetWindowHandle();
|
opener_ = opener->GetWindowHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
registrar_.reset(new content::NotificationRegistrar);
|
|
||||||
|
|
||||||
// When navigating through the history, the restored NavigationEntry's title
|
|
||||||
// will be used. If the entry ends up having the same title after we return
|
|
||||||
// to it, as will usually be the case, the
|
|
||||||
// NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since
|
|
||||||
// the NavigationEntry's title hasn't changed.
|
|
||||||
registrar_->Add(this, content::NOTIFICATION_LOAD_STOP,
|
|
||||||
content::Source<content::NavigationController>(
|
|
||||||
&web_contents->GetController()));
|
|
||||||
|
|
||||||
// Associate the platform delegate with this browser.
|
// Associate the platform delegate with this browser.
|
||||||
platform_delegate_->BrowserCreated(this);
|
platform_delegate_->BrowserCreated(this);
|
||||||
|
|
||||||
|
@ -24,36 +24,13 @@
|
|||||||
|
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
#include "base/synchronization/lock.h"
|
#include "base/synchronization/lock.h"
|
||||||
#include "content/public/browser/notification_observer.h"
|
|
||||||
#include "content/public/browser/notification_registrar.h"
|
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
#include "extensions/common/view_type.h"
|
#include "extensions/common/view_type.h"
|
||||||
|
|
||||||
namespace content {
|
|
||||||
struct DragEventSourceInfo;
|
|
||||||
class RenderWidgetHostImpl;
|
|
||||||
} // namespace content
|
|
||||||
|
|
||||||
namespace extensions {
|
|
||||||
class Extension;
|
|
||||||
class ExtensionHost;
|
|
||||||
} // namespace extensions
|
|
||||||
|
|
||||||
namespace gfx {
|
|
||||||
class ImageSkia;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
namespace views {
|
|
||||||
class Widget;
|
|
||||||
}
|
|
||||||
#endif // defined(USE_AURA)
|
|
||||||
|
|
||||||
class CefAudioCapturer;
|
class CefAudioCapturer;
|
||||||
class CefBrowserInfo;
|
class CefBrowserInfo;
|
||||||
class CefBrowserPlatformDelegate;
|
|
||||||
class CefDevToolsManager;
|
class CefDevToolsManager;
|
||||||
class SiteInstance;
|
class SiteInstance;
|
||||||
|
|
||||||
@ -72,12 +49,9 @@ class SiteInstance;
|
|||||||
// messages sent using AlloyBrowserHostImpl::Send() will be forwarded to the
|
// messages sent using AlloyBrowserHostImpl::Send() will be forwarded to the
|
||||||
// RenderViewHost (after posting to the UI thread if necessary). Use
|
// RenderViewHost (after posting to the UI thread if necessary). Use
|
||||||
// WebContentsObserver::routing_id() when sending IPC messages.
|
// WebContentsObserver::routing_id() when sending IPC messages.
|
||||||
//
|
|
||||||
// NotificationObserver: Interface for observing post-processed notifications.
|
|
||||||
class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
||||||
public content::WebContentsDelegate,
|
public content::WebContentsDelegate,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver {
|
||||||
public content::NotificationObserver {
|
|
||||||
public:
|
public:
|
||||||
// Used for handling the response to command messages.
|
// Used for handling the response to command messages.
|
||||||
class CommandResponseHandler : public virtual CefBaseRefCounted {
|
class CommandResponseHandler : public virtual CefBaseRefCounted {
|
||||||
@ -88,7 +62,8 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
~AlloyBrowserHostImpl() override;
|
~AlloyBrowserHostImpl() override;
|
||||||
|
|
||||||
// Create a new AlloyBrowserHostImpl instance with owned WebContents.
|
// Create a new AlloyBrowserHostImpl instance with owned WebContents.
|
||||||
static CefRefPtr<AlloyBrowserHostImpl> Create(CreateParams& create_params);
|
static CefRefPtr<AlloyBrowserHostImpl> Create(
|
||||||
|
CefBrowserCreateParams& create_params);
|
||||||
|
|
||||||
// Returns the browser associated with the specified RenderViewHost.
|
// Returns the browser associated with the specified RenderViewHost.
|
||||||
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
|
static CefRefPtr<AlloyBrowserHostImpl> GetBrowserForHost(
|
||||||
@ -152,15 +127,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
void NotifyScreenInfoChanged() override;
|
void NotifyScreenInfoChanged() override;
|
||||||
void Invalidate(PaintElementType type) override;
|
void Invalidate(PaintElementType type) override;
|
||||||
void SendExternalBeginFrame() override;
|
void SendExternalBeginFrame() override;
|
||||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
|
||||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
|
||||||
MouseButtonType type,
|
|
||||||
bool mouseUp,
|
|
||||||
int clickCount) override;
|
|
||||||
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
|
||||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
|
||||||
int deltaX,
|
|
||||||
int deltaY) override;
|
|
||||||
void SendTouchEvent(const CefTouchEvent& event) override;
|
void SendTouchEvent(const CefTouchEvent& event) override;
|
||||||
void SendFocusEvent(bool setFocus) override;
|
void SendFocusEvent(bool setFocus) override;
|
||||||
void SendCaptureLostEvent() override;
|
void SendCaptureLostEvent() override;
|
||||||
@ -194,13 +160,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
CefRefPtr<CefExtension> GetExtension() override;
|
CefRefPtr<CefExtension> GetExtension() override;
|
||||||
bool IsBackgroundHost() override;
|
bool IsBackgroundHost() override;
|
||||||
|
|
||||||
// CefBrowser methods.
|
|
||||||
void GoBack() override;
|
|
||||||
void GoForward() override;
|
|
||||||
void Reload() override;
|
|
||||||
void ReloadIgnoreCache() override;
|
|
||||||
void StopLoad() override;
|
|
||||||
|
|
||||||
// Returns true if windowless rendering is enabled.
|
// Returns true if windowless rendering is enabled.
|
||||||
bool IsWindowless() const;
|
bool IsWindowless() const;
|
||||||
|
|
||||||
@ -230,8 +189,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
CefRefPtr<CefBrowserView> GetBrowserView() const;
|
CefRefPtr<CefBrowserView> GetBrowserView() const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Open the specified text in the default text editor.
|
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||||
void ViewText(const std::string& text) override;
|
bool is_guest_view,
|
||||||
|
const content::OpenURLParams& params) override;
|
||||||
|
|
||||||
// Convert from view coordinates to screen coordinates. Potential display
|
// Convert from view coordinates to screen coordinates. Potential display
|
||||||
// scaling will be applied to the result.
|
// scaling will be applied to the result.
|
||||||
@ -364,7 +324,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
// content::WebContentsObserver methods.
|
// content::WebContentsObserver methods.
|
||||||
using content::WebContentsObserver::BeforeUnloadFired;
|
using content::WebContentsObserver::BeforeUnloadFired;
|
||||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
|
|
||||||
void RenderViewReady() override;
|
void RenderViewReady() override;
|
||||||
void DidFinishNavigation(
|
void DidFinishNavigation(
|
||||||
content::NavigationHandle* navigation_handle) override;
|
content::NavigationHandle* navigation_handle) override;
|
||||||
@ -391,11 +350,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
CefRefPtr<CefExtension> extension);
|
CefRefPtr<CefExtension> extension);
|
||||||
|
|
||||||
// content::NotificationObserver methods.
|
|
||||||
void Observe(int type,
|
|
||||||
const content::NotificationSource& source,
|
|
||||||
const content::NotificationDetails& details) override;
|
|
||||||
|
|
||||||
AlloyBrowserHostImpl(
|
AlloyBrowserHostImpl(
|
||||||
const CefBrowserSettings& settings,
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
@ -420,7 +374,6 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
CefRefPtr<CefRegistration> registration);
|
CefRefPtr<CefRegistration> registration);
|
||||||
|
|
||||||
CefWindowHandle opener_;
|
CefWindowHandle opener_;
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
|
|
||||||
const bool is_windowless_;
|
const bool is_windowless_;
|
||||||
const bool is_views_hosted_;
|
const bool is_views_hosted_;
|
||||||
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
CefWindowHandle host_window_handle_ = kNullWindowHandle;
|
||||||
@ -435,20 +388,9 @@ class AlloyBrowserHostImpl : public CefBrowserHostBase,
|
|||||||
// on the UI thread.
|
// on the UI thread.
|
||||||
bool window_destroyed_ = false;
|
bool window_destroyed_ = false;
|
||||||
|
|
||||||
// True if currently in the OnSetFocus callback. Only accessed on the UI
|
|
||||||
// thread.
|
|
||||||
bool is_in_onsetfocus_ = false;
|
|
||||||
|
|
||||||
// True if the focus is currently on an editable field on the page. Only
|
|
||||||
// accessed on the UI thread.
|
|
||||||
bool focus_on_editable_field_ = false;
|
|
||||||
|
|
||||||
// True if mouse cursor change is disabled.
|
// True if mouse cursor change is disabled.
|
||||||
bool mouse_cursor_change_disabled_ = false;
|
bool mouse_cursor_change_disabled_ = false;
|
||||||
|
|
||||||
// Used for managing notification subscriptions.
|
|
||||||
std::unique_ptr<content::NotificationRegistrar> registrar_;
|
|
||||||
|
|
||||||
// Used for creating and managing file dialogs.
|
// Used for creating and managing file dialogs.
|
||||||
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
|
std::unique_ptr<CefFileDialogManager> file_dialog_manager_;
|
||||||
|
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||||
#include "libcef/browser/net/chrome_scheme_handler.h"
|
#include "libcef/browser/net/chrome_scheme_handler.h"
|
||||||
|
#include "libcef/browser/net/throttle_handler.h"
|
||||||
|
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||||
#include "libcef/browser/net_service/login_delegate.h"
|
#include "libcef/browser/net_service/login_delegate.h"
|
||||||
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
||||||
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||||
@ -71,8 +73,6 @@
|
|||||||
#include "chrome/grit/generated_resources.h"
|
#include "chrome/grit/generated_resources.h"
|
||||||
#include "chrome/services/printing/printing_service.h"
|
#include "chrome/services/printing/printing_service.h"
|
||||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||||
#include "components/navigation_interception/intercept_navigation_throttle.h"
|
|
||||||
#include "components/navigation_interception/navigation_params.h"
|
|
||||||
#include "components/spellcheck/common/spellcheck.mojom.h"
|
#include "components/spellcheck/common/spellcheck.mojom.h"
|
||||||
#include "components/version_info/version_info.h"
|
#include "components/version_info/version_info.h"
|
||||||
#include "content/browser/frame_host/render_frame_host_impl.h"
|
#include "content/browser/frame_host/render_frame_host_impl.h"
|
||||||
@ -440,72 +440,6 @@ int GetCrashSignalFD(const base::CommandLine& command_line) {
|
|||||||
}
|
}
|
||||||
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
#endif // defined(OS_POSIX) && !defined(OS_MAC)
|
||||||
|
|
||||||
// TODO(cef): We can't currently trust NavigationParams::is_main_frame() because
|
|
||||||
// it's always set to true in
|
|
||||||
// InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation. Remove the
|
|
||||||
// |is_main_frame| argument once this problem is fixed.
|
|
||||||
bool NavigationOnUIThread(
|
|
||||||
bool is_main_frame,
|
|
||||||
int64_t frame_id,
|
|
||||||
int64_t parent_frame_id,
|
|
||||||
int frame_tree_node_id,
|
|
||||||
content::WebContents* source,
|
|
||||||
const navigation_interception::NavigationParams& params) {
|
|
||||||
CEF_REQUIRE_UIT();
|
|
||||||
|
|
||||||
content::OpenURLParams open_params(
|
|
||||||
params.url(), params.referrer(), WindowOpenDisposition::CURRENT_TAB,
|
|
||||||
params.transition_type(), params.is_renderer_initiated());
|
|
||||||
open_params.user_gesture = params.has_user_gesture();
|
|
||||||
open_params.initiator_origin = params.initiator_origin();
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser;
|
|
||||||
if (!CefBrowserInfoManager::GetInstance()->MaybeAllowNavigation(
|
|
||||||
source->GetMainFrame(), open_params, browser)) {
|
|
||||||
// Cancel the navigation.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ignore_navigation = false;
|
|
||||||
|
|
||||||
if (browser.get()) {
|
|
||||||
CefRefPtr<CefClient> client = browser->GetClient();
|
|
||||||
if (client.get()) {
|
|
||||||
CefRefPtr<CefRequestHandler> handler = client->GetRequestHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
CefRefPtr<CefFrame> frame;
|
|
||||||
if (is_main_frame) {
|
|
||||||
frame = browser->GetMainFrame();
|
|
||||||
} else if (frame_id >= 0) {
|
|
||||||
frame = browser->GetFrame(frame_id);
|
|
||||||
}
|
|
||||||
if (!frame && frame_tree_node_id >= 0) {
|
|
||||||
frame = browser->GetFrameForFrameTreeNode(frame_tree_node_id);
|
|
||||||
}
|
|
||||||
if (!frame) {
|
|
||||||
// Create a temporary frame object for navigation of sub-frames that
|
|
||||||
// don't yet exist.
|
|
||||||
frame = browser->browser_info()->CreateTempSubFrame(parent_frame_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
|
||||||
request->Set(params, is_main_frame);
|
|
||||||
request->SetReadOnly(true);
|
|
||||||
|
|
||||||
// Initiating a new navigation in OnBeforeBrowse will delete the
|
|
||||||
// InterceptNavigationThrottle that currently owns this callback,
|
|
||||||
// resulting in a crash. Use the lock to prevent that.
|
|
||||||
auto navigation_lock = browser->browser_info()->CreateNavigationLock();
|
|
||||||
ignore_navigation = handler->OnBeforeBrowse(
|
|
||||||
browser.get(), frame, request.get(), params.has_user_gesture(),
|
|
||||||
params.is_redirect());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ignore_navigation;
|
|
||||||
}
|
|
||||||
|
|
||||||
// From chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc.
|
// From chrome/browser/plugins/chrome_content_browser_client_plugins_part.cc.
|
||||||
void BindPluginInfoHost(
|
void BindPluginInfoHost(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
@ -1074,33 +1008,8 @@ AlloyContentBrowserClient::GetDevToolsManagerDelegate() {
|
|||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||||
AlloyContentBrowserClient::CreateThrottlesForNavigation(
|
AlloyContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
content::NavigationHandle* navigation_handle) {
|
content::NavigationHandle* navigation_handle) {
|
||||||
CEF_REQUIRE_UIT();
|
throttle::NavigationThrottleList throttles;
|
||||||
|
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>> throttles;
|
|
||||||
|
|
||||||
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
|
||||||
|
|
||||||
// Identify the RenderFrameHost that originated the navigation.
|
|
||||||
const int64_t parent_frame_id =
|
|
||||||
!is_main_frame
|
|
||||||
? CefFrameHostImpl::MakeFrameId(navigation_handle->GetParentFrame())
|
|
||||||
: CefFrameHostImpl::kInvalidFrameId;
|
|
||||||
|
|
||||||
const int64_t frame_id = !is_main_frame && navigation_handle->HasCommitted()
|
|
||||||
? CefFrameHostImpl::MakeFrameId(
|
|
||||||
navigation_handle->GetRenderFrameHost())
|
|
||||||
: CefFrameHostImpl::kInvalidFrameId;
|
|
||||||
|
|
||||||
// Must use SynchronyMode::kSync to ensure that OnBeforeBrowse is always
|
|
||||||
// called before OnBeforeResourceLoad.
|
|
||||||
std::unique_ptr<content::NavigationThrottle> throttle =
|
|
||||||
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
|
|
||||||
navigation_handle,
|
|
||||||
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id,
|
|
||||||
parent_frame_id, navigation_handle->GetFrameTreeNodeId()),
|
|
||||||
navigation_interception::SynchronyMode::kSync);
|
|
||||||
throttles.push_back(std::move(throttle));
|
|
||||||
|
|
||||||
return throttles;
|
return throttles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1306,10 +1215,16 @@ void AlloyContentBrowserClient::ConfigureNetworkContextParams(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Profile* profile = Profile::FromBrowserContext(context);
|
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
||||||
|
|
||||||
|
Profile* profile = cef_context->AsProfile();
|
||||||
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path,
|
profile->ConfigureNetworkContextParams(in_memory, relative_partition_path,
|
||||||
network_context_params,
|
network_context_params,
|
||||||
cert_verifier_creation_params);
|
cert_verifier_creation_params);
|
||||||
|
|
||||||
|
network_context_params->cookieable_schemes =
|
||||||
|
cef_context->GetCookieableSchemes();
|
||||||
|
|
||||||
// TODO(cef): Remove this and add required NetworkIsolationKeys,
|
// TODO(cef): Remove this and add required NetworkIsolationKeys,
|
||||||
// this is currently not the case and this was not required pre M84.
|
// this is currently not the case and this was not required pre M84.
|
||||||
network_context_params->require_network_isolation_key = false;
|
network_context_params->require_network_isolation_key = false;
|
||||||
@ -1336,7 +1251,7 @@ AlloyContentBrowserClient::GetNetworkContextsParentDirectory() {
|
|||||||
|
|
||||||
bool AlloyContentBrowserClient::HandleExternalProtocol(
|
bool AlloyContentBrowserClient::HandleExternalProtocol(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
base::OnceCallback<content::WebContents*()> web_contents_getter,
|
content::WebContents::OnceGetter web_contents_getter,
|
||||||
int child_id,
|
int child_id,
|
||||||
content::NavigationUIData* navigation_data,
|
content::NavigationUIData* navigation_data,
|
||||||
bool is_main_frame,
|
bool is_main_frame,
|
||||||
@ -1356,32 +1271,16 @@ bool AlloyContentBrowserClient::HandleExternalProtocol(
|
|||||||
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
||||||
out_factory->InitWithNewPipeAndPassReceiver();
|
out_factory->InitWithNewPipeAndPassReceiver();
|
||||||
|
|
||||||
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
|
// CefBrowserPlatformDelegate::HandleExternalProtocol may be called if
|
||||||
// nothing handles the request.
|
// nothing handles the request.
|
||||||
if (CEF_CURRENTLY_ON_IOT()) {
|
|
||||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||||
web_contents_getter, frame_tree_node_id, resource_request);
|
web_contents_getter, frame_tree_node_id, resource_request,
|
||||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
base::Bind(CefBrowserPlatformDelegate::HandleExternalProtocol,
|
||||||
web_contents_getter, std::move(receiver), std::move(request_handler));
|
resource_request.url));
|
||||||
} else {
|
|
||||||
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
|
||||||
web_contents_getter, frame_tree_node_id, resource_request);
|
|
||||||
CEF_POST_TASK(
|
|
||||||
CEF_IOT,
|
|
||||||
base::BindOnce(
|
|
||||||
[](mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver,
|
|
||||||
std::unique_ptr<net_service::InterceptedRequestHandler>
|
|
||||||
request_handler,
|
|
||||||
content::WebContents::Getter web_contents_getter) {
|
|
||||||
// Manages its own lifetime.
|
|
||||||
|
|
||||||
net_service::ProxyURLLoaderFactory::CreateProxy(
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||||
web_contents_getter, std::move(receiver),
|
web_contents_getter, std::move(receiver), std::move(request_handler));
|
||||||
std::move(request_handler));
|
|
||||||
},
|
|
||||||
std::move(receiver), std::move(request_handler),
|
|
||||||
std::move(web_contents_getter)));
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ class AlloyContentBrowserClient : public content::ContentBrowserClient {
|
|||||||
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
std::vector<base::FilePath> GetNetworkContextsParentDirectory() override;
|
||||||
bool HandleExternalProtocol(
|
bool HandleExternalProtocol(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
base::OnceCallback<content::WebContents*()> web_contents_getter,
|
content::WebContents::OnceGetter web_contents_getter,
|
||||||
int child_id,
|
int child_id,
|
||||||
content::NavigationUIData* navigation_data,
|
content::NavigationUIData* navigation_data,
|
||||||
bool is_main_frame,
|
bool is_main_frame,
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||||
#include "libcef/browser/printing/print_view_manager.h"
|
#include "libcef/browser/printing/print_view_manager.h"
|
||||||
#include "libcef/common/extensions/extensions_util.h"
|
#include "libcef/common/extensions/extensions_util.h"
|
||||||
|
#include "libcef/features/runtime_checks.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "chrome/browser/printing/print_view_manager.h"
|
#include "chrome/browser/printing/print_view_manager.h"
|
||||||
@ -28,8 +29,11 @@ CefBrowserPlatformDelegateAlloy::CefBrowserPlatformDelegateAlloy()
|
|||||||
: weak_ptr_factory_(this) {}
|
: weak_ptr_factory_(this) {}
|
||||||
|
|
||||||
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
|
content::WebContents* CefBrowserPlatformDelegateAlloy::CreateWebContents(
|
||||||
CefBrowserHostBase::CreateParams& create_params,
|
CefBrowserCreateParams& create_params,
|
||||||
bool& own_web_contents) {
|
bool& own_web_contents) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
DCHECK(primary_);
|
||||||
|
|
||||||
// Get or create the request context and browser context.
|
// Get or create the request context and browser context.
|
||||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||||
@ -105,6 +109,9 @@ void CefBrowserPlatformDelegateAlloy::AddNewContents(
|
|||||||
const gfx::Rect& initial_rect,
|
const gfx::Rect& initial_rect,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool* was_blocked) {
|
bool* was_blocked) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
DCHECK(primary_);
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> owner =
|
CefRefPtr<AlloyBrowserHostImpl> owner =
|
||||||
AlloyBrowserHostImpl::GetBrowserForContents(new_contents.get());
|
AlloyBrowserHostImpl::GetBrowserForContents(new_contents.get());
|
||||||
if (owner) {
|
if (owner) {
|
||||||
@ -143,10 +150,15 @@ void CefBrowserPlatformDelegateAlloy::RenderViewReady() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
void CefBrowserPlatformDelegateAlloy::BrowserCreated(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegate::BrowserCreated(browser);
|
CefBrowserPlatformDelegate::BrowserCreated(browser);
|
||||||
|
|
||||||
web_contents_->SetDelegate(browser);
|
// Only register WebContents delegate/observers if we're the primary delegate.
|
||||||
|
if (!primary_)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DCHECK(!web_contents_->GetDelegate());
|
||||||
|
web_contents_->SetDelegate(static_cast<AlloyBrowserHostImpl*>(browser));
|
||||||
|
|
||||||
PrefsTabHelper::CreateForWebContents(web_contents_);
|
PrefsTabHelper::CreateForWebContents(web_contents_);
|
||||||
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
|
printing::CefPrintViewManager::CreateForWebContents(web_contents_);
|
||||||
@ -169,24 +181,29 @@ void CefBrowserPlatformDelegateAlloy::CreateExtensionHost(
|
|||||||
const extensions::Extension* extension,
|
const extensions::Extension* extension,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
extensions::ViewType host_type) {
|
extensions::ViewType host_type) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
DCHECK(primary_);
|
||||||
|
|
||||||
// Should get WebContentsCreated and BrowserCreated calls first.
|
// Should get WebContentsCreated and BrowserCreated calls first.
|
||||||
DCHECK(web_contents_);
|
DCHECK(web_contents_);
|
||||||
DCHECK(browser_);
|
DCHECK(browser_);
|
||||||
DCHECK(!extension_host_);
|
DCHECK(!extension_host_);
|
||||||
|
|
||||||
|
auto alloy_browser = static_cast<AlloyBrowserHostImpl*>(browser_);
|
||||||
|
|
||||||
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
|
if (host_type == extensions::VIEW_TYPE_EXTENSION_DIALOG ||
|
||||||
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
|
host_type == extensions::VIEW_TYPE_EXTENSION_POPUP) {
|
||||||
// Create an extension host that we own.
|
// Create an extension host that we own.
|
||||||
extension_host_ = new extensions::CefExtensionViewHost(
|
extension_host_ = new extensions::CefExtensionViewHost(
|
||||||
browser_, extension, web_contents_, url, host_type);
|
alloy_browser, extension, web_contents_, url, host_type);
|
||||||
// Trigger load of the extension URL.
|
// Trigger load of the extension URL.
|
||||||
extension_host_->CreateRenderViewSoon();
|
extension_host_->CreateRenderViewSoon();
|
||||||
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
|
} else if (host_type == extensions::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE) {
|
||||||
is_background_host_ = true;
|
is_background_host_ = true;
|
||||||
browser_->is_background_host_ = true;
|
alloy_browser->is_background_host_ = true;
|
||||||
// Create an extension host that will be owned by ProcessManager.
|
// Create an extension host that will be owned by ProcessManager.
|
||||||
extension_host_ = new extensions::CefExtensionBackgroundHost(
|
extension_host_ = new extensions::CefExtensionBackgroundHost(
|
||||||
browser_,
|
alloy_browser,
|
||||||
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
|
base::BindOnce(&CefBrowserPlatformDelegateAlloy::OnExtensionHostDeleted,
|
||||||
weak_ptr_factory_.GetWeakPtr()),
|
weak_ptr_factory_.GetWeakPtr()),
|
||||||
extension, web_contents_, url, host_type);
|
extension, web_contents_, url, host_type);
|
||||||
@ -202,9 +219,11 @@ extensions::ExtensionHost* CefBrowserPlatformDelegateAlloy::GetExtensionHost()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
|
void CefBrowserPlatformDelegateAlloy::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
|
if (primary_) {
|
||||||
DestroyExtensionHost();
|
DestroyExtensionHost();
|
||||||
owned_web_contents_.reset();
|
owned_web_contents_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
|
||||||
}
|
}
|
||||||
@ -303,6 +322,8 @@ void CefBrowserPlatformDelegateAlloy::SetAccessibilityState(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
|
||||||
auto actionable_contents = GetActionableWebContents();
|
auto actionable_contents = GetActionableWebContents();
|
||||||
if (!actionable_contents)
|
if (!actionable_contents)
|
||||||
return false;
|
return false;
|
||||||
@ -318,6 +339,8 @@ bool CefBrowserPlatformDelegateAlloy::IsPrintPreviewSupported() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::Print() {
|
void CefBrowserPlatformDelegateAlloy::Print() {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
|
||||||
auto actionable_contents = GetActionableWebContents();
|
auto actionable_contents = GetActionableWebContents();
|
||||||
if (!actionable_contents)
|
if (!actionable_contents)
|
||||||
return;
|
return;
|
||||||
@ -337,6 +360,8 @@ void CefBrowserPlatformDelegateAlloy::PrintToPDF(
|
|||||||
const CefString& path,
|
const CefString& path,
|
||||||
const CefPdfPrintSettings& settings,
|
const CefPdfPrintSettings& settings,
|
||||||
CefRefPtr<CefPdfPrintCallback> callback) {
|
CefRefPtr<CefPdfPrintCallback> callback) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
|
||||||
content::WebContents* actionable_contents = GetActionableWebContents();
|
content::WebContents* actionable_contents = GetActionableWebContents();
|
||||||
if (!actionable_contents)
|
if (!actionable_contents)
|
||||||
return;
|
return;
|
||||||
@ -405,6 +430,8 @@ CefBrowserPlatformDelegateAlloy::GetActionableWebContents() const {
|
|||||||
|
|
||||||
void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
|
void CefBrowserPlatformDelegateAlloy::SetOwnedWebContents(
|
||||||
content::WebContents* owned_contents) {
|
content::WebContents* owned_contents) {
|
||||||
|
DCHECK(primary_);
|
||||||
|
|
||||||
// Should not currently own a WebContents.
|
// Should not currently own a WebContents.
|
||||||
CHECK(!owned_web_contents_);
|
CHECK(!owned_web_contents_);
|
||||||
owned_web_contents_.reset(owned_contents);
|
owned_web_contents_.reset(owned_contents);
|
||||||
|
@ -10,12 +10,13 @@
|
|||||||
#include "libcef/browser/web_contents_dialog_helper.h"
|
#include "libcef/browser/web_contents_dialog_helper.h"
|
||||||
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "content/public/browser/web_contents.h"
|
||||||
|
#include "ui/gfx/geometry/size.h"
|
||||||
|
|
||||||
// Implementation of Alloy-based browser functionality.
|
// Implementation of Alloy-based browser functionality.
|
||||||
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
||||||
public:
|
public:
|
||||||
content::WebContents* CreateWebContents(
|
content::WebContents* CreateWebContents(CefBrowserCreateParams& create_params,
|
||||||
CefBrowserHostBase::CreateParams& create_params,
|
|
||||||
bool& own_web_contents) override;
|
bool& own_web_contents) override;
|
||||||
void WebContentsCreated(content::WebContents* web_contents,
|
void WebContentsCreated(content::WebContents* web_contents,
|
||||||
bool owned) override;
|
bool owned) override;
|
||||||
@ -29,12 +30,12 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
|
bool ShouldTransferNavigation(bool is_main_frame_navigation) override;
|
||||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void RenderViewReady() override;
|
void RenderViewReady() override;
|
||||||
void BrowserCreated(AlloyBrowserHostImpl* browser) override;
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||||
void CreateExtensionHost(const extensions::Extension* extension,
|
void CreateExtensionHost(const extensions::Extension* extension,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
extensions::ViewType host_type) override;
|
extensions::ViewType host_type) override;
|
||||||
extensions::ExtensionHost* GetExtensionHost() const override;
|
extensions::ExtensionHost* GetExtensionHost() const override;
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
void SendCaptureLostEvent() override;
|
void SendCaptureLostEvent() override;
|
||||||
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
|
#if defined(OS_WIN) || (defined(OS_POSIX) && !defined(OS_MAC))
|
||||||
void NotifyMoveOrResizeStarted() override;
|
void NotifyMoveOrResizeStarted() override;
|
||||||
@ -69,6 +70,9 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
// Otherwise, the browser's WebContents will be returned.
|
// Otherwise, the browser's WebContents will be returned.
|
||||||
content::WebContents* GetActionableWebContents() const;
|
content::WebContents* GetActionableWebContents() const;
|
||||||
|
|
||||||
|
// Called from BrowserPlatformDelegateNative::set_windowless_handler().
|
||||||
|
void set_as_secondary() { primary_ = false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetOwnedWebContents(content::WebContents* owned_contents);
|
void SetOwnedWebContents(content::WebContents* owned_contents);
|
||||||
|
|
||||||
@ -98,6 +102,10 @@ class CefBrowserPlatformDelegateAlloy : public CefBrowserPlatformDelegate {
|
|||||||
gfx::Size auto_resize_min_;
|
gfx::Size auto_resize_min_;
|
||||||
gfx::Size auto_resize_max_;
|
gfx::Size auto_resize_max_;
|
||||||
|
|
||||||
|
// True if this is the primary platform delegate, in which case it will
|
||||||
|
// register WebContents delegate/observers.
|
||||||
|
bool primary_ = true;
|
||||||
|
|
||||||
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
|
base::WeakPtrFactory<CefBrowserPlatformDelegateAlloy> weak_ptr_factory_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy);
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegateAlloy);
|
||||||
|
@ -5,11 +5,20 @@
|
|||||||
#include "libcef/browser/browser_contents_delegate.h"
|
#include "libcef/browser/browser_contents_delegate.h"
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_base.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
|
#include "libcef/browser/browser_util.h"
|
||||||
|
|
||||||
|
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||||
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
#include "content/public/browser/navigation_handle.h"
|
#include "content/public/browser/navigation_handle.h"
|
||||||
|
#include "content/public/browser/notification_details.h"
|
||||||
|
#include "content/public/browser/notification_source.h"
|
||||||
|
#include "content/public/browser/notification_types.h"
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
|
|
||||||
|
using content::KeyboardEventProcessingResult;
|
||||||
|
|
||||||
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
||||||
scoped_refptr<CefBrowserInfo> browser_info)
|
scoped_refptr<CefBrowserInfo> browser_info)
|
||||||
: browser_info_(browser_info) {
|
: browser_info_(browser_info) {
|
||||||
@ -18,13 +27,29 @@ CefBrowserContentsDelegate::CefBrowserContentsDelegate(
|
|||||||
|
|
||||||
void CefBrowserContentsDelegate::ObserveWebContents(
|
void CefBrowserContentsDelegate::ObserveWebContents(
|
||||||
content::WebContents* new_contents) {
|
content::WebContents* new_contents) {
|
||||||
Observe(new_contents);
|
WebContentsObserver::Observe(new_contents);
|
||||||
|
|
||||||
if (new_contents) {
|
if (new_contents) {
|
||||||
|
registrar_.reset(new content::NotificationRegistrar);
|
||||||
|
|
||||||
|
// When navigating through the history, the restored NavigationEntry's title
|
||||||
|
// will be used. If the entry ends up having the same title after we return
|
||||||
|
// to it, as will usually be the case, the
|
||||||
|
// NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED will then be suppressed, since
|
||||||
|
// the NavigationEntry's title hasn't changed.
|
||||||
|
registrar_->Add(this, content::NOTIFICATION_LOAD_STOP,
|
||||||
|
content::Source<content::NavigationController>(
|
||||||
|
&new_contents->GetController()));
|
||||||
|
|
||||||
|
// Make sure RenderViewCreated is called at least one time.
|
||||||
|
RenderViewCreated(new_contents->GetRenderViewHost());
|
||||||
|
|
||||||
// Create the frame representation before OnAfterCreated is called for a new
|
// Create the frame representation before OnAfterCreated is called for a new
|
||||||
// browser. Additionally, RenderFrameCreated is otherwise not called at all
|
// browser. Additionally, RenderFrameCreated is otherwise not called at all
|
||||||
// for new popup browsers.
|
// for new popup browsers.
|
||||||
RenderFrameCreated(new_contents->GetMainFrame());
|
RenderFrameCreated(new_contents->GetMainFrame());
|
||||||
|
} else {
|
||||||
|
registrar_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +61,27 @@ void CefBrowserContentsDelegate::RemoveObserver(Observer* observer) {
|
|||||||
observers_.RemoveObserver(observer);
|
observers_.RemoveObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// |source| may be NULL for navigations in the current tab, or if the
|
||||||
|
// navigation originates from a guest view via MaybeAllowNavigation.
|
||||||
|
content::WebContents* CefBrowserContentsDelegate::OpenURLFromTab(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::OpenURLParams& params) {
|
||||||
|
bool cancel = false;
|
||||||
|
|
||||||
|
if (auto c = client()) {
|
||||||
|
if (auto handler = c->GetRequestHandler()) {
|
||||||
|
cancel = handler->OnOpenURLFromTab(
|
||||||
|
browser(), browser()->GetFrame(params.frame_tree_node_id),
|
||||||
|
params.url.spec(),
|
||||||
|
static_cast<cef_window_open_disposition_t>(params.disposition),
|
||||||
|
params.user_gesture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returning nullptr will cancel the navigation.
|
||||||
|
return cancel ? nullptr : web_contents();
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::LoadingStateChanged(
|
void CefBrowserContentsDelegate::LoadingStateChanged(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
bool to_different_document) {
|
bool to_different_document) {
|
||||||
@ -126,6 +172,60 @@ void CefBrowserContentsDelegate::ExitFullscreenModeForTab(
|
|||||||
OnFullscreenModeChange(/*fullscreen=*/false);
|
OnFullscreenModeChange(/*fullscreen=*/false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardEventProcessingResult
|
||||||
|
CefBrowserContentsDelegate::PreHandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
if (auto delegate = platform_delegate()) {
|
||||||
|
if (auto c = client()) {
|
||||||
|
if (auto handler = c->GetKeyboardHandler()) {
|
||||||
|
CefKeyEvent cef_event;
|
||||||
|
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
||||||
|
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
||||||
|
|
||||||
|
auto event_handle = delegate->GetEventHandle(event);
|
||||||
|
bool is_keyboard_shortcut = false;
|
||||||
|
bool result = handler->OnPreKeyEvent(
|
||||||
|
browser(), cef_event, event_handle, &is_keyboard_shortcut);
|
||||||
|
if (result) {
|
||||||
|
return KeyboardEventProcessingResult::HANDLED;
|
||||||
|
} else if (is_keyboard_shortcut) {
|
||||||
|
return KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return KeyboardEventProcessingResult::NOT_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserContentsDelegate::HandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
// Check to see if event should be ignored.
|
||||||
|
if (event.skip_in_browser)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (auto delegate = platform_delegate()) {
|
||||||
|
if (auto c = client()) {
|
||||||
|
if (auto handler = c->GetKeyboardHandler()) {
|
||||||
|
CefKeyEvent cef_event;
|
||||||
|
if (browser_util::GetCefKeyEvent(event, cef_event)) {
|
||||||
|
cef_event.focus_on_editable_field = focus_on_editable_field_;
|
||||||
|
|
||||||
|
auto event_handle = delegate->GetEventHandle(event);
|
||||||
|
if (handler->OnKeyEvent(browser(), cef_event, event_handle)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::RenderFrameCreated(
|
void CefBrowserContentsDelegate::RenderFrameCreated(
|
||||||
content::RenderFrameHost* render_frame_host) {
|
content::RenderFrameHost* render_frame_host) {
|
||||||
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
|
browser_info_->MaybeCreateFrame(render_frame_host, false /* is_guest_view */);
|
||||||
@ -149,6 +249,28 @@ void CefBrowserContentsDelegate::RenderFrameDeleted(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserContentsDelegate::RenderViewCreated(
|
||||||
|
content::RenderViewHost* render_view_host) {
|
||||||
|
// May be already registered if the renderer crashed previously.
|
||||||
|
if (!registrar_->IsRegistered(
|
||||||
|
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(render_view_host))) {
|
||||||
|
registrar_->Add(this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(render_view_host));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserContentsDelegate::RenderViewDeleted(
|
||||||
|
content::RenderViewHost* render_view_host) {
|
||||||
|
if (registrar_->IsRegistered(
|
||||||
|
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(render_view_host))) {
|
||||||
|
registrar_->Remove(
|
||||||
|
this, content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE,
|
||||||
|
content::Source<content::RenderViewHost>(render_view_host));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::RenderViewReady() {
|
void CefBrowserContentsDelegate::RenderViewReady() {
|
||||||
if (auto c = client()) {
|
if (auto c = client()) {
|
||||||
if (auto handler = c->GetRequestHandler()) {
|
if (auto handler = c->GetRequestHandler()) {
|
||||||
@ -358,12 +480,77 @@ void CefBrowserContentsDelegate::OnWebContentsFocused(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::WebContentsDestroyed() {
|
void CefBrowserContentsDelegate::WebContentsDestroyed() {
|
||||||
|
auto wc = web_contents();
|
||||||
ObserveWebContents(nullptr);
|
ObserveWebContents(nullptr);
|
||||||
for (auto& observer : observers_) {
|
for (auto& observer : observers_) {
|
||||||
observer.OnWebContentsDestroyed();
|
observer.OnWebContentsDestroyed(wc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserContentsDelegate::Observe(
|
||||||
|
int type,
|
||||||
|
const content::NotificationSource& source,
|
||||||
|
const content::NotificationDetails& details) {
|
||||||
|
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
|
||||||
|
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
|
||||||
|
|
||||||
|
if (type == content::NOTIFICATION_LOAD_STOP) {
|
||||||
|
content::NavigationController* controller =
|
||||||
|
content::Source<content::NavigationController>(source).ptr();
|
||||||
|
OnTitleChange(controller->GetWebContents()->GetTitle());
|
||||||
|
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
|
||||||
|
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||||
|
const GURL& url,
|
||||||
|
int http_status_code) {
|
||||||
|
if (auto c = client()) {
|
||||||
|
if (auto handler = c->GetLoadHandler()) {
|
||||||
|
handler->OnLoadEnd(browser(), frame, http_status_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserContentsDelegate::OnSetFocus(cef_focus_source_t source) {
|
||||||
|
// SetFocus() might be called while inside the OnSetFocus() callback. If
|
||||||
|
// so, don't re-enter the callback.
|
||||||
|
if (is_in_onsetfocus_)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (auto c = client()) {
|
||||||
|
if (auto handler = c->GetFocusHandler()) {
|
||||||
|
is_in_onsetfocus_ = true;
|
||||||
|
bool handled = handler->OnSetFocus(browser(), source);
|
||||||
|
is_in_onsetfocus_ = false;
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefClient> CefBrowserContentsDelegate::client() const {
|
||||||
|
if (auto b = browser()) {
|
||||||
|
return b->GetHost()->GetClient();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowser> CefBrowserContentsDelegate::browser() const {
|
||||||
|
return browser_info_->browser();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefBrowserPlatformDelegate* CefBrowserContentsDelegate::platform_delegate()
|
||||||
|
const {
|
||||||
|
auto browser = browser_info_->browser();
|
||||||
|
if (browser)
|
||||||
|
return browser->platform_delegate();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::OnAddressChange(const GURL& url) {
|
void CefBrowserContentsDelegate::OnAddressChange(const GURL& url) {
|
||||||
if (auto c = client()) {
|
if (auto c = client()) {
|
||||||
if (auto handler = c->GetDisplayHandler()) {
|
if (auto handler = c->GetDisplayHandler()) {
|
||||||
@ -400,16 +587,6 @@ void CefBrowserContentsDelegate::OnLoadError(CefRefPtr<CefFrame> frame,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::OnLoadEnd(CefRefPtr<CefFrame> frame,
|
|
||||||
const GURL& url,
|
|
||||||
int http_status_code) {
|
|
||||||
if (auto c = client()) {
|
|
||||||
if (auto handler = c->GetLoadHandler()) {
|
|
||||||
handler->OnLoadEnd(browser(), frame, http_status_code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
|
void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
|
||||||
if (auto c = client()) {
|
if (auto c = client()) {
|
||||||
if (auto handler = c->GetDisplayHandler()) {
|
if (auto handler = c->GetDisplayHandler()) {
|
||||||
@ -418,17 +595,6 @@ void CefBrowserContentsDelegate::OnTitleChange(const base::string16& title) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefClient> CefBrowserContentsDelegate::client() const {
|
|
||||||
if (auto b = browser()) {
|
|
||||||
return b->GetHost()->GetClient();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefBrowser> CefBrowserContentsDelegate::browser() const {
|
|
||||||
return browser_info_->browser();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserContentsDelegate::OnFullscreenModeChange(bool fullscreen) {
|
void CefBrowserContentsDelegate::OnFullscreenModeChange(bool fullscreen) {
|
||||||
if (fullscreen == is_fullscreen_)
|
if (fullscreen == is_fullscreen_)
|
||||||
return;
|
return;
|
||||||
|
@ -11,11 +11,14 @@
|
|||||||
#include "libcef/browser/frame_host_impl.h"
|
#include "libcef/browser/frame_host_impl.h"
|
||||||
|
|
||||||
#include "base/observer_list.h"
|
#include "base/observer_list.h"
|
||||||
|
#include "content/public/browser/notification_observer.h"
|
||||||
|
#include "content/public/browser/notification_registrar.h"
|
||||||
#include "content/public/browser/web_contents_delegate.h"
|
#include "content/public/browser/web_contents_delegate.h"
|
||||||
#include "content/public/browser/web_contents_observer.h"
|
#include "content/public/browser/web_contents_observer.h"
|
||||||
|
|
||||||
class CefBrowser;
|
class CefBrowser;
|
||||||
class CefBrowserInfo;
|
class CefBrowserInfo;
|
||||||
|
class CefBrowserPlatformDelegate;
|
||||||
class CefClient;
|
class CefClient;
|
||||||
|
|
||||||
// Flags that represent which states have changed.
|
// Flags that represent which states have changed.
|
||||||
@ -45,7 +48,8 @@ constexpr inline CefBrowserContentsState operator|(
|
|||||||
// Includes functionality that is shared by the alloy and chrome runtimes.
|
// Includes functionality that is shared by the alloy and chrome runtimes.
|
||||||
// Only accessed on the UI thread.
|
// Only accessed on the UI thread.
|
||||||
class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
||||||
public content::WebContentsObserver {
|
public content::WebContentsObserver,
|
||||||
|
public content::NotificationObserver {
|
||||||
public:
|
public:
|
||||||
using State = CefBrowserContentsState;
|
using State = CefBrowserContentsState;
|
||||||
|
|
||||||
@ -58,7 +62,7 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
virtual void OnStateChanged(State state_changed) = 0;
|
virtual void OnStateChanged(State state_changed) = 0;
|
||||||
|
|
||||||
// Called when the associated WebContents is destroyed.
|
// Called when the associated WebContents is destroyed.
|
||||||
virtual void OnWebContentsDestroyed() = 0;
|
virtual void OnWebContentsDestroyed(content::WebContents* web_contents) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~Observer() override {}
|
~Observer() override {}
|
||||||
@ -75,6 +79,9 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
void RemoveObserver(Observer* observer);
|
void RemoveObserver(Observer* observer);
|
||||||
|
|
||||||
// WebContentsDelegate methods:
|
// WebContentsDelegate methods:
|
||||||
|
content::WebContents* OpenURLFromTab(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::OpenURLParams& params) override;
|
||||||
void LoadingStateChanged(content::WebContents* source,
|
void LoadingStateChanged(content::WebContents* source,
|
||||||
bool to_different_document) override;
|
bool to_different_document) override;
|
||||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||||
@ -89,12 +96,20 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
content::RenderFrameHost* requesting_frame,
|
content::RenderFrameHost* requesting_frame,
|
||||||
const blink::mojom::FullscreenOptions& options) override;
|
const blink::mojom::FullscreenOptions& options) override;
|
||||||
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
||||||
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
bool HandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
|
||||||
// WebContentsObserver methods:
|
// WebContentsObserver methods:
|
||||||
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
|
||||||
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
void RenderFrameHostChanged(content::RenderFrameHost* old_host,
|
||||||
content::RenderFrameHost* new_host) override;
|
content::RenderFrameHost* new_host) override;
|
||||||
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
||||||
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
|
void RenderViewDeleted(content::RenderViewHost* render_view_host) override;
|
||||||
void RenderViewReady() override;
|
void RenderViewReady() override;
|
||||||
void RenderProcessGone(base::TerminationStatus status) override;
|
void RenderProcessGone(base::TerminationStatus status) override;
|
||||||
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
|
void OnFrameFocused(content::RenderFrameHost* render_frame_host) override;
|
||||||
@ -118,6 +133,11 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
content::RenderWidgetHost* render_widget_host) override;
|
content::RenderWidgetHost* render_widget_host) override;
|
||||||
void WebContentsDestroyed() override;
|
void WebContentsDestroyed() override;
|
||||||
|
|
||||||
|
// NotificationObserver methods.
|
||||||
|
void Observe(int type,
|
||||||
|
const content::NotificationSource& source,
|
||||||
|
const content::NotificationDetails& details) override;
|
||||||
|
|
||||||
// Accessors for state information. Changes will be signaled to
|
// Accessors for state information. Changes will be signaled to
|
||||||
// Observer::OnStateChanged.
|
// Observer::OnStateChanged.
|
||||||
bool is_loading() const { return is_loading_; }
|
bool is_loading() const { return is_loading_; }
|
||||||
@ -128,20 +148,25 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
CefRefPtr<CefFrameHostImpl> focused_frame() const { return focused_frame_; }
|
CefRefPtr<CefFrameHostImpl> focused_frame() const { return focused_frame_; }
|
||||||
|
|
||||||
// Helpers for executing client callbacks.
|
// Helpers for executing client callbacks.
|
||||||
void OnAddressChange(const GURL& url);
|
// TODO(cef): Make this private if/when possible.
|
||||||
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
|
||||||
ui::PageTransition transition_type);
|
|
||||||
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
|
||||||
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
void OnLoadEnd(CefRefPtr<CefFrame> frame,
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
int http_status_code);
|
int http_status_code);
|
||||||
void OnTitleChange(const base::string16& title);
|
bool OnSetFocus(cef_focus_source_t source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CefRefPtr<CefClient> client() const;
|
CefRefPtr<CefClient> client() const;
|
||||||
CefRefPtr<CefBrowser> browser() const;
|
CefRefPtr<CefBrowser> browser() const;
|
||||||
|
CefBrowserPlatformDelegate* platform_delegate() const;
|
||||||
|
|
||||||
|
// Helpers for executing client callbacks.
|
||||||
|
void OnAddressChange(const GURL& url);
|
||||||
|
void OnLoadStart(CefRefPtr<CefFrame> frame,
|
||||||
|
ui::PageTransition transition_type);
|
||||||
|
void OnLoadError(CefRefPtr<CefFrame> frame, const GURL& url, int error_code);
|
||||||
|
void OnTitleChange(const base::string16& title);
|
||||||
void OnFullscreenModeChange(bool fullscreen);
|
void OnFullscreenModeChange(bool fullscreen);
|
||||||
|
|
||||||
void OnStateChanged(State state_changed);
|
void OnStateChanged(State state_changed);
|
||||||
|
|
||||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||||
@ -155,9 +180,18 @@ class CefBrowserContentsDelegate : public content::WebContentsDelegate,
|
|||||||
// The currently focused frame, or nullptr if the main frame is focused.
|
// The currently focused frame, or nullptr if the main frame is focused.
|
||||||
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
CefRefPtr<CefFrameHostImpl> focused_frame_;
|
||||||
|
|
||||||
|
// True if currently in the OnSetFocus callback.
|
||||||
|
bool is_in_onsetfocus_ = false;
|
||||||
|
|
||||||
// Observers that want to be notified of changes to this object.
|
// Observers that want to be notified of changes to this object.
|
||||||
base::ObserverList<Observer> observers_;
|
base::ObserverList<Observer> observers_;
|
||||||
|
|
||||||
|
// Used for managing notification subscriptions.
|
||||||
|
std::unique_ptr<content::NotificationRegistrar> registrar_;
|
||||||
|
|
||||||
|
// True if the focus is currently on an editable field on the page.
|
||||||
|
bool focus_on_editable_field_ = false;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserContentsDelegate);
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserContentsDelegate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -470,3 +470,12 @@ CefMediaRouterManager* CefBrowserContext::GetMediaRouterManager() {
|
|||||||
}
|
}
|
||||||
return media_router_manager_.get();
|
return media_router_manager_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefBrowserContext::CookieableSchemes CefBrowserContext::GetCookieableSchemes()
|
||||||
|
const {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
if (cookieable_schemes_)
|
||||||
|
return cookieable_schemes_;
|
||||||
|
|
||||||
|
return CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
||||||
|
}
|
||||||
|
@ -193,10 +193,15 @@ class CefBrowserContext {
|
|||||||
CefMediaRouterManager* GetMediaRouterManager();
|
CefMediaRouterManager* GetMediaRouterManager();
|
||||||
|
|
||||||
using CookieableSchemes = base::Optional<std::vector<std::string>>;
|
using CookieableSchemes = base::Optional<std::vector<std::string>>;
|
||||||
|
|
||||||
|
// Returns the schemes associated with this context specifically, or the
|
||||||
|
// global configuration if unset.
|
||||||
|
CookieableSchemes GetCookieableSchemes() const;
|
||||||
|
|
||||||
|
// Set the schemes associated with this context specifically.
|
||||||
void set_cookieable_schemes(const CookieableSchemes& schemes) {
|
void set_cookieable_schemes(const CookieableSchemes& schemes) {
|
||||||
cookieable_schemes_ = schemes;
|
cookieable_schemes_ = schemes;
|
||||||
}
|
}
|
||||||
CookieableSchemes cookieable_schemes() const { return cookieable_schemes_; }
|
|
||||||
|
|
||||||
// These accessors are safe to call from any thread because the values don't
|
// These accessors are safe to call from any thread because the values don't
|
||||||
// change during this object's lifespan.
|
// change during this object's lifespan.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "libcef/browser/browser_host_base.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
|
|
||||||
#include "libcef/browser/browser_info_manager.h"
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
#include "libcef/browser/image_impl.h"
|
#include "libcef/browser/image_impl.h"
|
||||||
#include "libcef/browser/navigation_entry_impl.h"
|
#include "libcef/browser/navigation_entry_impl.h"
|
||||||
#include "libcef/browser/net/scheme_handler.h"
|
#include "libcef/browser/net/scheme_handler.h"
|
||||||
@ -155,10 +156,12 @@ CefRefPtr<CefBrowserHostBase> CefBrowserHostBase::GetBrowserForFrameRoute(
|
|||||||
CefBrowserHostBase::CefBrowserHostBase(
|
CefBrowserHostBase::CefBrowserHostBase(
|
||||||
const CefBrowserSettings& settings,
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context)
|
CefRefPtr<CefRequestContextImpl> request_context)
|
||||||
: settings_(settings),
|
: settings_(settings),
|
||||||
client_(client),
|
client_(client),
|
||||||
|
platform_delegate_(std::move(platform_delegate)),
|
||||||
browser_info_(browser_info),
|
browser_info_(browser_info),
|
||||||
request_context_(request_context) {
|
request_context_(request_context) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
@ -181,6 +184,8 @@ void CefBrowserHostBase::InitializeBrowser() {
|
|||||||
void CefBrowserHostBase::DestroyBrowser() {
|
void CefBrowserHostBase::DestroyBrowser() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
platform_delegate_.reset(nullptr);
|
||||||
|
|
||||||
contents_delegate_->RemoveObserver(this);
|
contents_delegate_->RemoveObserver(this);
|
||||||
contents_delegate_->ObserveWebContents(nullptr);
|
contents_delegate_->ObserveWebContents(nullptr);
|
||||||
|
|
||||||
@ -375,6 +380,67 @@ void CefBrowserHostBase::AddWordToDictionary(const CefString& word) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::SendKeyEvent(const CefKeyEvent& event) {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&CefBrowserHostBase::SendKeyEvent,
|
||||||
|
this, event));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platform_delegate_)
|
||||||
|
platform_delegate_->SendKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::SendMouseClickEvent(const CefMouseEvent& event,
|
||||||
|
MouseButtonType type,
|
||||||
|
bool mouseUp,
|
||||||
|
int clickCount) {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::BindOnce(&CefBrowserHostBase::SendMouseClickEvent, this,
|
||||||
|
event, type, mouseUp, clickCount));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platform_delegate_) {
|
||||||
|
platform_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::SendMouseMoveEvent(const CefMouseEvent& event,
|
||||||
|
bool mouseLeave) {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::BindOnce(&CefBrowserHostBase::SendMouseMoveEvent, this,
|
||||||
|
event, mouseLeave));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platform_delegate_) {
|
||||||
|
platform_delegate_->SendMouseMoveEvent(event, mouseLeave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||||
|
int deltaX,
|
||||||
|
int deltaY) {
|
||||||
|
if (deltaX == 0 && deltaY == 0) {
|
||||||
|
// Nothing to do.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::BindOnce(&CefBrowserHostBase::SendMouseWheelEvent, this,
|
||||||
|
event, deltaX, deltaY));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platform_delegate_) {
|
||||||
|
platform_delegate_->SendMouseWheelEvent(event, deltaX, deltaY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
|
CefRefPtr<CefBrowserHost> CefBrowserHostBase::GetHost() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -384,16 +450,96 @@ bool CefBrowserHostBase::CanGoBack() {
|
|||||||
return can_go_back_;
|
return can_go_back_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::GoBack() {
|
||||||
|
auto callback = base::BindOnce(&CefBrowserHostBase::GoBack, this);
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wc = GetWebContents();
|
||||||
|
if (wc && wc->GetController().CanGoBack()) {
|
||||||
|
wc->GetController().GoBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserHostBase::CanGoForward() {
|
bool CefBrowserHostBase::CanGoForward() {
|
||||||
base::AutoLock lock_scope(state_lock_);
|
base::AutoLock lock_scope(state_lock_);
|
||||||
return can_go_forward_;
|
return can_go_forward_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::GoForward() {
|
||||||
|
auto callback = base::BindOnce(&CefBrowserHostBase::GoForward, this);
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wc = GetWebContents();
|
||||||
|
if (wc && wc->GetController().CanGoForward()) {
|
||||||
|
wc->GetController().GoForward();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserHostBase::IsLoading() {
|
bool CefBrowserHostBase::IsLoading() {
|
||||||
base::AutoLock lock_scope(state_lock_);
|
base::AutoLock lock_scope(state_lock_);
|
||||||
return is_loading_;
|
return is_loading_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::Reload() {
|
||||||
|
auto callback = base::BindOnce(&CefBrowserHostBase::Reload, this);
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wc = GetWebContents();
|
||||||
|
if (wc) {
|
||||||
|
wc->GetController().Reload(content::ReloadType::NORMAL, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::ReloadIgnoreCache() {
|
||||||
|
auto callback = base::BindOnce(&CefBrowserHostBase::ReloadIgnoreCache, this);
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wc = GetWebContents();
|
||||||
|
if (wc) {
|
||||||
|
wc->GetController().Reload(content::ReloadType::BYPASSING_CACHE, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::StopLoad() {
|
||||||
|
auto callback = base::BindOnce(&CefBrowserHostBase::StopLoad, this);
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto wc = GetWebContents();
|
||||||
|
if (wc) {
|
||||||
|
wc->Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int CefBrowserHostBase::GetIdentifier() {
|
int CefBrowserHostBase::GetIdentifier() {
|
||||||
return browser_id();
|
return browser_id();
|
||||||
}
|
}
|
||||||
@ -501,7 +647,8 @@ void CefBrowserHostBase::OnStateChanged(CefBrowserContentsState state_changed) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::OnWebContentsDestroyed() {}
|
void CefBrowserHostBase::OnWebContentsDestroyed(
|
||||||
|
content::WebContents* web_contents) {}
|
||||||
|
|
||||||
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
|
CefRefPtr<CefFrame> CefBrowserHostBase::GetFrameForHost(
|
||||||
const content::RenderFrameHost* host) {
|
const content::RenderFrameHost* host) {
|
||||||
@ -532,12 +679,15 @@ bool CefBrowserHostBase::HasObserver(Observer* observer) const {
|
|||||||
return observers_.HasObserver(observer);
|
return observers_.HasObserver(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::LoadMainFrameURL(const std::string& url,
|
void CefBrowserHostBase::LoadMainFrameURL(
|
||||||
const content::Referrer& referrer,
|
const content::OpenURLParams& params) {
|
||||||
ui::PageTransition transition,
|
if (!params.url.is_valid()) {
|
||||||
const std::string& extra_headers) {
|
LOG(ERROR) << "Invalid URL: " << params.url.spec();
|
||||||
auto callback = base::BindOnce(&CefBrowserHostBase::LoadMainFrameURL, this,
|
return;
|
||||||
url, referrer, transition, extra_headers);
|
}
|
||||||
|
|
||||||
|
auto callback =
|
||||||
|
base::BindOnce(&CefBrowserHostBase::LoadMainFrameURL, this, params);
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
||||||
return;
|
return;
|
||||||
@ -547,27 +697,22 @@ void CefBrowserHostBase::LoadMainFrameURL(const std::string& url,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto web_contents = GetWebContents();
|
if (Navigate(params)) {
|
||||||
if (web_contents) {
|
|
||||||
GURL gurl = GURL(url);
|
|
||||||
|
|
||||||
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
|
||||||
// Try to add "http://" at the beginning
|
|
||||||
std::string new_url = std::string("http://") + url;
|
|
||||||
gurl = GURL(new_url);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gurl.is_valid()) {
|
|
||||||
LOG(ERROR) << "Invalid URL: " << url;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
web_contents->GetController().LoadURL(gurl, referrer, transition,
|
|
||||||
extra_headers);
|
|
||||||
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
OnSetFocus(FOCUS_SOURCE_NAVIGATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CefBrowserHostBase::Navigate(const content::OpenURLParams& params) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
auto web_contents = GetWebContents();
|
||||||
|
if (web_contents) {
|
||||||
|
web_contents->GetController().LoadURL(
|
||||||
|
params.url, params.referrer, params.transition, params.extra_headers);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||||
const GURL& validated_url,
|
const GURL& validated_url,
|
||||||
int http_status_code) {
|
int http_status_code) {
|
||||||
@ -579,6 +724,24 @@ void CefBrowserHostBase::OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
|||||||
contents_delegate_->OnLoadEnd(frame, validated_url, http_status_code);
|
contents_delegate_->OnLoadEnd(frame, validated_url, http_status_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CefBrowserHostBase::ViewText(const std::string& text) {
|
||||||
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT,
|
||||||
|
base::BindOnce(&CefBrowserHostBase::ViewText, this, text));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (platform_delegate_)
|
||||||
|
platform_delegate_->ViewText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserHostBase::MaybeAllowNavigation(
|
||||||
|
content::RenderFrameHost* opener,
|
||||||
|
bool is_guest_view,
|
||||||
|
const content::OpenURLParams& params) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserHostBase::OnAfterCreated() {
|
void CefBrowserHostBase::OnAfterCreated() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
if (client_) {
|
if (client_) {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "include/views/cef_browser_view.h"
|
#include "include/views/cef_browser_view.h"
|
||||||
#include "libcef/browser/browser_contents_delegate.h"
|
#include "libcef/browser/browser_contents_delegate.h"
|
||||||
#include "libcef/browser/browser_info.h"
|
#include "libcef/browser/browser_info.h"
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
#include "libcef/browser/frame_host_impl.h"
|
#include "libcef/browser/frame_host_impl.h"
|
||||||
#include "libcef/browser/request_context_impl.h"
|
#include "libcef/browser/request_context_impl.h"
|
||||||
|
|
||||||
@ -22,20 +23,15 @@ namespace extensions {
|
|||||||
class Extension;
|
class Extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base class for CefBrowserHost implementations. Includes functionality that is
|
|
||||||
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
|
|
||||||
// otherwise indicated.
|
|
||||||
class CefBrowserHostBase : public CefBrowserHost,
|
|
||||||
public CefBrowser,
|
|
||||||
public CefBrowserContentsDelegate::Observer {
|
|
||||||
public:
|
|
||||||
// Parameters that are passed to the runtime-specific Create methods.
|
// Parameters that are passed to the runtime-specific Create methods.
|
||||||
struct CreateParams {
|
struct CefBrowserCreateParams {
|
||||||
CreateParams() {}
|
CefBrowserCreateParams() {}
|
||||||
|
|
||||||
// Copy constructor used with the chrome runtime only.
|
// Copy constructor used with the chrome runtime only.
|
||||||
CreateParams(const CreateParams& that) { operator=(that); }
|
CefBrowserCreateParams(const CefBrowserCreateParams& that) {
|
||||||
CreateParams& operator=(const CreateParams& that) {
|
operator=(that);
|
||||||
|
}
|
||||||
|
CefBrowserCreateParams& operator=(const CefBrowserCreateParams& that) {
|
||||||
// Not all parameters can be copied.
|
// Not all parameters can be copied.
|
||||||
client = that.client;
|
client = that.client;
|
||||||
url = that.url;
|
url = that.url;
|
||||||
@ -85,6 +81,13 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
|
extensions::ViewType extension_host_type = extensions::VIEW_TYPE_INVALID;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Base class for CefBrowserHost implementations. Includes functionality that is
|
||||||
|
// shared by the alloy and chrome runtimes. All methods are thread-safe unless
|
||||||
|
// otherwise indicated.
|
||||||
|
class CefBrowserHostBase : public CefBrowserHost,
|
||||||
|
public CefBrowser,
|
||||||
|
public CefBrowserContentsDelegate::Observer {
|
||||||
|
public:
|
||||||
// Interface to implement for observers that wish to be informed of changes
|
// Interface to implement for observers that wish to be informed of changes
|
||||||
// to the CefBrowserHostBase. All methods will be called on the UI thread.
|
// to the CefBrowserHostBase. All methods will be called on the UI thread.
|
||||||
class Observer : public base::CheckedObserver {
|
class Observer : public base::CheckedObserver {
|
||||||
@ -114,8 +117,10 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
int render_process_id,
|
int render_process_id,
|
||||||
int render_routing_id);
|
int render_routing_id);
|
||||||
|
|
||||||
CefBrowserHostBase(const CefBrowserSettings& settings,
|
CefBrowserHostBase(
|
||||||
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context);
|
CefRefPtr<CefRequestContextImpl> request_context);
|
||||||
|
|
||||||
@ -139,6 +144,15 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
CefRefPtr<CefDownloadImageCallback> callback) override;
|
CefRefPtr<CefDownloadImageCallback> callback) override;
|
||||||
void ReplaceMisspelling(const CefString& word) override;
|
void ReplaceMisspelling(const CefString& word) override;
|
||||||
void AddWordToDictionary(const CefString& word) override;
|
void AddWordToDictionary(const CefString& word) override;
|
||||||
|
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||||
|
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||||
|
MouseButtonType type,
|
||||||
|
bool mouseUp,
|
||||||
|
int clickCount) override;
|
||||||
|
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
||||||
|
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||||
|
int deltaX,
|
||||||
|
int deltaY) override;
|
||||||
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
|
void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor,
|
||||||
bool current_only) override;
|
bool current_only) override;
|
||||||
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() override;
|
||||||
@ -146,8 +160,13 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
// CefBrowser methods:
|
// CefBrowser methods:
|
||||||
CefRefPtr<CefBrowserHost> GetHost() override;
|
CefRefPtr<CefBrowserHost> GetHost() override;
|
||||||
bool CanGoBack() override;
|
bool CanGoBack() override;
|
||||||
|
void GoBack() override;
|
||||||
bool CanGoForward() override;
|
bool CanGoForward() override;
|
||||||
|
void GoForward() override;
|
||||||
bool IsLoading() override;
|
bool IsLoading() override;
|
||||||
|
void Reload() override;
|
||||||
|
void ReloadIgnoreCache() override;
|
||||||
|
void StopLoad() override;
|
||||||
int GetIdentifier() override;
|
int GetIdentifier() override;
|
||||||
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
||||||
bool HasDocument() override;
|
bool HasDocument() override;
|
||||||
@ -162,7 +181,7 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
|
|
||||||
// CefBrowserContentsDelegate::Observer methods:
|
// CefBrowserContentsDelegate::Observer methods:
|
||||||
void OnStateChanged(CefBrowserContentsState state_changed) override;
|
void OnStateChanged(CefBrowserContentsState state_changed) override;
|
||||||
void OnWebContentsDestroyed() override;
|
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
|
||||||
|
|
||||||
// Returns the frame associated with the specified RenderFrameHost.
|
// Returns the frame associated with the specified RenderFrameHost.
|
||||||
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
|
CefRefPtr<CefFrame> GetFrameForHost(const content::RenderFrameHost* host);
|
||||||
@ -177,15 +196,17 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
bool HasObserver(Observer* observer) const;
|
bool HasObserver(Observer* observer) const;
|
||||||
|
|
||||||
// Methods called from CefFrameHostImpl.
|
// Methods called from CefFrameHostImpl.
|
||||||
void LoadMainFrameURL(const std::string& url,
|
void LoadMainFrameURL(const content::OpenURLParams& params);
|
||||||
const content::Referrer& referrer,
|
|
||||||
ui::PageTransition transition,
|
|
||||||
const std::string& extra_headers);
|
|
||||||
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
void OnDidFinishLoad(CefRefPtr<CefFrameHostImpl> frame,
|
||||||
const GURL& validated_url,
|
const GURL& validated_url,
|
||||||
int http_status_code);
|
int http_status_code);
|
||||||
virtual void OnSetFocus(cef_focus_source_t source) = 0;
|
virtual void OnSetFocus(cef_focus_source_t source) = 0;
|
||||||
virtual void ViewText(const std::string& text) = 0;
|
void ViewText(const std::string& text);
|
||||||
|
|
||||||
|
// Called from CefBrowserInfoManager::MaybeAllowNavigation.
|
||||||
|
virtual bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||||
|
bool is_guest_view,
|
||||||
|
const content::OpenURLParams& params);
|
||||||
|
|
||||||
// Helpers for executing client callbacks. Must be called on the UI thread.
|
// Helpers for executing client callbacks. Must be called on the UI thread.
|
||||||
void OnAfterCreated();
|
void OnAfterCreated();
|
||||||
@ -204,14 +225,21 @@ class CefBrowserHostBase : public CefBrowserHost,
|
|||||||
// Accessors that must be called on the UI thread.
|
// Accessors that must be called on the UI thread.
|
||||||
content::WebContents* GetWebContents() const;
|
content::WebContents* GetWebContents() const;
|
||||||
content::BrowserContext* GetBrowserContext() const;
|
content::BrowserContext* GetBrowserContext() const;
|
||||||
|
CefBrowserPlatformDelegate* platform_delegate() const {
|
||||||
|
return platform_delegate_.get();
|
||||||
|
}
|
||||||
CefBrowserContentsDelegate* contents_delegate() const {
|
CefBrowserContentsDelegate* contents_delegate() const {
|
||||||
return contents_delegate_.get();
|
return contents_delegate_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// Called from LoadMainFrameURL to perform the actual navigation.
|
||||||
|
virtual bool Navigate(const content::OpenURLParams& params);
|
||||||
|
|
||||||
// Thread-safe members.
|
// Thread-safe members.
|
||||||
CefBrowserSettings settings_;
|
CefBrowserSettings settings_;
|
||||||
CefRefPtr<CefClient> client_;
|
CefRefPtr<CefClient> client_;
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate_;
|
||||||
scoped_refptr<CefBrowserInfo> browser_info_;
|
scoped_refptr<CefBrowserInfo> browser_info_;
|
||||||
CefRefPtr<CefRequestContextImpl> request_context_;
|
CefRefPtr<CefRequestContextImpl> request_context_;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ CefRefPtr<CefBrowser> CefBrowserHost::CreateBrowserSync(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
||||||
create_params.client = client;
|
create_params.client = client;
|
||||||
create_params.url = GURL(url.ToString());
|
create_params.url = GURL(url.ToString());
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/browser_platform_delegate.h"
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
#include "libcef/browser/extensions/browser_extensions_util.h"
|
#include "libcef/browser/extensions/browser_extensions_util.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
@ -24,7 +24,6 @@
|
|||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
#include "content/public/common/child_process_host.h"
|
#include "content/public/common/child_process_host.h"
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
#include "extensions/common/constants.h"
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@ -117,14 +116,13 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
|||||||
bool opener_suppressed,
|
bool opener_suppressed,
|
||||||
bool* no_javascript_access) {
|
bool* no_javascript_access) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
|
|
||||||
content::OpenURLParams params(target_url, referrer, disposition,
|
content::OpenURLParams params(target_url, referrer, disposition,
|
||||||
ui::PAGE_TRANSITION_LINK,
|
ui::PAGE_TRANSITION_LINK,
|
||||||
/*is_renderer_initiated=*/true);
|
/*is_renderer_initiated=*/true);
|
||||||
params.user_gesture = user_gesture;
|
params.user_gesture = user_gesture;
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser;
|
CefRefPtr<CefBrowserHostBase> browser;
|
||||||
if (!MaybeAllowNavigation(opener, params, browser) || !browser) {
|
if (!MaybeAllowNavigation(opener, params, browser) || !browser) {
|
||||||
// Cancel the popup.
|
// Cancel the popup.
|
||||||
return false;
|
return false;
|
||||||
@ -182,9 +180,9 @@ bool CefBrowserInfoManager::CanCreateWindow(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allow) {
|
if (allow) {
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
|
|
||||||
if (!browser->IsViewsHosted())
|
if (!browser->HasView())
|
||||||
create_params.window_info = std::move(window_info);
|
create_params.window_info = std::move(window_info);
|
||||||
|
|
||||||
create_params.settings = pending_popup->settings;
|
create_params.settings = pending_popup->settings;
|
||||||
@ -243,12 +241,16 @@ void CefBrowserInfoManager::WebContentsCreated(
|
|||||||
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
|
std::unique_ptr<CefBrowserPlatformDelegate>& platform_delegate,
|
||||||
CefRefPtr<CefDictionaryValue>& extra_info) {
|
CefRefPtr<CefDictionaryValue>& extra_info) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
|
// GET_CUSTOM_WEB_CONTENTS_VIEW is only used with the alloy runtime.
|
||||||
|
const auto previous_step =
|
||||||
|
cef::IsAlloyRuntimeEnabled()
|
||||||
|
? CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW
|
||||||
|
: CefBrowserInfoManager::PendingPopup::CAN_CREATE_WINDOW;
|
||||||
|
|
||||||
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
std::unique_ptr<CefBrowserInfoManager::PendingPopup> pending_popup =
|
||||||
PopPendingPopup(
|
PopPendingPopup(previous_step, opener_render_process_id,
|
||||||
CefBrowserInfoManager::PendingPopup::GET_CUSTOM_WEB_CONTENTS_VIEW,
|
opener_render_routing_id, target_url);
|
||||||
opener_render_process_id, opener_render_routing_id, target_url);
|
|
||||||
DCHECK(pending_popup.get());
|
DCHECK(pending_popup.get());
|
||||||
DCHECK(pending_popup->platform_delegate.get());
|
DCHECK(pending_popup->platform_delegate.get());
|
||||||
|
|
||||||
@ -365,29 +367,18 @@ CefBrowserInfoManager::GetBrowserInfoForFrameRoute(int render_process_id,
|
|||||||
bool CefBrowserInfoManager::MaybeAllowNavigation(
|
bool CefBrowserInfoManager::MaybeAllowNavigation(
|
||||||
content::RenderFrameHost* opener,
|
content::RenderFrameHost* opener,
|
||||||
const content::OpenURLParams& params,
|
const content::OpenURLParams& params,
|
||||||
CefRefPtr<AlloyBrowserHostImpl>& browser_out) const {
|
CefRefPtr<CefBrowserHostBase>& browser_out) const {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
|
|
||||||
bool is_guest_view = false;
|
bool is_guest_view = false;
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser = static_cast<AlloyBrowserHostImpl*>(
|
auto browser = extensions::GetOwnerBrowserForHost(opener, &is_guest_view);
|
||||||
extensions::GetOwnerBrowserForHost(opener, &is_guest_view).get());
|
|
||||||
if (!browser) {
|
if (!browser) {
|
||||||
// Print preview uses a modal dialog where we don't own the WebContents.
|
// Print preview uses a modal dialog where we don't own the WebContents.
|
||||||
// Allow that navigation to proceed.
|
// Allow that navigation to proceed.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_guest_view && !params.url.SchemeIs(extensions::kExtensionScheme) &&
|
if (!browser->MaybeAllowNavigation(opener, is_guest_view, params)) {
|
||||||
!params.url.SchemeIs(content::kChromeUIScheme)) {
|
|
||||||
// The PDF viewer will load the PDF extension in the guest view, and print
|
|
||||||
// preview will load chrome://print in the guest view. All other navigations
|
|
||||||
// are passed to the owner browser.
|
|
||||||
CEF_POST_TASK(
|
|
||||||
CEF_UIT,
|
|
||||||
base::Bind(base::IgnoreResult(&AlloyBrowserHostImpl::OpenURLFromTab),
|
|
||||||
browser.get(), nullptr, params));
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ class Message;
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CefBrowserHostBase;
|
class CefBrowserHostBase;
|
||||||
class AlloyBrowserHostImpl;
|
|
||||||
class CefBrowserPlatformDelegate;
|
class CefBrowserPlatformDelegate;
|
||||||
|
|
||||||
// Singleton object for managing BrowserInfo instances.
|
// Singleton object for managing BrowserInfo instances.
|
||||||
@ -50,15 +49,14 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
// Returns this singleton instance of this class.
|
// Returns this singleton instance of this class.
|
||||||
static CefBrowserInfoManager* GetInstance();
|
static CefBrowserInfoManager* GetInstance();
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::Create or
|
// Called immediately before a new CefBrowserHost implementation is created
|
||||||
// ChromeBrowserDelegate::SetAsDelegate when a new browser is being created
|
|
||||||
// directly. In this case |is_popup| will be true only for DevTools browsers.
|
// directly. In this case |is_popup| will be true only for DevTools browsers.
|
||||||
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
|
scoped_refptr<CefBrowserInfo> CreateBrowserInfo(
|
||||||
bool is_popup,
|
bool is_popup,
|
||||||
bool is_windowless,
|
bool is_windowless,
|
||||||
CefRefPtr<CefDictionaryValue> extra_info);
|
CefRefPtr<CefDictionaryValue> extra_info);
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::WebContentsCreated when a new browser is
|
// Called from WebContentsDelegate::WebContentsCreated when a new browser is
|
||||||
// being created for a traditional popup (e.g. window.open() or targeted
|
// being created for a traditional popup (e.g. window.open() or targeted
|
||||||
// link). If any OnGetNewBrowserInfo requests are pending for the popup the
|
// link). If any OnGetNewBrowserInfo requests are pending for the popup the
|
||||||
// response will be sent when this method is called.
|
// response will be sent when this method is called.
|
||||||
@ -67,7 +65,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
bool is_windowless,
|
bool is_windowless,
|
||||||
CefRefPtr<CefDictionaryValue> extra_info);
|
CefRefPtr<CefDictionaryValue> extra_info);
|
||||||
|
|
||||||
// Called from AlloyContentBrowserClient::CanCreateWindow. See comments on
|
// Called from ContentBrowserClient::CanCreateWindow. See comments on
|
||||||
// PendingPopup for more information.
|
// PendingPopup for more information.
|
||||||
bool CanCreateWindow(content::RenderFrameHost* opener,
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
@ -79,8 +77,8 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
bool opener_suppressed,
|
bool opener_suppressed,
|
||||||
bool* no_javascript_access);
|
bool* no_javascript_access);
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::GetCustomWebContentsView. See comments on
|
// Called from WebContentsDelegate::GetCustomWebContentsView (alloy runtime
|
||||||
// PendingPopup for more information.
|
// only). See comments on PendingPopup for more information.
|
||||||
void GetCustomWebContentsView(
|
void GetCustomWebContentsView(
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
int opener_render_process_id,
|
int opener_render_process_id,
|
||||||
@ -88,7 +86,7 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
content::WebContentsView** view,
|
content::WebContentsView** view,
|
||||||
content::RenderViewHostDelegateView** delegate_view);
|
content::RenderViewHostDelegateView** delegate_view);
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::WebContentsCreated. See comments on
|
// Called from WebContentsDelegate::WebContentsCreated. See comments on
|
||||||
// PendingPopup for more information.
|
// PendingPopup for more information.
|
||||||
void WebContentsCreated(
|
void WebContentsCreated(
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
@ -147,23 +145,24 @@ class CefBrowserInfoManager : public content::RenderProcessHostObserver {
|
|||||||
// |browser| will be set to the target browser if any.
|
// |browser| will be set to the target browser if any.
|
||||||
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
bool MaybeAllowNavigation(content::RenderFrameHost* opener,
|
||||||
const content::OpenURLParams& params,
|
const content::OpenURLParams& params,
|
||||||
CefRefPtr<AlloyBrowserHostImpl>& browser) const;
|
CefRefPtr<CefBrowserHostBase>& browser) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// RenderProcessHostObserver methods:
|
// RenderProcessHostObserver methods:
|
||||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||||
|
|
||||||
// Store state information about pending popups. Call order is:
|
// Store state information about pending popups. Call order is:
|
||||||
// - AlloyContentBrowserClient::CanCreateWindow (UIT)
|
// - CanCreateWindow (UIT):
|
||||||
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
|
// Provides an opportunity to cancel the popup (calls OnBeforePopup) and
|
||||||
// creates the new platform delegate for the popup. If the popup owner is
|
// creates the new platform delegate for the popup. If the popup owner is
|
||||||
// an extension guest view then the popup is canceled and
|
// an extension guest view then the popup is canceled and
|
||||||
// AlloyBrowserHostImpl::OpenURLFromTab is called.
|
// WebContentsDelegate::OpenURLFromTab is called via the
|
||||||
|
// CefBrowserHostBase::MaybeAllowNavigation implementation.
|
||||||
// And then the following calls may occur at the same time:
|
// And then the following calls may occur at the same time:
|
||||||
// - AlloyBrowserHostImpl::GetCustomWebContentsView (UIT)
|
// - GetCustomWebContentsView (UIT) (alloy runtime only):
|
||||||
// Creates the OSR views for windowless popups.
|
// Creates the OSR views for windowless popups.
|
||||||
// - AlloyBrowserHostImpl::WebContentsCreated (UIT)
|
// - WebContentsCreated (UIT):
|
||||||
// Creates the AlloyBrowserHostImpl representation for the popup.
|
// Creates the CefBrowserHost representation for the popup.
|
||||||
// - CefBrowserMessageFilter::OnGetNewBrowserInfo (IOT)
|
// - CefBrowserMessageFilter::OnGetNewBrowserInfo (IOT)
|
||||||
// Passes information about the popup to the renderer process.
|
// Passes information about the popup to the renderer process.
|
||||||
struct PendingPopup {
|
struct PendingPopup {
|
||||||
|
@ -14,6 +14,13 @@ CefBrowserPlatformDelegate::~CefBrowserPlatformDelegate() {
|
|||||||
DCHECK(!browser_);
|
DCHECK(!browser_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::WebContents* CefBrowserPlatformDelegate::CreateWebContents(
|
||||||
|
CefBrowserCreateParams& create_params,
|
||||||
|
bool& own_web_contents) {
|
||||||
|
NOTREACHED();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
void CefBrowserPlatformDelegate::CreateViewForWebContents(
|
||||||
content::WebContentsView** view,
|
content::WebContentsView** view,
|
||||||
content::RenderViewHostDelegateView** delegate_view) {
|
content::RenderViewHostDelegateView** delegate_view) {
|
||||||
@ -57,7 +64,7 @@ void CefBrowserPlatformDelegate::RenderViewCreated(
|
|||||||
|
|
||||||
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
void CefBrowserPlatformDelegate::RenderViewReady() {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::BrowserCreated(AlloyBrowserHostImpl* browser) {
|
void CefBrowserPlatformDelegate::BrowserCreated(CefBrowserHostBase* browser) {
|
||||||
// We should have an associated WebContents at this point.
|
// We should have an associated WebContents at this point.
|
||||||
DCHECK(web_contents_);
|
DCHECK(web_contents_);
|
||||||
|
|
||||||
@ -83,8 +90,7 @@ void CefBrowserPlatformDelegate::NotifyBrowserCreated() {}
|
|||||||
|
|
||||||
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
void CefBrowserPlatformDelegate::NotifyBrowserDestroyed() {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::BrowserDestroyed(
|
void CefBrowserPlatformDelegate::BrowserDestroyed(CefBrowserHostBase* browser) {
|
||||||
AlloyBrowserHostImpl* browser) {
|
|
||||||
// WebContentsDestroyed should already be called.
|
// WebContentsDestroyed should already be called.
|
||||||
DCHECK(!web_contents_);
|
DCHECK(!web_contents_);
|
||||||
|
|
||||||
@ -101,6 +107,11 @@ void CefBrowserPlatformDelegate::CloseHostWindow() {
|
|||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefWindowHandle CefBrowserPlatformDelegate::GetHostWindowHandle() const {
|
||||||
|
NOTREACHED();
|
||||||
|
return kNullWindowHandle;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
#if defined(USE_AURA)
|
||||||
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
views::Widget* CefBrowserPlatformDelegate::GetWindowWidget() const {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
@ -121,9 +132,49 @@ void CefBrowserPlatformDelegate::PopupWebContentsCreated(
|
|||||||
bool is_devtools) {}
|
bool is_devtools) {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
void CefBrowserPlatformDelegate::PopupBrowserCreated(
|
||||||
AlloyBrowserHostImpl* new_browser,
|
CefBrowserHostBase* new_browser,
|
||||||
bool is_devtools) {}
|
bool is_devtools) {}
|
||||||
|
|
||||||
|
SkColor CefBrowserPlatformDelegate::GetBackgroundColor() const {
|
||||||
|
NOTREACHED();
|
||||||
|
return SkColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::WasResized() {
|
||||||
|
NOTREACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendKeyEvent(const CefKeyEvent& event) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendMouseClickEvent(
|
||||||
|
const CefMouseEvent& event,
|
||||||
|
CefBrowserHost::MouseButtonType type,
|
||||||
|
bool mouseUp,
|
||||||
|
int clickCount) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendMouseMoveEvent(const CefMouseEvent& event,
|
||||||
|
bool mouseLeave) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendMouseWheelEvent(const CefMouseEvent& event,
|
||||||
|
int deltaX,
|
||||||
|
int deltaY) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendTouchEvent(const CefTouchEvent& event) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::SendFocusEvent(bool setFocus) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
|
void CefBrowserPlatformDelegate::SendCaptureLostEvent() {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
}
|
}
|
||||||
@ -134,6 +185,22 @@ void CefBrowserPlatformDelegate::NotifyMoveOrResizeStarted() {}
|
|||||||
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
void CefBrowserPlatformDelegate::SizeTo(int width, int height) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
gfx::Point CefBrowserPlatformDelegate::GetScreenPoint(
|
||||||
|
const gfx::Point& view) const {
|
||||||
|
NOTREACHED();
|
||||||
|
return gfx::Point();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegate::ViewText(const std::string& text) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserPlatformDelegate::HandleKeyboardEvent(
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
NOTREACHED();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
|
bool CefBrowserPlatformDelegate::PreHandleGestureEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const blink::WebGestureEvent& event) {
|
const blink::WebGestureEvent& event) {
|
||||||
@ -145,6 +212,12 @@ bool CefBrowserPlatformDelegate::IsNeverComposited(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefEventHandle CefBrowserPlatformDelegate::GetEventHandle(
|
||||||
|
const content::NativeWebKeyboardEvent& event) const {
|
||||||
|
NOTREACHED();
|
||||||
|
return kNullEventHandle;
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<CefFileDialogRunner>
|
std::unique_ptr<CefFileDialogRunner>
|
||||||
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
CefBrowserPlatformDelegate::CreateFileDialogRunner() {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
@ -157,6 +230,19 @@ CefBrowserPlatformDelegate::CreateJavaScriptDialogRunner() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<CefMenuRunner> CefBrowserPlatformDelegate::CreateMenuRunner() {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserPlatformDelegate::IsWindowless() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefBrowserPlatformDelegate::IsViewsHosted() const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
void CefBrowserPlatformDelegate::WasHidden(bool hidden) {
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,17 @@
|
|||||||
#include "include/cef_drag_data.h"
|
#include "include/cef_drag_data.h"
|
||||||
#include "include/internal/cef_types.h"
|
#include "include/internal/cef_types.h"
|
||||||
#include "include/views/cef_browser_view.h"
|
#include "include/views/cef_browser_view.h"
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
|
|
||||||
#include "base/callback_forward.h"
|
#include "base/callback_forward.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "extensions/common/view_type.h"
|
||||||
|
#include "third_party/blink/public/common/page/web_drag_operation.h"
|
||||||
|
#include "third_party/skia/include/core/SkColor.h"
|
||||||
|
#include "ui/base/window_open_disposition.h"
|
||||||
|
|
||||||
|
class GURL;
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
|
class WebGestureEvent;
|
||||||
class WebMouseEvent;
|
class WebMouseEvent;
|
||||||
class WebMouseWheelEvent;
|
class WebMouseWheelEvent;
|
||||||
class WebInputEvent;
|
class WebInputEvent;
|
||||||
@ -26,15 +31,30 @@ class WebTouchEvent;
|
|||||||
} // namespace blink
|
} // namespace blink
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
|
struct AXEventNotificationDetails;
|
||||||
|
struct AXLocationChangeNotificationDetails;
|
||||||
|
struct DragEventSourceInfo;
|
||||||
|
struct DropData;
|
||||||
struct NativeWebKeyboardEvent;
|
struct NativeWebKeyboardEvent;
|
||||||
class RenderViewHost;
|
class RenderViewHost;
|
||||||
class RenderViewHostDelegateView;
|
class RenderViewHostDelegateView;
|
||||||
|
class RenderWidgetHostImpl;
|
||||||
|
class WebContents;
|
||||||
class WebContentsView;
|
class WebContentsView;
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
|
||||||
namespace extensions {
|
namespace extensions {
|
||||||
|
class Extension;
|
||||||
class ExtensionHost;
|
class ExtensionHost;
|
||||||
}
|
} // namespace extensions
|
||||||
|
|
||||||
|
namespace gfx {
|
||||||
|
class ImageSkia;
|
||||||
|
class Point;
|
||||||
|
class Rect;
|
||||||
|
class Size;
|
||||||
|
class Vector2d;
|
||||||
|
} // namespace gfx
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
#if defined(USE_AURA)
|
||||||
namespace views {
|
namespace views {
|
||||||
@ -42,6 +62,8 @@ class Widget;
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
struct CefBrowserCreateParams;
|
||||||
|
class CefBrowserHostBase;
|
||||||
class CefFileDialogRunner;
|
class CefFileDialogRunner;
|
||||||
class CefJavaScriptDialogRunner;
|
class CefJavaScriptDialogRunner;
|
||||||
class CefMenuRunner;
|
class CefMenuRunner;
|
||||||
@ -54,14 +76,14 @@ class CefBrowserPlatformDelegate {
|
|||||||
// Create a new CefBrowserPlatformDelegate instance. May be called on multiple
|
// Create a new CefBrowserPlatformDelegate instance. May be called on multiple
|
||||||
// threads.
|
// threads.
|
||||||
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
|
static std::unique_ptr<CefBrowserPlatformDelegate> Create(
|
||||||
CefBrowserHostBase::CreateParams& create_params);
|
const CefBrowserCreateParams& create_params);
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::Create.
|
// Called from AlloyBrowserHostImpl::Create.
|
||||||
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
|
// Wait for the call to WebContentsCreated(owned=true) before taking ownership
|
||||||
// of the resulting WebContents object.
|
// of the resulting WebContents object.
|
||||||
virtual content::WebContents* CreateWebContents(
|
virtual content::WebContents* CreateWebContents(
|
||||||
CefBrowserHostBase::CreateParams& create_params,
|
CefBrowserCreateParams& create_params,
|
||||||
bool& own_web_contents) = 0;
|
bool& own_web_contents);
|
||||||
|
|
||||||
// Called to create the view objects for a new WebContents. Will only be
|
// 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
|
// called a single time per instance. May be called on multiple threads. Only
|
||||||
@ -106,7 +128,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
// Called after the owning AlloyBrowserHostImpl is created. Will only be
|
// Called after the owning AlloyBrowserHostImpl is created. Will only be
|
||||||
// called a single time per instance. Do not send any client notifications
|
// called a single time per instance. Do not send any client notifications
|
||||||
// from this method.
|
// from this method.
|
||||||
virtual void BrowserCreated(AlloyBrowserHostImpl* browser);
|
virtual void BrowserCreated(CefBrowserHostBase* browser);
|
||||||
|
|
||||||
// Called from AlloyBrowserHostImpl::Create.
|
// Called from AlloyBrowserHostImpl::Create.
|
||||||
virtual void CreateExtensionHost(const extensions::Extension* extension,
|
virtual void CreateExtensionHost(const extensions::Extension* extension,
|
||||||
@ -128,7 +150,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
// called a single time per instance. All references to the
|
// called a single time per instance. All references to the
|
||||||
// AlloyBrowserHostImpl and WebContents should be cleared when this method is
|
// AlloyBrowserHostImpl and WebContents should be cleared when this method is
|
||||||
// called. Do not send any client notifications from this method.
|
// called. Do not send any client notifications from this method.
|
||||||
virtual void BrowserDestroyed(AlloyBrowserHostImpl* browser);
|
virtual void BrowserDestroyed(CefBrowserHostBase* browser);
|
||||||
|
|
||||||
// Create the window that hosts the browser. Will only be called a single time
|
// Create the window that hosts the browser. Will only be called a single time
|
||||||
// per instance. Only used with windowed rendering.
|
// per instance. Only used with windowed rendering.
|
||||||
@ -143,7 +165,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
// rendering this will return the most immediate parent window handle. For
|
// rendering this will return the most immediate parent window handle. For
|
||||||
// windowless rendering this will return the parent window handle specified by
|
// windowless rendering this will return the parent window handle specified by
|
||||||
// the client, which may be NULL. May be called on multiple threads.
|
// the client, which may be NULL. May be called on multiple threads.
|
||||||
virtual CefWindowHandle GetHostWindowHandle() const = 0;
|
virtual CefWindowHandle GetHostWindowHandle() const;
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
#if defined(USE_AURA)
|
||||||
// Returns the Widget owner for the browser window. Only used with windowed
|
// Returns the Widget owner for the browser window. Only used with windowed
|
||||||
@ -174,7 +196,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
|
// CefLifeSpanHandler::OnAfterCreated() for the popup browser. It is safe to
|
||||||
// make the new browser visible in this callback (for example, add the browser
|
// make the new browser visible in this callback (for example, add the browser
|
||||||
// to a window and show it).
|
// to a window and show it).
|
||||||
virtual void PopupBrowserCreated(AlloyBrowserHostImpl* new_browser,
|
virtual void PopupBrowserCreated(CefBrowserHostBase* new_browser,
|
||||||
bool is_devtools);
|
bool is_devtools);
|
||||||
|
|
||||||
// Returns the background color for the browser. The alpha component will be
|
// Returns the background color for the browser. The alpha component will be
|
||||||
@ -182,27 +204,26 @@ class CefBrowserPlatformDelegate {
|
|||||||
// fully opaque). SK_AlphaOPAQUE will always be returned for windowed
|
// fully opaque). SK_AlphaOPAQUE will always be returned for windowed
|
||||||
// browsers. SK_ColorTRANSPARENT may be returned for windowless browsers to
|
// browsers. SK_ColorTRANSPARENT may be returned for windowless browsers to
|
||||||
// enable transparency.
|
// enable transparency.
|
||||||
virtual SkColor GetBackgroundColor() const = 0;
|
virtual SkColor GetBackgroundColor() const;
|
||||||
|
|
||||||
// Notify the window that it was resized.
|
// Notify the window that it was resized.
|
||||||
virtual void WasResized() = 0;
|
virtual void WasResized();
|
||||||
|
|
||||||
// Send input events.
|
// Send input events.
|
||||||
virtual void SendKeyEvent(const CefKeyEvent& event) = 0;
|
virtual void SendKeyEvent(const CefKeyEvent& event);
|
||||||
virtual void SendMouseClickEvent(const CefMouseEvent& event,
|
virtual void SendMouseClickEvent(const CefMouseEvent& event,
|
||||||
CefBrowserHost::MouseButtonType type,
|
CefBrowserHost::MouseButtonType type,
|
||||||
bool mouseUp,
|
bool mouseUp,
|
||||||
int clickCount) = 0;
|
int clickCount);
|
||||||
virtual void SendMouseMoveEvent(const CefMouseEvent& event,
|
virtual void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave);
|
||||||
bool mouseLeave) = 0;
|
|
||||||
virtual void SendMouseWheelEvent(const CefMouseEvent& event,
|
virtual void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||||
int deltaX,
|
int deltaX,
|
||||||
int deltaY) = 0;
|
int deltaY);
|
||||||
virtual void SendTouchEvent(const CefTouchEvent& event) = 0;
|
virtual void SendTouchEvent(const CefTouchEvent& event);
|
||||||
|
|
||||||
// Send focus event. The browser's WebContents may be NULL when this method is
|
// Send focus event. The browser's WebContents may be NULL when this method is
|
||||||
// called.
|
// called.
|
||||||
virtual void SendFocusEvent(bool setFocus) = 0;
|
virtual void SendFocusEvent(bool setFocus);
|
||||||
|
|
||||||
// Send capture lost event.
|
// Send capture lost event.
|
||||||
virtual void SendCaptureLostEvent();
|
virtual void SendCaptureLostEvent();
|
||||||
@ -219,15 +240,15 @@ class CefBrowserPlatformDelegate {
|
|||||||
|
|
||||||
// Convert from view coordinates to screen coordinates. Potential display
|
// Convert from view coordinates to screen coordinates. Potential display
|
||||||
// scaling will be applied to the result.
|
// scaling will be applied to the result.
|
||||||
virtual gfx::Point GetScreenPoint(const gfx::Point& view) const = 0;
|
virtual gfx::Point GetScreenPoint(const gfx::Point& view) const;
|
||||||
|
|
||||||
// Open the specified text in the default text editor.
|
// Open the specified text in the default text editor.
|
||||||
virtual void ViewText(const std::string& text) = 0;
|
virtual void ViewText(const std::string& text);
|
||||||
|
|
||||||
// Forward the keyboard event to the application or frame window to allow
|
// Forward the keyboard event to the application or frame window to allow
|
||||||
// processing of shortcut keys.
|
// processing of shortcut keys.
|
||||||
virtual bool HandleKeyboardEvent(
|
virtual bool HandleKeyboardEvent(
|
||||||
const content::NativeWebKeyboardEvent& event) = 0;
|
const content::NativeWebKeyboardEvent& event);
|
||||||
|
|
||||||
// See WebContentsDelegate documentation.
|
// See WebContentsDelegate documentation.
|
||||||
virtual bool PreHandleGestureEvent(content::WebContents* source,
|
virtual bool PreHandleGestureEvent(content::WebContents* source,
|
||||||
@ -241,7 +262,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
|
|
||||||
// Returns the OS event handle, if any, associated with |event|.
|
// Returns the OS event handle, if any, associated with |event|.
|
||||||
virtual CefEventHandle GetEventHandle(
|
virtual CefEventHandle GetEventHandle(
|
||||||
const content::NativeWebKeyboardEvent& event) const = 0;
|
const content::NativeWebKeyboardEvent& event) const;
|
||||||
|
|
||||||
// Create the platform-specific file dialog runner.
|
// Create the platform-specific file dialog runner.
|
||||||
virtual std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner();
|
virtual std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner();
|
||||||
@ -251,15 +272,15 @@ class CefBrowserPlatformDelegate {
|
|||||||
CreateJavaScriptDialogRunner();
|
CreateJavaScriptDialogRunner();
|
||||||
|
|
||||||
// Create the platform-specific menu runner.
|
// Create the platform-specific menu runner.
|
||||||
virtual std::unique_ptr<CefMenuRunner> CreateMenuRunner() = 0;
|
virtual std::unique_ptr<CefMenuRunner> CreateMenuRunner();
|
||||||
|
|
||||||
// Returns true if this delegate implements windowless rendering. May be
|
// Returns true if this delegate implements windowless rendering. May be
|
||||||
// called on multiple threads.
|
// called on multiple threads.
|
||||||
virtual bool IsWindowless() const = 0;
|
virtual bool IsWindowless() const;
|
||||||
|
|
||||||
// Returns true if this delegate implements views-hosted browser handling. May
|
// Returns true if this delegate implements views-hosted browser handling. May
|
||||||
// be called on multiple threads.
|
// be called on multiple threads.
|
||||||
virtual bool IsViewsHosted() const = 0;
|
virtual bool IsViewsHosted() const;
|
||||||
|
|
||||||
// Notify the browser that it was hidden. Only used with windowless rendering.
|
// Notify the browser that it was hidden. Only used with windowless rendering.
|
||||||
virtual void WasHidden(bool hidden);
|
virtual void WasHidden(bool hidden);
|
||||||
@ -343,7 +364,7 @@ class CefBrowserPlatformDelegate {
|
|||||||
|
|
||||||
// Not owned by this object.
|
// Not owned by this object.
|
||||||
content::WebContents* web_contents_ = nullptr;
|
content::WebContents* web_contents_ = nullptr;
|
||||||
AlloyBrowserHostImpl* browser_ = nullptr;
|
CefBrowserHostBase* browser_ = nullptr;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserPlatformDelegate);
|
||||||
};
|
};
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_host_base.h"
|
||||||
|
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||||
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
|
#include "libcef/browser/extensions/browser_platform_delegate_background.h"
|
||||||
#include "libcef/features/runtime_checks.h"
|
#include "libcef/features/runtime_checks.h"
|
||||||
|
|
||||||
@ -68,7 +70,7 @@ std::unique_ptr<CefBrowserPlatformDelegateOsr> CreateOSRDelegate(
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
||||||
CefBrowserHostBase::CreateParams& create_params) {
|
const CefBrowserCreateParams& create_params) {
|
||||||
const bool is_windowless =
|
const bool is_windowless =
|
||||||
create_params.window_info &&
|
create_params.window_info &&
|
||||||
create_params.window_info->windowless_rendering_enabled &&
|
create_params.window_info->windowless_rendering_enabled &&
|
||||||
@ -76,6 +78,14 @@ std::unique_ptr<CefBrowserPlatformDelegate> CefBrowserPlatformDelegate::Create(
|
|||||||
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
|
const SkColor background_color = CefContext::Get()->GetBackgroundColor(
|
||||||
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
|
&create_params.settings, is_windowless ? STATE_ENABLED : STATE_DISABLED);
|
||||||
|
|
||||||
|
if (cef::IsChromeRuntimeEnabled()) {
|
||||||
|
// CefWindowInfo is not used in this case.
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||||
|
CreateNativeDelegate(CefWindowInfo(), background_color);
|
||||||
|
return std::make_unique<CefBrowserPlatformDelegateChrome>(
|
||||||
|
std::move(native_delegate));
|
||||||
|
}
|
||||||
|
|
||||||
if (create_params.window_info) {
|
if (create_params.window_info) {
|
||||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate =
|
||||||
CreateNativeDelegate(*create_params.window_info.get(),
|
CreateNativeDelegate(*create_params.window_info.get(),
|
||||||
|
@ -35,6 +35,9 @@ class BrowserDelegate : public content::WebContentsDelegate {
|
|||||||
|
|
||||||
~BrowserDelegate() override {}
|
~BrowserDelegate() override {}
|
||||||
|
|
||||||
|
// Called immediately after |new_contents| is created.
|
||||||
|
virtual void OnWebContentsCreated(content::WebContents* new_contents) = 0;
|
||||||
|
|
||||||
// Add or remove ownership of the WebContents.
|
// Add or remove ownership of the WebContents.
|
||||||
virtual void SetAsDelegate(content::WebContents* web_contents,
|
virtual void SetAsDelegate(content::WebContents* web_contents,
|
||||||
bool set_delegate) = 0;
|
bool set_delegate) = 0;
|
||||||
|
101
libcef/browser/chrome/browser_platform_delegate_chrome.cc
Normal file
101
libcef/browser/chrome/browser_platform_delegate_chrome.cc
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// Copyright 2020 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/chrome/browser_platform_delegate_chrome.h"
|
||||||
|
|
||||||
|
#include "chrome/browser/ui/browser.h"
|
||||||
|
#include "chrome/browser/ui/browser_window.h"
|
||||||
|
#include "ui/display/screen.h"
|
||||||
|
#include "ui/gfx/geometry/point.h"
|
||||||
|
|
||||||
|
CefBrowserPlatformDelegateChrome::CefBrowserPlatformDelegateChrome(
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
|
||||||
|
: native_delegate_(std::move(native_delegate)) {
|
||||||
|
native_delegate_->set_windowless_handler(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::WebContentsCreated(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
bool owned) {
|
||||||
|
CefBrowserPlatformDelegate::WebContentsCreated(web_contents, owned);
|
||||||
|
native_delegate_->WebContentsCreated(web_contents, /*owned=*/false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::WebContentsDestroyed(
|
||||||
|
content::WebContents* web_contents) {
|
||||||
|
CefBrowserPlatformDelegate::WebContentsDestroyed(web_contents);
|
||||||
|
native_delegate_->WebContentsDestroyed(web_contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::BrowserCreated(
|
||||||
|
CefBrowserHostBase* browser) {
|
||||||
|
CefBrowserPlatformDelegate::BrowserCreated(browser);
|
||||||
|
native_delegate_->BrowserCreated(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::BrowserDestroyed(
|
||||||
|
CefBrowserHostBase* browser) {
|
||||||
|
CefBrowserPlatformDelegate::BrowserDestroyed(browser);
|
||||||
|
native_delegate_->BrowserDestroyed(browser);
|
||||||
|
}
|
||||||
|
|
||||||
|
SkColor CefBrowserPlatformDelegateChrome::GetBackgroundColor() const {
|
||||||
|
return native_delegate_->GetBackgroundColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::SendKeyEvent(const CefKeyEvent& event) {
|
||||||
|
native_delegate_->SendKeyEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::SendMouseClickEvent(
|
||||||
|
const CefMouseEvent& event,
|
||||||
|
CefBrowserHost::MouseButtonType type,
|
||||||
|
bool mouseUp,
|
||||||
|
int clickCount) {
|
||||||
|
native_delegate_->SendMouseClickEvent(event, type, mouseUp, clickCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::SendMouseMoveEvent(
|
||||||
|
const CefMouseEvent& event,
|
||||||
|
bool mouseLeave) {
|
||||||
|
native_delegate_->SendMouseMoveEvent(event, mouseLeave);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::SendMouseWheelEvent(
|
||||||
|
const CefMouseEvent& event,
|
||||||
|
int deltaX,
|
||||||
|
int deltaY) {
|
||||||
|
native_delegate_->SendMouseWheelEvent(event, deltaX, deltaY);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::Point CefBrowserPlatformDelegateChrome::GetScreenPoint(
|
||||||
|
const gfx::Point& view) const {
|
||||||
|
auto screen = display::Screen::GetScreen();
|
||||||
|
|
||||||
|
gfx::NativeWindow native_window =
|
||||||
|
chrome_browser_ ? chrome_browser_->window()->GetNativeWindow() : nullptr;
|
||||||
|
|
||||||
|
// Returns screen pixel coordinates.
|
||||||
|
auto screen_rect = screen->DIPToScreenRectInWindow(
|
||||||
|
native_window, gfx::Rect(view, gfx::Size(0, 0)));
|
||||||
|
return screen_rect.origin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::ViewText(const std::string& text) {
|
||||||
|
native_delegate_->ViewText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefWindowHandle CefBrowserPlatformDelegateChrome::GetParentWindowHandle()
|
||||||
|
const {
|
||||||
|
return GetHostWindowHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::Point CefBrowserPlatformDelegateChrome::GetParentScreenPoint(
|
||||||
|
const gfx::Point& view) const {
|
||||||
|
return GetScreenPoint(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserPlatformDelegateChrome::set_chrome_browser(Browser* browser) {
|
||||||
|
chrome_browser_ = browser;
|
||||||
|
}
|
52
libcef/browser/chrome/browser_platform_delegate_chrome.h
Normal file
52
libcef/browser/chrome/browser_platform_delegate_chrome.h
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
|
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||||
|
|
||||||
|
class Browser;
|
||||||
|
|
||||||
|
// Implementation of Chrome-based browser functionality.
|
||||||
|
class CefBrowserPlatformDelegateChrome
|
||||||
|
: public CefBrowserPlatformDelegate,
|
||||||
|
public CefBrowserPlatformDelegateNative::WindowlessHandler {
|
||||||
|
public:
|
||||||
|
explicit CefBrowserPlatformDelegateChrome(
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate);
|
||||||
|
|
||||||
|
// CefBrowserPlatformDelegate overrides.
|
||||||
|
void WebContentsCreated(content::WebContents* web_contents,
|
||||||
|
bool owned) override;
|
||||||
|
void WebContentsDestroyed(content::WebContents* web_contents) override;
|
||||||
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||||
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
|
SkColor GetBackgroundColor() const override;
|
||||||
|
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||||
|
void SendMouseClickEvent(const CefMouseEvent& event,
|
||||||
|
CefBrowserHost::MouseButtonType type,
|
||||||
|
bool mouseUp,
|
||||||
|
int clickCount) override;
|
||||||
|
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
||||||
|
void SendMouseWheelEvent(const CefMouseEvent& event,
|
||||||
|
int deltaX,
|
||||||
|
int deltaY) override;
|
||||||
|
gfx::Point GetScreenPoint(const gfx::Point& view) const override;
|
||||||
|
void ViewText(const std::string& text) override;
|
||||||
|
|
||||||
|
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||||
|
CefWindowHandle GetParentWindowHandle() const override;
|
||||||
|
gfx::Point GetParentScreenPoint(const gfx::Point& view) const override;
|
||||||
|
|
||||||
|
void set_chrome_browser(Browser* browser);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate_;
|
||||||
|
|
||||||
|
Browser* chrome_browser_ = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_CHROME_BROWSER_PLATFORM_DELEGATE_CHROME_H_
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "libcef/browser/chrome/chrome_browser_context.h"
|
#include "libcef/browser/chrome/chrome_browser_context.h"
|
||||||
|
|
||||||
|
#include "libcef/browser/prefs/browser_prefs.h"
|
||||||
|
|
||||||
#include "chrome/browser/profiles/profile_manager.h"
|
#include "chrome/browser/profiles/profile_manager.h"
|
||||||
|
|
||||||
ChromeBrowserContext::ChromeBrowserContext(
|
ChromeBrowserContext::ChromeBrowserContext(
|
||||||
@ -28,6 +30,8 @@ void ChromeBrowserContext::Initialize() {
|
|||||||
// The global ProfileManager instance can be retrieved via
|
// The global ProfileManager instance can be retrieved via
|
||||||
// |g_browser_process->profile_manager()|.
|
// |g_browser_process->profile_manager()|.
|
||||||
profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
|
profile_ = ProfileManager::GetLastUsedProfileAllowedByPolicy();
|
||||||
|
|
||||||
|
browser_prefs::SetLanguagePrefs(profile_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserContext::Shutdown() {
|
void ChromeBrowserContext::Shutdown() {
|
||||||
|
@ -9,22 +9,36 @@
|
|||||||
#include "libcef/browser/browser_contents_delegate.h"
|
#include "libcef/browser/browser_contents_delegate.h"
|
||||||
#include "libcef/browser/browser_host_base.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/browser_info_manager.h"
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||||
#include "libcef/browser/request_context_impl.h"
|
#include "libcef/browser/request_context_impl.h"
|
||||||
#include "libcef/common/app_manager.h"
|
#include "libcef/common/app_manager.h"
|
||||||
|
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "chrome/browser/ui/browser.h"
|
#include "chrome/browser/ui/browser.h"
|
||||||
|
#include "content/public/browser/keyboard_event_processing_result.h"
|
||||||
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
|
|
||||||
|
using content::KeyboardEventProcessingResult;
|
||||||
|
|
||||||
ChromeBrowserDelegate::ChromeBrowserDelegate(
|
ChromeBrowserDelegate::ChromeBrowserDelegate(
|
||||||
Browser* browser,
|
Browser* browser,
|
||||||
const CefBrowserHostBase::CreateParams& create_params)
|
const CefBrowserCreateParams& create_params)
|
||||||
: browser_(browser), create_params_(create_params) {
|
: browser_(browser), create_params_(create_params) {
|
||||||
DCHECK(browser_);
|
DCHECK(browser_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChromeBrowserDelegate::~ChromeBrowserDelegate() = default;
|
ChromeBrowserDelegate::~ChromeBrowserDelegate() = default;
|
||||||
|
|
||||||
|
void ChromeBrowserDelegate::OnWebContentsCreated(
|
||||||
|
content::WebContents* new_contents) {
|
||||||
|
// Necessary to receive LoadingStateChanged calls during initial navigation.
|
||||||
|
// This will be called again in Browser::SetAsDelegate, which should be fine.
|
||||||
|
new_contents->SetDelegate(browser_);
|
||||||
|
|
||||||
|
SetAsDelegate(new_contents, /*set_delegate=*/true);
|
||||||
|
}
|
||||||
|
|
||||||
void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
||||||
bool set_delegate) {
|
bool set_delegate) {
|
||||||
DCHECK(web_contents);
|
DCHECK(web_contents);
|
||||||
@ -40,37 +54,67 @@ void ChromeBrowserDelegate::SetAsDelegate(content::WebContents* web_contents,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto request_context_impl =
|
auto platform_delegate = CefBrowserPlatformDelegate::Create(create_params_);
|
||||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
CHECK(platform_delegate);
|
||||||
create_params_.request_context);
|
|
||||||
|
|
||||||
// Check if chrome and CEF are using the same browser context.
|
|
||||||
// TODO(chrome-runtime): Verify if/when this might occur.
|
|
||||||
auto chrome_browser_context =
|
|
||||||
CefBrowserContext::FromBrowserContext(browser_->create_params().profile);
|
|
||||||
if (chrome_browser_context != request_context_impl->GetBrowserContext()) {
|
|
||||||
LOG(WARNING) << "Creating a chrome browser with mismatched context";
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefClient> client = create_params_.client;
|
|
||||||
if (!client) {
|
|
||||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
|
||||||
if (auto bph = app->GetBrowserProcessHandler()) {
|
|
||||||
client = bph->GetDefaultClient();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!client) {
|
|
||||||
LOG(WARNING) << "Creating a chrome browser without a client";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto browser_info = CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
auto browser_info = CefBrowserInfoManager::GetInstance()->CreateBrowserInfo(
|
||||||
/*is_popup=*/false, /*is_windowless=*/false, create_params_.extra_info);
|
/*is_popup=*/false, /*is_windowless=*/false, create_params_.extra_info);
|
||||||
|
|
||||||
browser_host = new ChromeBrowserHostImpl(create_params_.settings, client,
|
auto request_context_impl =
|
||||||
|
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||||
|
create_params_.request_context);
|
||||||
|
|
||||||
|
CreateBrowser(web_contents, create_params_.settings, create_params_.client,
|
||||||
|
std::move(platform_delegate), browser_info,
|
||||||
|
request_context_impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeBrowserDelegate::WebContentsCreated(
|
||||||
|
content::WebContents* source_contents,
|
||||||
|
int opener_render_process_id,
|
||||||
|
int opener_render_frame_id,
|
||||||
|
const std::string& frame_name,
|
||||||
|
const GURL& target_url,
|
||||||
|
content::WebContents* new_contents) {
|
||||||
|
CefBrowserSettings settings;
|
||||||
|
CefRefPtr<CefClient> client;
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate;
|
||||||
|
CefRefPtr<CefDictionaryValue> extra_info;
|
||||||
|
|
||||||
|
CefBrowserInfoManager::GetInstance()->WebContentsCreated(
|
||||||
|
target_url, opener_render_process_id, opener_render_frame_id, settings,
|
||||||
|
client, platform_delegate, extra_info);
|
||||||
|
|
||||||
|
auto opener = ChromeBrowserHostImpl::GetBrowserForContents(source_contents);
|
||||||
|
if (!opener) {
|
||||||
|
LOG(ERROR) << "No opener found for chrome popup browser";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto browser_info =
|
||||||
|
CefBrowserInfoManager::GetInstance()->CreatePopupBrowserInfo(
|
||||||
|
new_contents, /*is_windowless=*/false, extra_info);
|
||||||
|
CHECK(browser_info->is_popup());
|
||||||
|
|
||||||
|
// Popups must share the same RequestContext as the parent.
|
||||||
|
auto request_context_impl = opener->request_context();
|
||||||
|
CHECK(request_context_impl);
|
||||||
|
|
||||||
|
// We don't officially own |new_contents| until AddNewContents() is called.
|
||||||
|
// However, we need to install observers/delegates here.
|
||||||
|
CreateBrowser(new_contents, settings, client, std::move(platform_delegate),
|
||||||
browser_info, request_context_impl);
|
browser_info, request_context_impl);
|
||||||
browser_host->Attach(browser_, web_contents);
|
}
|
||||||
|
|
||||||
|
content::WebContents* ChromeBrowserDelegate::OpenURLFromTab(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::OpenURLParams& params) {
|
||||||
|
// Return nullptr to cancel the navigation. Otherwise, proceed with default
|
||||||
|
// chrome handling.
|
||||||
|
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||||
|
return delegate->OpenURLFromTab(source, params);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserDelegate::LoadingStateChanged(content::WebContents* source,
|
void ChromeBrowserDelegate::LoadingStateChanged(content::WebContents* source,
|
||||||
@ -127,6 +171,64 @@ void ChromeBrowserDelegate::ExitFullscreenModeForTab(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardEventProcessingResult ChromeBrowserDelegate::PreHandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||||
|
return delegate->PreHandleKeyboardEvent(source, event);
|
||||||
|
}
|
||||||
|
return KeyboardEventProcessingResult::NOT_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChromeBrowserDelegate::HandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
|
if (auto delegate = GetDelegateForWebContents(source)) {
|
||||||
|
return delegate->HandleKeyboardEvent(source, event);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeBrowserDelegate::CreateBrowser(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
CefBrowserSettings settings,
|
||||||
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
|
CefRefPtr<CefRequestContextImpl> request_context_impl) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
DCHECK(web_contents);
|
||||||
|
DCHECK(platform_delegate);
|
||||||
|
DCHECK(browser_info);
|
||||||
|
DCHECK(request_context_impl);
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||||
|
if (auto bph = app->GetBrowserProcessHandler()) {
|
||||||
|
client = bph->GetDefaultClient();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!client) {
|
||||||
|
LOG(WARNING) << "Creating a chrome browser without a client";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if chrome and CEF are using the same browser context.
|
||||||
|
// TODO(chrome-runtime): Verify if/when this might occur.
|
||||||
|
auto chrome_browser_context =
|
||||||
|
CefBrowserContext::FromBrowserContext(browser_->create_params().profile);
|
||||||
|
if (chrome_browser_context != request_context_impl->GetBrowserContext()) {
|
||||||
|
LOG(WARNING) << "Creating a chrome browser with mismatched context";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remains alive until the associated WebContents is destroyed.
|
||||||
|
CefRefPtr<ChromeBrowserHostImpl> browser_host =
|
||||||
|
new ChromeBrowserHostImpl(settings, client, std::move(platform_delegate),
|
||||||
|
browser_info, request_context_impl);
|
||||||
|
browser_host->Attach(browser_, web_contents);
|
||||||
|
}
|
||||||
|
|
||||||
CefBrowserContentsDelegate* ChromeBrowserDelegate::GetDelegateForWebContents(
|
CefBrowserContentsDelegate* ChromeBrowserDelegate::GetDelegateForWebContents(
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
auto browser_host =
|
auto browser_host =
|
||||||
@ -142,7 +244,7 @@ namespace cef {
|
|||||||
std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
|
std::unique_ptr<BrowserDelegate> BrowserDelegate::Create(
|
||||||
Browser* browser,
|
Browser* browser,
|
||||||
scoped_refptr<CreateParams> cef_params) {
|
scoped_refptr<CreateParams> cef_params) {
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
|
|
||||||
// Parameters from ChromeBrowserHostImpl::Create, or nullptr if the Browser
|
// Parameters from ChromeBrowserHostImpl::Create, or nullptr if the Browser
|
||||||
// was created from somewhere else.
|
// was created from somewhere else.
|
||||||
|
@ -40,14 +40,24 @@ class ChromeBrowserHostImpl;
|
|||||||
class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
||||||
public:
|
public:
|
||||||
ChromeBrowserDelegate(Browser* browser,
|
ChromeBrowserDelegate(Browser* browser,
|
||||||
const CefBrowserHostBase::CreateParams& create_params);
|
const CefBrowserCreateParams& create_params);
|
||||||
~ChromeBrowserDelegate() override;
|
~ChromeBrowserDelegate() override;
|
||||||
|
|
||||||
// cef::BrowserDelegate methods:
|
// cef::BrowserDelegate methods:
|
||||||
|
void OnWebContentsCreated(content::WebContents* new_contents) override;
|
||||||
void SetAsDelegate(content::WebContents* web_contents,
|
void SetAsDelegate(content::WebContents* web_contents,
|
||||||
bool set_delegate) override;
|
bool set_delegate) override;
|
||||||
|
|
||||||
// WebContentsDelegate methods:
|
// WebContentsDelegate methods:
|
||||||
|
void WebContentsCreated(content::WebContents* source_contents,
|
||||||
|
int opener_render_process_id,
|
||||||
|
int opener_render_frame_id,
|
||||||
|
const std::string& frame_name,
|
||||||
|
const GURL& target_url,
|
||||||
|
content::WebContents* new_contents) override;
|
||||||
|
content::WebContents* OpenURLFromTab(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::OpenURLParams& params) override;
|
||||||
void LoadingStateChanged(content::WebContents* source,
|
void LoadingStateChanged(content::WebContents* source,
|
||||||
bool to_different_document) override;
|
bool to_different_document) override;
|
||||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||||
@ -62,17 +72,31 @@ class ChromeBrowserDelegate : public cef::BrowserDelegate {
|
|||||||
content::RenderFrameHost* requesting_frame,
|
content::RenderFrameHost* requesting_frame,
|
||||||
const blink::mojom::FullscreenOptions& options) override;
|
const blink::mojom::FullscreenOptions& options) override;
|
||||||
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
|
||||||
|
content::KeyboardEventProcessingResult PreHandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
bool HandleKeyboardEvent(
|
||||||
|
content::WebContents* source,
|
||||||
|
const content::NativeWebKeyboardEvent& event) override;
|
||||||
|
|
||||||
Browser* browser() const { return browser_; }
|
Browser* browser() const { return browser_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void CreateBrowser(
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
CefBrowserSettings settings,
|
||||||
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
|
CefRefPtr<CefRequestContextImpl> request_context_impl);
|
||||||
|
|
||||||
CefBrowserContentsDelegate* GetDelegateForWebContents(
|
CefBrowserContentsDelegate* GetDelegateForWebContents(
|
||||||
content::WebContents* web_contents);
|
content::WebContents* web_contents);
|
||||||
|
|
||||||
Browser* const browser_;
|
Browser* const browser_;
|
||||||
|
|
||||||
// Used when creating a new browser host.
|
// Used when creating a new browser host.
|
||||||
const CefBrowserHostBase::CreateParams create_params_;
|
const CefBrowserCreateParams create_params_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserDelegate);
|
DISALLOW_COPY_AND_ASSIGN(ChromeBrowserDelegate);
|
||||||
};
|
};
|
||||||
|
@ -4,26 +4,27 @@
|
|||||||
|
|
||||||
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
#include "libcef/browser/chrome/chrome_browser_host_impl.h"
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_platform_delegate.h"
|
||||||
|
#include "libcef/browser/chrome/browser_platform_delegate_chrome.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
#include "libcef/features/runtime_checks.h"
|
#include "libcef/features/runtime_checks.h"
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/notreached.h"
|
#include "base/notreached.h"
|
||||||
|
#include "chrome/browser/printing/print_view_manager_common.h"
|
||||||
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "chrome/browser/ui/browser.h"
|
#include "chrome/browser/ui/browser.h"
|
||||||
#include "chrome/browser/ui/browser_commands.h"
|
#include "chrome/browser/ui/browser_commands.h"
|
||||||
|
#include "chrome/browser/ui/browser_navigator.h"
|
||||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||||
#include "chrome/browser/ui/browser_window.h"
|
#include "chrome/browser/ui/browser_window.h"
|
||||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||||
|
#include "chrome/common/pref_names.h"
|
||||||
namespace {
|
#include "url/url_constants.h"
|
||||||
|
|
||||||
const auto kDefaultWindowDisposition = WindowOpenDisposition::CURRENT_TAB;
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
|
CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
|
||||||
const CreateParams& params) {
|
const CefBrowserCreateParams& params) {
|
||||||
// Get or create the request context and profile.
|
// Get or create the request context and profile.
|
||||||
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
CefRefPtr<CefRequestContextImpl> request_context_impl =
|
||||||
CefRequestContextImpl::GetOrCreateForRequestContext(
|
CefRequestContextImpl::GetOrCreateForRequestContext(
|
||||||
@ -44,21 +45,30 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::Create(
|
|||||||
// out of the existing Browser.
|
// out of the existing Browser.
|
||||||
auto browser = new Browser(chrome_params);
|
auto browser = new Browser(chrome_params);
|
||||||
|
|
||||||
// Add a new tab. This will indirectly create a new tab WebContents and
|
GURL url = params.url;
|
||||||
// call ChromeBrowserDelegate::SetAsDelegate to create the associated
|
if (url.is_empty()) {
|
||||||
// ChromeBrowserHostImpl.
|
// Chrome will navigate to kChromeUINewTabURL by default. We want to keep
|
||||||
chrome::AddTabAt(browser, params.url, /*idx=*/-1, /*foreground=*/true);
|
// the current CEF behavior of not navigating at all. Use a special URL that
|
||||||
|
// will be recognized in HandleNonNavigationAboutURL.
|
||||||
|
url = GURL("chrome://ignore/");
|
||||||
|
}
|
||||||
|
|
||||||
browser->window()->Show();
|
// Add a new tab. This will indirectly create a new tab WebContents and
|
||||||
|
// call ChromeBrowserDelegate::OnWebContentsCreated to create the associated
|
||||||
|
// ChromeBrowserHostImpl.
|
||||||
|
chrome::AddTabAt(browser, url, /*idx=*/-1, /*foreground=*/true);
|
||||||
|
|
||||||
// The new tab WebContents.
|
// The new tab WebContents.
|
||||||
auto web_contents = browser->tab_strip_model()->GetActiveWebContents();
|
auto web_contents = browser->tab_strip_model()->GetActiveWebContents();
|
||||||
DCHECK(web_contents);
|
CHECK(web_contents);
|
||||||
|
|
||||||
// The associated ChromeBrowserHostImpl.
|
// The associated ChromeBrowserHostImpl.
|
||||||
auto browser_host =
|
auto browser_host =
|
||||||
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
ChromeBrowserHostImpl::GetBrowserForContents(web_contents);
|
||||||
DCHECK(browser_host);
|
CHECK(browser_host);
|
||||||
|
|
||||||
|
browser->window()->Show();
|
||||||
|
|
||||||
return browser_host;
|
return browser_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,20 +117,34 @@ CefRefPtr<ChromeBrowserHostImpl> ChromeBrowserHostImpl::GetBrowserForFrameRoute(
|
|||||||
|
|
||||||
ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default;
|
ChromeBrowserHostImpl::~ChromeBrowserHostImpl() = default;
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::OnWebContentsDestroyed() {
|
void ChromeBrowserHostImpl::OnWebContentsDestroyed(
|
||||||
|
content::WebContents* web_contents) {
|
||||||
|
platform_delegate_->WebContentsDestroyed(web_contents);
|
||||||
DestroyBrowser();
|
DestroyBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
void ChromeBrowserHostImpl::OnSetFocus(cef_focus_source_t source) {
|
||||||
NOTIMPLEMENTED();
|
if (!CEF_CURRENTLY_ON_UIT()) {
|
||||||
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&ChromeBrowserHostImpl::OnSetFocus,
|
||||||
|
this, source));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::ViewText(const std::string& text) {
|
if (contents_delegate_->OnSetFocus(source))
|
||||||
NOTIMPLEMENTED();
|
return;
|
||||||
|
|
||||||
|
if (browser_) {
|
||||||
|
const int tab_index = GetCurrentTabIndex();
|
||||||
|
if (tab_index != TabStripModel::kNoTab) {
|
||||||
|
chrome::SelectNumberedTab(browser_, tab_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::CloseBrowser(bool force_close) {
|
void ChromeBrowserHostImpl::CloseBrowser(bool force_close) {
|
||||||
NOTIMPLEMENTED();
|
// Always do this asynchronously because TabStripModel is not re-entrant.
|
||||||
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&ChromeBrowserHostImpl::DoCloseBrowser,
|
||||||
|
this, force_close));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChromeBrowserHostImpl::TryCloseBrowser() {
|
bool ChromeBrowserHostImpl::TryCloseBrowser() {
|
||||||
@ -129,7 +153,9 @@ bool ChromeBrowserHostImpl::TryCloseBrowser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SetFocus(bool focus) {
|
void ChromeBrowserHostImpl::SetFocus(bool focus) {
|
||||||
NOTIMPLEMENTED();
|
if (focus) {
|
||||||
|
OnSetFocus(FOCUS_SOURCE_SYSTEM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowHandle ChromeBrowserHostImpl::GetWindowHandle() {
|
CefWindowHandle ChromeBrowserHostImpl::GetWindowHandle() {
|
||||||
@ -143,7 +169,7 @@ CefWindowHandle ChromeBrowserHostImpl::GetOpenerWindowHandle() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ChromeBrowserHostImpl::HasView() {
|
bool ChromeBrowserHostImpl::HasView() {
|
||||||
NOTIMPLEMENTED();
|
// TODO(chrome-runtime): Support Views-hosted browsers.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +200,12 @@ void ChromeBrowserHostImpl::Print() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (browser_) {
|
if (browser_) {
|
||||||
chrome::Print(browser_);
|
// Like chrome::Print() but specifying the WebContents.
|
||||||
|
printing::StartPrint(GetWebContents(),
|
||||||
|
/*print_renderer=*/mojo::NullAssociatedRemote(),
|
||||||
|
browser_->profile()->GetPrefs()->GetBoolean(
|
||||||
|
prefs::kPrintPreviewDisabled),
|
||||||
|
/*has_selection=*/false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,28 +298,6 @@ void ChromeBrowserHostImpl::SendExternalBeginFrame() {
|
|||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SendKeyEvent(const CefKeyEvent& event) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SendMouseClickEvent(const CefMouseEvent& event,
|
|
||||||
MouseButtonType type,
|
|
||||||
bool mouseUp,
|
|
||||||
int clickCount) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SendMouseMoveEvent(const CefMouseEvent& event,
|
|
||||||
bool mouseLeave) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SendMouseWheelEvent(const CefMouseEvent& event,
|
|
||||||
int deltaX,
|
|
||||||
int deltaY) {
|
|
||||||
NOTIMPLEMENTED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
|
void ChromeBrowserHostImpl::SendTouchEvent(const CefTouchEvent& event) {
|
||||||
NOTIMPLEMENTED();
|
NOTIMPLEMENTED();
|
||||||
}
|
}
|
||||||
@ -390,94 +399,56 @@ bool ChromeBrowserHostImpl::IsBackgroundHost() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::GoBack() {
|
bool ChromeBrowserHostImpl::Navigate(const content::OpenURLParams& params) {
|
||||||
auto callback = base::BindOnce(&ChromeBrowserHostImpl::GoBack, this);
|
CEF_REQUIRE_UIT();
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
if (GetCurrentTabIndex() == TabStripModel::kNoTab) {
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
// We can't navigate via the Browser because we don't have a current tab.
|
||||||
}
|
return CefBrowserHostBase::Navigate(params);
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_ && chrome::CanGoBack(browser_)) {
|
|
||||||
chrome::GoBack(browser_, kDefaultWindowDisposition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::GoForward() {
|
|
||||||
auto callback = base::BindOnce(&ChromeBrowserHostImpl::GoForward, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_ && chrome::CanGoForward(browser_)) {
|
|
||||||
chrome::GoForward(browser_, kDefaultWindowDisposition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::Reload() {
|
|
||||||
auto callback = base::BindOnce(&ChromeBrowserHostImpl::Reload, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browser_) {
|
if (browser_) {
|
||||||
chrome::Reload(browser_, kDefaultWindowDisposition);
|
// This is generally equivalent to calling Browser::OpenURL, except:
|
||||||
}
|
// 1. It doesn't trigger a call to CefRequestHandler::OnOpenURLFromTab, and
|
||||||
}
|
// 2. It navigates in this CefBrowserHost's WebContents instead of
|
||||||
|
// (a) creating a new WebContents, or (b) using the Browser's active
|
||||||
|
// WebContents (which may not be the same), and
|
||||||
|
// 3. There is no risk of triggering chrome's popup blocker.
|
||||||
|
NavigateParams nav_params(browser_, params.url, params.transition);
|
||||||
|
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::ReloadIgnoreCache() {
|
// Always navigate in the current tab.
|
||||||
auto callback =
|
nav_params.disposition = WindowOpenDisposition::CURRENT_TAB;
|
||||||
base::BindOnce(&ChromeBrowserHostImpl::ReloadIgnoreCache, this);
|
nav_params.source_contents = GetWebContents();
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
nav_params.tabstrip_add_types = TabStripModel::ADD_NONE;
|
||||||
return;
|
if (params.user_gesture)
|
||||||
}
|
nav_params.window_action = NavigateParams::SHOW_WINDOW;
|
||||||
|
::Navigate(&nav_params);
|
||||||
if (browser_) {
|
return true;
|
||||||
chrome::ReloadBypassingCache(browser_, kDefaultWindowDisposition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::StopLoad() {
|
|
||||||
auto callback = base::BindOnce(&ChromeBrowserHostImpl::StopLoad, this);
|
|
||||||
if (!CEF_CURRENTLY_ON_UIT()) {
|
|
||||||
CEF_POST_TASK(CEF_UIT, std::move(callback));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_info_->IsNavigationLocked(std::move(callback))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser_) {
|
|
||||||
chrome::Stop(browser_);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChromeBrowserHostImpl::ChromeBrowserHostImpl(
|
ChromeBrowserHostImpl::ChromeBrowserHostImpl(
|
||||||
const CefBrowserSettings& settings,
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context)
|
CefRefPtr<CefRequestContextImpl> request_context)
|
||||||
: CefBrowserHostBase(settings, client, browser_info, request_context) {}
|
: CefBrowserHostBase(settings,
|
||||||
|
client,
|
||||||
|
std::move(platform_delegate),
|
||||||
|
browser_info,
|
||||||
|
request_context) {}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::Attach(Browser* browser,
|
void ChromeBrowserHostImpl::Attach(Browser* browser,
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
DCHECK(browser);
|
DCHECK(browser);
|
||||||
DCHECK(web_contents);
|
DCHECK(web_contents);
|
||||||
|
|
||||||
|
platform_delegate_->WebContentsCreated(web_contents,
|
||||||
|
/*own_web_contents=*/false);
|
||||||
|
|
||||||
SetBrowser(browser);
|
SetBrowser(browser);
|
||||||
contents_delegate_->ObserveWebContents(web_contents);
|
contents_delegate_->ObserveWebContents(web_contents);
|
||||||
InitializeBrowser();
|
InitializeBrowser();
|
||||||
@ -486,14 +457,22 @@ void ChromeBrowserHostImpl::Attach(Browser* browser,
|
|||||||
void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
|
void ChromeBrowserHostImpl::SetBrowser(Browser* browser) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
browser_ = browser;
|
browser_ = browser;
|
||||||
|
static_cast<CefBrowserPlatformDelegateChrome*>(platform_delegate_.get())
|
||||||
|
->set_chrome_browser(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserHostImpl::InitializeBrowser() {
|
void ChromeBrowserHostImpl::InitializeBrowser() {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
DCHECK(browser_);
|
DCHECK(browser_);
|
||||||
|
|
||||||
|
// Associate the platform delegate with this browser.
|
||||||
|
platform_delegate_->BrowserCreated(this);
|
||||||
|
|
||||||
CefBrowserHostBase::InitializeBrowser();
|
CefBrowserHostBase::InitializeBrowser();
|
||||||
|
|
||||||
|
// The WebContents won't be added to the Browser's TabStripModel until later
|
||||||
|
// in the current call stack. Block navigation until that time.
|
||||||
|
auto navigation_lock = browser_info_->CreateNavigationLock();
|
||||||
OnAfterCreated();
|
OnAfterCreated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,5 +483,29 @@ void ChromeBrowserHostImpl::DestroyBrowser() {
|
|||||||
OnBeforeClose();
|
OnBeforeClose();
|
||||||
OnBrowserDestroyed();
|
OnBrowserDestroyed();
|
||||||
|
|
||||||
|
// Disassociate the platform delegate from this browser.
|
||||||
|
platform_delegate_->BrowserDestroyed(this);
|
||||||
|
|
||||||
CefBrowserHostBase::DestroyBrowser();
|
CefBrowserHostBase::DestroyBrowser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChromeBrowserHostImpl::DoCloseBrowser(bool force_close) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
if (browser_) {
|
||||||
|
// Like chrome::CloseTab() but specifying the WebContents.
|
||||||
|
const int tab_index = GetCurrentTabIndex();
|
||||||
|
if (tab_index != TabStripModel::kNoTab) {
|
||||||
|
browser_->tab_strip_model()->CloseWebContentsAt(
|
||||||
|
tab_index, TabStripModel::CLOSE_CREATE_HISTORICAL_TAB |
|
||||||
|
TabStripModel::CLOSE_USER_GESTURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ChromeBrowserHostImpl::GetCurrentTabIndex() const {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
if (browser_) {
|
||||||
|
return browser_->tab_strip_model()->GetIndexOfWebContents(GetWebContents());
|
||||||
|
}
|
||||||
|
return TabStripModel::kNoTab;
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_HOST_IMPL_H_
|
#define CEF_LIBCEF_BROWSER_CHROME_CHROME_BROWSER_HOST_IMPL_H_
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_base.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/chrome/browser_delegate.h"
|
#include "libcef/browser/chrome/browser_delegate.h"
|
||||||
|
|
||||||
@ -22,15 +24,16 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
// possibly shared by multiple Browser instances.
|
// possibly shared by multiple Browser instances.
|
||||||
class DelegateCreateParams : public cef::BrowserDelegate::CreateParams {
|
class DelegateCreateParams : public cef::BrowserDelegate::CreateParams {
|
||||||
public:
|
public:
|
||||||
DelegateCreateParams(const CefBrowserHostBase::CreateParams& create_params)
|
DelegateCreateParams(const CefBrowserCreateParams& create_params)
|
||||||
: create_params_(create_params) {}
|
: create_params_(create_params) {}
|
||||||
|
|
||||||
CefBrowserHostBase::CreateParams create_params_;
|
CefBrowserCreateParams create_params_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a new Browser with a single tab (WebContents) and associated
|
// Create a new Browser with a single tab (WebContents) and associated
|
||||||
// ChromeBrowserHostImpl instance.
|
// ChromeBrowserHostImpl instance.
|
||||||
static CefRefPtr<ChromeBrowserHostImpl> Create(const CreateParams& params);
|
static CefRefPtr<ChromeBrowserHostImpl> Create(
|
||||||
|
const CefBrowserCreateParams& params);
|
||||||
|
|
||||||
// Returns the browser associated with the specified RenderViewHost.
|
// Returns the browser associated with the specified RenderViewHost.
|
||||||
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForHost(
|
static CefRefPtr<ChromeBrowserHostImpl> GetBrowserForHost(
|
||||||
@ -52,11 +55,10 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
~ChromeBrowserHostImpl() override;
|
~ChromeBrowserHostImpl() override;
|
||||||
|
|
||||||
// CefBrowserContentsDelegate::Observer methods:
|
// CefBrowserContentsDelegate::Observer methods:
|
||||||
void OnWebContentsDestroyed() override;
|
void OnWebContentsDestroyed(content::WebContents* web_contents) override;
|
||||||
|
|
||||||
// CefBrowserHostBase methods called from CefFrameHostImpl:
|
// CefBrowserHostBase methods called from CefFrameHostImpl:
|
||||||
void OnSetFocus(cef_focus_source_t source) override;
|
void OnSetFocus(cef_focus_source_t source) override;
|
||||||
void ViewText(const std::string& text) override;
|
|
||||||
|
|
||||||
// CefBrowserHost methods:
|
// CefBrowserHost methods:
|
||||||
void CloseBrowser(bool force_close) override;
|
void CloseBrowser(bool force_close) override;
|
||||||
@ -103,15 +105,6 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
void NotifyScreenInfoChanged() override;
|
void NotifyScreenInfoChanged() override;
|
||||||
void Invalidate(PaintElementType type) override;
|
void Invalidate(PaintElementType type) override;
|
||||||
void SendExternalBeginFrame() override;
|
void SendExternalBeginFrame() override;
|
||||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
|
||||||
void SendMouseClickEvent(const CefMouseEvent& event,
|
|
||||||
MouseButtonType type,
|
|
||||||
bool mouseUp,
|
|
||||||
int clickCount) override;
|
|
||||||
void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) override;
|
|
||||||
void SendMouseWheelEvent(const CefMouseEvent& event,
|
|
||||||
int deltaX,
|
|
||||||
int deltaY) override;
|
|
||||||
void SendTouchEvent(const CefTouchEvent& event) override;
|
void SendTouchEvent(const CefTouchEvent& event) override;
|
||||||
void SendFocusEvent(bool setFocus) override;
|
void SendFocusEvent(bool setFocus) override;
|
||||||
void SendCaptureLostEvent() override;
|
void SendCaptureLostEvent() override;
|
||||||
@ -145,18 +138,16 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
CefRefPtr<CefExtension> GetExtension() override;
|
CefRefPtr<CefExtension> GetExtension() override;
|
||||||
bool IsBackgroundHost() override;
|
bool IsBackgroundHost() override;
|
||||||
|
|
||||||
// CefBrowser methods:
|
protected:
|
||||||
void GoBack() override;
|
bool Navigate(const content::OpenURLParams& params) override;
|
||||||
void GoForward() override;
|
|
||||||
void Reload() override;
|
|
||||||
void ReloadIgnoreCache() override;
|
|
||||||
void StopLoad() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class ChromeBrowserDelegate;
|
friend class ChromeBrowserDelegate;
|
||||||
|
|
||||||
ChromeBrowserHostImpl(const CefBrowserSettings& settings,
|
ChromeBrowserHostImpl(
|
||||||
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefClient> client,
|
CefRefPtr<CefClient> client,
|
||||||
|
std::unique_ptr<CefBrowserPlatformDelegate> platform_delegate,
|
||||||
scoped_refptr<CefBrowserInfo> browser_info,
|
scoped_refptr<CefBrowserInfo> browser_info,
|
||||||
CefRefPtr<CefRequestContextImpl> request_context);
|
CefRefPtr<CefRequestContextImpl> request_context);
|
||||||
|
|
||||||
@ -173,6 +164,12 @@ class ChromeBrowserHostImpl : public CefBrowserHostBase {
|
|||||||
void InitializeBrowser() override;
|
void InitializeBrowser() override;
|
||||||
void DestroyBrowser() override;
|
void DestroyBrowser() override;
|
||||||
|
|
||||||
|
void DoCloseBrowser(bool force_close);
|
||||||
|
|
||||||
|
// Returns the current tab index for the associated WebContents, or
|
||||||
|
// TabStripModel::kNoTab if not found.
|
||||||
|
int GetCurrentTabIndex() const;
|
||||||
|
|
||||||
Browser* browser_ = nullptr;
|
Browser* browser_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void ChromeBrowserMainExtraPartsCef::PostProfileInit() {
|
|||||||
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
CefRequestContextImpl::CreateGlobalRequestContext(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeBrowserMainExtraPartsCef::PostMainMessageLoopRun() {
|
void ChromeBrowserMainExtraPartsCef::PreMainMessageLoopRun() {
|
||||||
background_task_runner_ = base::CreateSingleThreadTaskRunner(
|
background_task_runner_ = base::CreateSingleThreadTaskRunner(
|
||||||
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
{base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
||||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
base::TaskShutdownBehavior::BLOCK_SHUTDOWN, base::MayBlock()});
|
||||||
|
@ -37,7 +37,7 @@ class ChromeBrowserMainExtraPartsCef : public ChromeBrowserMainExtraParts {
|
|||||||
private:
|
private:
|
||||||
// ChromeBrowserMainExtraParts overrides.
|
// ChromeBrowserMainExtraParts overrides.
|
||||||
void PostProfileInit() override;
|
void PostProfileInit() override;
|
||||||
void PostMainMessageLoopRun() override;
|
void PreMainMessageLoopRun() override;
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl> global_request_context_;
|
CefRefPtr<CefRequestContextImpl> global_request_context_;
|
||||||
|
|
||||||
|
@ -5,14 +5,48 @@
|
|||||||
|
|
||||||
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
|
#include "libcef/browser/browser_message_filter.h"
|
||||||
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
#include "libcef/browser/chrome/chrome_browser_main_extra_parts_cef.h"
|
||||||
|
#include "libcef/browser/net/throttle_handler.h"
|
||||||
|
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||||
|
#include "libcef/browser/net_service/login_delegate.h"
|
||||||
|
#include "libcef/browser/net_service/proxy_url_loader_factory.h"
|
||||||
|
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||||
|
#include "libcef/common/app_manager.h"
|
||||||
#include "libcef/common/cef_switches.h"
|
#include "libcef/common/cef_switches.h"
|
||||||
|
#include "libcef/common/command_line_impl.h"
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "chrome/browser/chrome_browser_main.h"
|
#include "chrome/browser/chrome_browser_main.h"
|
||||||
#include "chrome/common/chrome_paths.h"
|
#include "chrome/common/chrome_paths.h"
|
||||||
#include "chrome/common/chrome_switches.h"
|
#include "chrome/common/chrome_switches.h"
|
||||||
|
#include "content/public/browser/navigation_throttle.h"
|
||||||
|
#include "content/public/browser/render_process_host.h"
|
||||||
|
#include "content/public/common/content_switches.h"
|
||||||
|
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void HandleExternalProtocolHelper(
|
||||||
|
ChromeContentBrowserClientCef* self,
|
||||||
|
content::WebContents::OnceGetter web_contents_getter,
|
||||||
|
content::NavigationUIData* navigation_data,
|
||||||
|
const network::ResourceRequest& resource_request) {
|
||||||
|
// Match the logic of the original call in
|
||||||
|
// NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
|
||||||
|
self->HandleExternalProtocol(
|
||||||
|
resource_request.url, std::move(web_contents_getter),
|
||||||
|
content::ChildProcessHost::kInvalidUniqueID, navigation_data,
|
||||||
|
resource_request.resource_type ==
|
||||||
|
static_cast<int>(blink::mojom::ResourceType::kMainFrame),
|
||||||
|
static_cast<ui::PageTransition>(resource_request.transition_type),
|
||||||
|
resource_request.has_user_gesture, resource_request.request_initiator,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
|
ChromeContentBrowserClientCef::ChromeContentBrowserClientCef(
|
||||||
StartupData* startup_data)
|
StartupData* startup_data)
|
||||||
@ -46,6 +80,199 @@ void ChromeContentBrowserClientCef::AppendExtraCommandLineSwitches(
|
|||||||
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
if (base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
|
||||||
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
command_line->AppendSwitchPath(switches::kUserDataDir, user_data_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const base::CommandLine* browser_cmd = base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
|
const std::string& process_type =
|
||||||
|
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||||
|
if (process_type == switches::kRendererProcess) {
|
||||||
|
// Propagate the following switches to the renderer command line (along with
|
||||||
|
// any associated values) if present in the browser command line.
|
||||||
|
static const char* const kSwitchNames[] = {
|
||||||
|
switches::kUncaughtExceptionStackSize,
|
||||||
|
};
|
||||||
|
command_line->CopySwitchesFrom(*browser_cmd, kSwitchNames,
|
||||||
|
base::size(kSwitchNames));
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefApp> app = CefAppManager::Get()->GetApplication();
|
||||||
|
if (app.get()) {
|
||||||
|
CefRefPtr<CefBrowserProcessHandler> handler =
|
||||||
|
app->GetBrowserProcessHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
||||||
|
new CefCommandLineImpl(command_line, false, false));
|
||||||
|
handler->OnBeforeChildProcessLaunch(commandLinePtr.get());
|
||||||
|
commandLinePtr->Detach(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentBrowserClientCef::RenderProcessWillLaunch(
|
||||||
|
content::RenderProcessHost* host) {
|
||||||
|
const int id = host->GetID();
|
||||||
|
host->AddFilter(new CefBrowserMessageFilter(id));
|
||||||
|
|
||||||
|
// If the renderer process crashes then the host may already have
|
||||||
|
// CefBrowserInfoManager as an observer. Try to remove it first before adding
|
||||||
|
// to avoid DCHECKs.
|
||||||
|
host->RemoveObserver(CefBrowserInfoManager::GetInstance());
|
||||||
|
host->AddObserver(CefBrowserInfoManager::GetInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChromeContentBrowserClientCef::CanCreateWindow(
|
||||||
|
content::RenderFrameHost* opener,
|
||||||
|
const GURL& opener_url,
|
||||||
|
const GURL& opener_top_level_frame_url,
|
||||||
|
const url::Origin& source_origin,
|
||||||
|
content::mojom::WindowContainerType container_type,
|
||||||
|
const GURL& target_url,
|
||||||
|
const content::Referrer& referrer,
|
||||||
|
const std::string& frame_name,
|
||||||
|
WindowOpenDisposition disposition,
|
||||||
|
const blink::mojom::WindowFeatures& features,
|
||||||
|
bool user_gesture,
|
||||||
|
bool opener_suppressed,
|
||||||
|
bool* no_javascript_access) {
|
||||||
|
// The chrome layer has popup blocker, extensions, etc.
|
||||||
|
if (!ChromeContentBrowserClient::CanCreateWindow(
|
||||||
|
opener, opener_url, opener_top_level_frame_url, source_origin,
|
||||||
|
container_type, target_url, referrer, frame_name, disposition,
|
||||||
|
features, user_gesture, opener_suppressed, no_javascript_access)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CefBrowserInfoManager::GetInstance()->CanCreateWindow(
|
||||||
|
opener, target_url, referrer, frame_name, disposition, features,
|
||||||
|
user_gesture, opener_suppressed, no_javascript_access);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChromeContentBrowserClientCef::WillCreateURLLoaderFactory(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
content::RenderFrameHost* frame,
|
||||||
|
int render_process_id,
|
||||||
|
URLLoaderFactoryType type,
|
||||||
|
const url::Origin& request_initiator,
|
||||||
|
base::Optional<int64_t> navigation_id,
|
||||||
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||||
|
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||||
|
header_client,
|
||||||
|
bool* bypass_redirect_checks,
|
||||||
|
bool* disable_secure_dns,
|
||||||
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override) {
|
||||||
|
bool use_proxy = ChromeContentBrowserClient::WillCreateURLLoaderFactory(
|
||||||
|
browser_context, frame, render_process_id, type, request_initiator,
|
||||||
|
navigation_id, factory_receiver, header_client, bypass_redirect_checks,
|
||||||
|
disable_secure_dns, factory_override);
|
||||||
|
if (use_proxy) {
|
||||||
|
// The chrome layer will handle the request.
|
||||||
|
return use_proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||||
|
browser_context, frame, render_process_id,
|
||||||
|
type == URLLoaderFactoryType::kNavigation,
|
||||||
|
type == URLLoaderFactoryType::kDownload, request_initiator);
|
||||||
|
|
||||||
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||||
|
browser_context, factory_receiver, header_client,
|
||||||
|
std::move(request_handler));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
|
||||||
|
const GURL& url,
|
||||||
|
content::WebContents::OnceGetter web_contents_getter,
|
||||||
|
int child_id,
|
||||||
|
content::NavigationUIData* navigation_data,
|
||||||
|
bool is_main_frame,
|
||||||
|
ui::PageTransition page_transition,
|
||||||
|
bool has_user_gesture,
|
||||||
|
const base::Optional<url::Origin>& initiating_origin,
|
||||||
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||||
|
// |out_factory| will be non-nullptr when this method is initially called
|
||||||
|
// from NavigationURLLoaderImpl::PrepareForNonInterceptedRequest.
|
||||||
|
if (out_factory) {
|
||||||
|
// Let the other HandleExternalProtocol variant handle the request.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The request was unhandled and we've recieved a callback from
|
||||||
|
// HandleExternalProtocolHelper. Forward to the chrome layer for default
|
||||||
|
// handling.
|
||||||
|
return ChromeContentBrowserClient::HandleExternalProtocol(
|
||||||
|
url, std::move(web_contents_getter), child_id, navigation_data,
|
||||||
|
is_main_frame, page_transition, has_user_gesture, initiating_origin,
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ChromeContentBrowserClientCef::HandleExternalProtocol(
|
||||||
|
content::WebContents::Getter web_contents_getter,
|
||||||
|
int frame_tree_node_id,
|
||||||
|
content::NavigationUIData* navigation_data,
|
||||||
|
const network::ResourceRequest& resource_request,
|
||||||
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) {
|
||||||
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> receiver =
|
||||||
|
out_factory->InitWithNewPipeAndPassReceiver();
|
||||||
|
|
||||||
|
// HandleExternalProtocolHelper may be called if nothing handles the request.
|
||||||
|
auto request_handler = net_service::CreateInterceptedRequestHandler(
|
||||||
|
web_contents_getter, frame_tree_node_id, resource_request,
|
||||||
|
base::Bind(HandleExternalProtocolHelper, base::Unretained(this),
|
||||||
|
web_contents_getter, navigation_data, resource_request));
|
||||||
|
|
||||||
|
net_service::ProxyURLLoaderFactory::CreateProxy(
|
||||||
|
web_contents_getter, std::move(receiver), std::move(request_handler));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||||
|
ChromeContentBrowserClientCef::CreateThrottlesForNavigation(
|
||||||
|
content::NavigationHandle* navigation_handle) {
|
||||||
|
auto throttles = ChromeContentBrowserClient::CreateThrottlesForNavigation(
|
||||||
|
navigation_handle);
|
||||||
|
throttle::CreateThrottlesForNavigation(navigation_handle, throttles);
|
||||||
|
return throttles;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentBrowserClientCef::ConfigureNetworkContextParams(
|
||||||
|
content::BrowserContext* context,
|
||||||
|
bool in_memory,
|
||||||
|
const base::FilePath& relative_partition_path,
|
||||||
|
network::mojom::NetworkContextParams* network_context_params,
|
||||||
|
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params) {
|
||||||
|
ChromeContentBrowserClient::ConfigureNetworkContextParams(
|
||||||
|
context, in_memory, relative_partition_path, network_context_params,
|
||||||
|
cert_verifier_creation_params);
|
||||||
|
|
||||||
|
auto cef_context = CefBrowserContext::FromBrowserContext(context);
|
||||||
|
network_context_params->cookieable_schemes =
|
||||||
|
cef_context ? cef_context->GetCookieableSchemes()
|
||||||
|
: CefCookieManagerImpl::GetGlobalCookieableSchemes();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<content::LoginDelegate>
|
||||||
|
ChromeContentBrowserClientCef::CreateLoginDelegate(
|
||||||
|
const net::AuthChallengeInfo& auth_info,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
const content::GlobalRequestID& request_id,
|
||||||
|
bool is_request_for_main_frame,
|
||||||
|
const GURL& url,
|
||||||
|
scoped_refptr<net::HttpResponseHeaders> response_headers,
|
||||||
|
bool first_auth_attempt,
|
||||||
|
LoginAuthRequiredCallback auth_required_callback) {
|
||||||
|
// |web_contents| is nullptr for CefURLRequests without an associated frame.
|
||||||
|
if (!web_contents || base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
|
switches::kDisableChromeLoginPrompt)) {
|
||||||
|
// Delegate auth callbacks to GetAuthCredentials.
|
||||||
|
return std::make_unique<net_service::LoginDelegate>(
|
||||||
|
auth_info, web_contents, request_id, url,
|
||||||
|
std::move(auth_required_callback));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChromeContentBrowserClient::CreateLoginDelegate(
|
||||||
|
auth_info, web_contents, request_id, is_request_for_main_frame, url,
|
||||||
|
response_headers, first_auth_attempt, std::move(auth_required_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl>
|
CefRefPtr<CefRequestContextImpl>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
class ChromeBrowserMainExtraPartsCef;
|
class ChromeBrowserMainExtraPartsCef;
|
||||||
|
|
||||||
// CEF override of ChromeContentBrowserClient
|
// CEF override of ChromeContentBrowserClient.
|
||||||
class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
||||||
public:
|
public:
|
||||||
explicit ChromeContentBrowserClientCef(StartupData* startup_data = nullptr);
|
explicit ChromeContentBrowserClientCef(StartupData* startup_data = nullptr);
|
||||||
@ -26,6 +26,70 @@ class ChromeContentBrowserClientCef : public ChromeContentBrowserClient {
|
|||||||
const content::MainFunctionParams& parameters) override;
|
const content::MainFunctionParams& parameters) override;
|
||||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||||
int child_process_id) override;
|
int child_process_id) override;
|
||||||
|
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
||||||
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||||
|
const GURL& opener_url,
|
||||||
|
const GURL& opener_top_level_frame_url,
|
||||||
|
const url::Origin& source_origin,
|
||||||
|
content::mojom::WindowContainerType container_type,
|
||||||
|
const GURL& target_url,
|
||||||
|
const content::Referrer& referrer,
|
||||||
|
const std::string& frame_name,
|
||||||
|
WindowOpenDisposition disposition,
|
||||||
|
const blink::mojom::WindowFeatures& features,
|
||||||
|
bool user_gesture,
|
||||||
|
bool opener_suppressed,
|
||||||
|
bool* no_javascript_access) override;
|
||||||
|
bool WillCreateURLLoaderFactory(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
content::RenderFrameHost* frame,
|
||||||
|
int render_process_id,
|
||||||
|
URLLoaderFactoryType type,
|
||||||
|
const url::Origin& request_initiator,
|
||||||
|
base::Optional<int64_t> navigation_id,
|
||||||
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver,
|
||||||
|
mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>*
|
||||||
|
header_client,
|
||||||
|
bool* bypass_redirect_checks,
|
||||||
|
bool* disable_secure_dns,
|
||||||
|
network::mojom::URLLoaderFactoryOverridePtr* factory_override) override;
|
||||||
|
bool HandleExternalProtocol(
|
||||||
|
const GURL& url,
|
||||||
|
content::WebContents::OnceGetter web_contents_getter,
|
||||||
|
int child_id,
|
||||||
|
content::NavigationUIData* navigation_data,
|
||||||
|
bool is_main_frame,
|
||||||
|
ui::PageTransition page_transition,
|
||||||
|
bool has_user_gesture,
|
||||||
|
const base::Optional<url::Origin>& initiating_origin,
|
||||||
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
||||||
|
override;
|
||||||
|
bool HandleExternalProtocol(
|
||||||
|
content::WebContents::Getter web_contents_getter,
|
||||||
|
int frame_tree_node_id,
|
||||||
|
content::NavigationUIData* navigation_data,
|
||||||
|
const network::ResourceRequest& request,
|
||||||
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory)
|
||||||
|
override;
|
||||||
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||||
|
CreateThrottlesForNavigation(
|
||||||
|
content::NavigationHandle* navigation_handle) override;
|
||||||
|
void ConfigureNetworkContextParams(
|
||||||
|
content::BrowserContext* context,
|
||||||
|
bool in_memory,
|
||||||
|
const base::FilePath& relative_partition_path,
|
||||||
|
network::mojom::NetworkContextParams* network_context_params,
|
||||||
|
network::mojom::CertVerifierCreationParams* cert_verifier_creation_params)
|
||||||
|
override;
|
||||||
|
std::unique_ptr<content::LoginDelegate> CreateLoginDelegate(
|
||||||
|
const net::AuthChallengeInfo& auth_info,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
const content::GlobalRequestID& request_id,
|
||||||
|
bool is_request_for_main_frame,
|
||||||
|
const GURL& url,
|
||||||
|
scoped_refptr<net::HttpResponseHeaders> response_headers,
|
||||||
|
bool first_auth_attempt,
|
||||||
|
LoginAuthRequiredCallback auth_required_callback) override;
|
||||||
|
|
||||||
CefRefPtr<CefRequestContextImpl> request_context() const;
|
CefRefPtr<CefRequestContextImpl> request_context() const;
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ CefDevToolsFrontend* CefDevToolsFrontend::Show(
|
|||||||
new_settings.background_color = SK_ColorWHITE;
|
new_settings.background_color = SK_ColorWHITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
if (!inspected_browser->IsViewsHosted())
|
if (!inspected_browser->IsViewsHosted())
|
||||||
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
create_params.window_info.reset(new CefWindowInfo(windowInfo));
|
||||||
create_params.client = client;
|
create_params.client = client;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
|
#include "libcef/features/runtime_checks.h"
|
||||||
|
|
||||||
#include "content/public/browser/render_view_host.h"
|
#include "content/public/browser/render_view_host.h"
|
||||||
#include "content/public/browser/render_widget_host.h"
|
#include "content/public/browser/render_widget_host.h"
|
||||||
@ -15,6 +16,7 @@
|
|||||||
CefBrowserPlatformDelegateBackground::CefBrowserPlatformDelegateBackground(
|
CefBrowserPlatformDelegateBackground::CefBrowserPlatformDelegateBackground(
|
||||||
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
|
std::unique_ptr<CefBrowserPlatformDelegateNative> native_delegate)
|
||||||
: native_delegate_(std::move(native_delegate)) {
|
: native_delegate_(std::move(native_delegate)) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
native_delegate_->set_windowless_handler(this);
|
native_delegate_->set_windowless_handler(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +29,8 @@ void CefBrowserPlatformDelegateBackground::CloseHostWindow() {
|
|||||||
// No host window, so continue browser destruction now. Do it asynchronously
|
// No host window, so continue browser destruction now. Do it asynchronously
|
||||||
// so the call stack has a chance to unwind.
|
// so the call stack has a chance to unwind.
|
||||||
CEF_POST_TASK(CEF_UIT,
|
CEF_POST_TASK(CEF_UIT,
|
||||||
base::Bind(&AlloyBrowserHostImpl::WindowDestroyed, browser_));
|
base::Bind(&AlloyBrowserHostImpl::WindowDestroyed,
|
||||||
|
static_cast<AlloyBrowserHostImpl*>(browser_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()
|
CefWindowHandle CefBrowserPlatformDelegateBackground::GetHostWindowHandle()
|
||||||
@ -115,14 +118,6 @@ CefBrowserPlatformDelegateBackground::CreateMenuRunner() {
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateBackground::IsWindowless() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateBackground::IsViewsHosted() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefWindowHandle CefBrowserPlatformDelegateBackground::GetParentWindowHandle()
|
CefWindowHandle CefBrowserPlatformDelegateBackground::GetParentWindowHandle()
|
||||||
const {
|
const {
|
||||||
return GetHostWindowHandle();
|
return GetHostWindowHandle();
|
||||||
|
@ -44,8 +44,6 @@ class CefBrowserPlatformDelegateBackground
|
|||||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
||||||
override;
|
override;
|
||||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||||
bool IsWindowless() const override;
|
|
||||||
bool IsViewsHosted() const override;
|
|
||||||
|
|
||||||
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
// CefBrowserPlatformDelegateNative::WindowlessHandler methods:
|
||||||
CefWindowHandle GetParentWindowHandle() const override;
|
CefWindowHandle GetParentWindowHandle() const override;
|
||||||
|
@ -365,7 +365,7 @@ base::DictionaryValue* CefExtensionFunctionDetails::OpenTab(
|
|||||||
if (!request_context)
|
if (!request_context)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
create_params.url = url;
|
create_params.url = url;
|
||||||
create_params.request_context = request_context;
|
create_params.request_context = request_context;
|
||||||
create_params.window_info.reset(new CefWindowInfo);
|
create_params.window_info.reset(new CefWindowInfo);
|
||||||
|
@ -250,7 +250,7 @@ bool CefExtensionsBrowserClient::CreateBackgroundExtensionHost(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefBrowserHostBase::CreateParams create_params;
|
CefBrowserCreateParams create_params;
|
||||||
create_params.url = url;
|
create_params.url = url;
|
||||||
create_params.request_context = request_context;
|
create_params.request_context = request_context;
|
||||||
|
|
||||||
|
@ -306,8 +306,7 @@ void CefFrameHostImpl::Navigate(const CefNavigateParams& params) {
|
|||||||
CefMsg_LoadRequest_Params request;
|
CefMsg_LoadRequest_Params request;
|
||||||
request.url = params.url;
|
request.url = params.url;
|
||||||
if (!request.url.is_valid()) {
|
if (!request.url.is_valid()) {
|
||||||
LOG(ERROR) << "Invalid URL passed to CefFrameHostImpl::Navigate: "
|
LOG(ERROR) << "Invalid URL: " << params.url;
|
||||||
<< params.url;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,14 +336,30 @@ void CefFrameHostImpl::LoadURLWithExtras(const std::string& url,
|
|||||||
if (frame_id < CefFrameHostImpl::kMainFrameId)
|
if (frame_id < CefFrameHostImpl::kMainFrameId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
GURL gurl(url);
|
||||||
|
if (!gurl.is_valid() && !gurl.has_scheme()) {
|
||||||
|
// Try to add "http://" at the beginning.
|
||||||
|
std::string new_url = std::string("http://") + url;
|
||||||
|
gurl = GURL(new_url);
|
||||||
|
}
|
||||||
|
if (!gurl.is_valid()) {
|
||||||
|
LOG(ERROR) << "Invalid URL: " << url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (frame_id == CefFrameHostImpl::kMainFrameId) {
|
if (frame_id == CefFrameHostImpl::kMainFrameId) {
|
||||||
// Load via the browser using NavigationController.
|
// Load via the browser using NavigationController.
|
||||||
auto browser = GetBrowserHostBase();
|
auto browser = GetBrowserHostBase();
|
||||||
if (browser) {
|
if (browser) {
|
||||||
browser->LoadMainFrameURL(url, referrer, transition, extra_headers);
|
content::OpenURLParams params(
|
||||||
|
gurl, referrer, WindowOpenDisposition::CURRENT_TAB, transition,
|
||||||
|
/*is_renderer_initiated=*/false);
|
||||||
|
params.extra_headers = extra_headers;
|
||||||
|
|
||||||
|
browser->LoadMainFrameURL(params);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CefNavigateParams params(GURL(url), transition);
|
CefNavigateParams params(gurl, transition);
|
||||||
params.referrer = referrer;
|
params.referrer = referrer;
|
||||||
params.headers = extra_headers;
|
params.headers = extra_headers;
|
||||||
Navigate(params);
|
Navigate(params);
|
||||||
|
@ -22,15 +22,8 @@ SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNative::WasResized() {
|
void CefBrowserPlatformDelegateNative::WasResized() {
|
||||||
content::RenderViewHost* host = browser_->web_contents()->GetRenderViewHost();
|
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
|
||||||
if (host)
|
if (host) {
|
||||||
host->GetWidget()->SynchronizeVisualProperties();
|
host->GetWidget()->SynchronizeVisualProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateNative::IsWindowless() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateNative::IsViewsHosted() const {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,6 @@ class CefBrowserPlatformDelegateNative
|
|||||||
// CefBrowserPlatformDelegate methods:
|
// CefBrowserPlatformDelegate methods:
|
||||||
SkColor GetBackgroundColor() const override;
|
SkColor GetBackgroundColor() const override;
|
||||||
void WasResized() override;
|
void WasResized() override;
|
||||||
bool IsWindowless() const override;
|
|
||||||
bool IsViewsHosted() const override;
|
|
||||||
|
|
||||||
// Translate CEF events to Chromium/Blink Web events.
|
// Translate CEF events to Chromium/Blink Web events.
|
||||||
virtual content::NativeWebKeyboardEvent TranslateWebKeyEvent(
|
virtual content::NativeWebKeyboardEvent TranslateWebKeyEvent(
|
||||||
@ -52,6 +50,7 @@ class CefBrowserPlatformDelegateNative
|
|||||||
protected:
|
protected:
|
||||||
// Delegates that can wrap a native delegate.
|
// Delegates that can wrap a native delegate.
|
||||||
friend class CefBrowserPlatformDelegateBackground;
|
friend class CefBrowserPlatformDelegateBackground;
|
||||||
|
friend class CefBrowserPlatformDelegateChrome;
|
||||||
friend class CefBrowserPlatformDelegateOsr;
|
friend class CefBrowserPlatformDelegateOsr;
|
||||||
friend class CefBrowserPlatformDelegateViews;
|
friend class CefBrowserPlatformDelegateViews;
|
||||||
|
|
||||||
@ -61,6 +60,7 @@ class CefBrowserPlatformDelegateNative
|
|||||||
// Methods used by delegates that can wrap a native delegate.
|
// Methods used by delegates that can wrap a native delegate.
|
||||||
void set_windowless_handler(WindowlessHandler* handler) {
|
void set_windowless_handler(WindowlessHandler* handler) {
|
||||||
windowless_handler_ = handler;
|
windowless_handler_ = handler;
|
||||||
|
set_as_secondary();
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowInfo window_info_;
|
CefWindowInfo window_info_;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include <sys/sysinfo.h>
|
#include <sys/sysinfo.h>
|
||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/context.h"
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/native/menu_runner_linux.h"
|
#include "libcef/browser/native/menu_runner_linux.h"
|
||||||
#include "libcef/browser/native/window_delegate_view.h"
|
#include "libcef/browser/native/window_delegate_view.h"
|
||||||
@ -50,7 +50,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
|
|||||||
window_widget_(nullptr) {}
|
window_widget_(nullptr) {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
||||||
|
|
||||||
if (host_window_created_) {
|
if (host_window_created_) {
|
||||||
|
@ -19,7 +19,7 @@ class CefBrowserPlatformDelegateNativeLinux
|
|||||||
SkColor background_color);
|
SkColor background_color);
|
||||||
|
|
||||||
// CefBrowserPlatformDelegate methods:
|
// CefBrowserPlatformDelegate methods:
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
bool CreateHostWindow() override;
|
bool CreateHostWindow() override;
|
||||||
void CloseHostWindow() override;
|
void CloseHostWindow() override;
|
||||||
CefWindowHandle GetHostWindowHandle() const override;
|
CefWindowHandle GetHostWindowHandle() const override;
|
||||||
|
@ -19,7 +19,7 @@ class CefBrowserPlatformDelegateNativeMac
|
|||||||
SkColor background_color);
|
SkColor background_color);
|
||||||
|
|
||||||
// CefBrowserPlatformDelegate methods:
|
// CefBrowserPlatformDelegate methods:
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
bool CreateHostWindow() override;
|
bool CreateHostWindow() override;
|
||||||
void CloseHostWindow() override;
|
void CloseHostWindow() override;
|
||||||
CefWindowHandle GetHostWindowHandle() const override;
|
CefWindowHandle GetHostWindowHandle() const override;
|
||||||
|
@ -34,10 +34,10 @@
|
|||||||
// the view is deleted.
|
// the view is deleted.
|
||||||
@interface CefBrowserHostView : NSView {
|
@interface CefBrowserHostView : NSView {
|
||||||
@private
|
@private
|
||||||
AlloyBrowserHostImpl* browser_; // weak
|
CefBrowserHostBase* browser_; // weak
|
||||||
}
|
}
|
||||||
|
|
||||||
@property(nonatomic, assign) AlloyBrowserHostImpl* browser;
|
@property(nonatomic, assign) CefBrowserHostBase* browser;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -49,7 +49,7 @@
|
|||||||
if (browser_) {
|
if (browser_) {
|
||||||
// Force the browser to be destroyed and release the reference added in
|
// Force the browser to be destroyed and release the reference added in
|
||||||
// PlatformCreateWindow().
|
// PlatformCreateWindow().
|
||||||
browser_->WindowDestroyed();
|
static_cast<AlloyBrowserHostImpl*>(browser_)->WindowDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
@ -60,17 +60,15 @@
|
|||||||
// Receives notifications from the browser window. Will delete itself when done.
|
// Receives notifications from the browser window. Will delete itself when done.
|
||||||
@interface CefWindowDelegate : NSObject <NSWindowDelegate> {
|
@interface CefWindowDelegate : NSObject <NSWindowDelegate> {
|
||||||
@private
|
@private
|
||||||
AlloyBrowserHostImpl* browser_; // weak
|
CefBrowserHostBase* browser_; // weak
|
||||||
NSWindow* window_;
|
NSWindow* window_;
|
||||||
}
|
}
|
||||||
- (id)initWithWindow:(NSWindow*)window
|
- (id)initWithWindow:(NSWindow*)window andBrowser:(CefBrowserHostBase*)browser;
|
||||||
andBrowser:(AlloyBrowserHostImpl*)browser;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CefWindowDelegate
|
@implementation CefWindowDelegate
|
||||||
|
|
||||||
- (id)initWithWindow:(NSWindow*)window
|
- (id)initWithWindow:(NSWindow*)window andBrowser:(CefBrowserHostBase*)browser {
|
||||||
andBrowser:(AlloyBrowserHostImpl*)browser {
|
|
||||||
if (self = [super init]) {
|
if (self = [super init]) {
|
||||||
window_ = window;
|
window_ = window;
|
||||||
browser_ = browser;
|
browser_ = browser;
|
||||||
@ -152,7 +150,7 @@ CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
|
|||||||
host_window_created_(false) {}
|
host_window_created_(false) {}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
|
void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
||||||
|
|
||||||
if (host_window_created_) {
|
if (host_window_created_) {
|
||||||
|
@ -127,12 +127,10 @@ float GetWindowScaleFactor(HWND hwnd) {
|
|||||||
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
||||||
const CefWindowInfo& window_info,
|
const CefWindowInfo& window_info,
|
||||||
SkColor background_color)
|
SkColor background_color)
|
||||||
: CefBrowserPlatformDelegateNativeAura(window_info, background_color),
|
: CefBrowserPlatformDelegateNativeAura(window_info, background_color) {}
|
||||||
host_window_created_(false),
|
|
||||||
window_widget_(nullptr) {}
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateNative::BrowserDestroyed(browser);
|
||||||
|
|
||||||
if (host_window_created_) {
|
if (host_window_created_) {
|
||||||
@ -530,14 +528,15 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
|||||||
WPARAM wParam,
|
WPARAM wParam,
|
||||||
LPARAM lParam) {
|
LPARAM lParam) {
|
||||||
CefBrowserPlatformDelegateNativeWin* platform_delegate = nullptr;
|
CefBrowserPlatformDelegateNativeWin* platform_delegate = nullptr;
|
||||||
AlloyBrowserHostImpl* browser = nullptr;
|
CefBrowserHostBase* browser = nullptr;
|
||||||
|
|
||||||
if (message != WM_NCCREATE) {
|
if (message != WM_NCCREATE) {
|
||||||
platform_delegate = static_cast<CefBrowserPlatformDelegateNativeWin*>(
|
platform_delegate = static_cast<CefBrowserPlatformDelegateNativeWin*>(
|
||||||
gfx::GetWindowUserData(hwnd));
|
gfx::GetWindowUserData(hwnd));
|
||||||
if (platform_delegate)
|
if (platform_delegate) {
|
||||||
browser = platform_delegate->browser_;
|
browser = platform_delegate->browser_;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
@ -582,7 +581,7 @@ LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
|||||||
// Force the browser to be destroyed. This will result in a call to
|
// Force the browser to be destroyed. This will result in a call to
|
||||||
// BrowserDestroyed() that will release the reference added in
|
// BrowserDestroyed() that will release the reference added in
|
||||||
// CreateHostWindow().
|
// CreateHostWindow().
|
||||||
browser->WindowDestroyed();
|
static_cast<AlloyBrowserHostImpl*>(browser)->WindowDestroyed();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class CefBrowserPlatformDelegateNativeWin
|
|||||||
SkColor background_color);
|
SkColor background_color);
|
||||||
|
|
||||||
// CefBrowserPlatformDelegate methods:
|
// CefBrowserPlatformDelegate methods:
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
bool CreateHostWindow() override;
|
bool CreateHostWindow() override;
|
||||||
void CloseHostWindow() override;
|
void CloseHostWindow() override;
|
||||||
CefWindowHandle GetHostWindowHandle() const override;
|
CefWindowHandle GetHostWindowHandle() const override;
|
||||||
@ -52,11 +52,11 @@ class CefBrowserPlatformDelegateNativeWin
|
|||||||
LPARAM lParam);
|
LPARAM lParam);
|
||||||
|
|
||||||
// True if the host window has been created.
|
// True if the host window has been created.
|
||||||
bool host_window_created_;
|
bool host_window_created_ = false;
|
||||||
|
|
||||||
// Widget hosting the web contents. It will be deleted automatically when the
|
// Widget hosting the web contents. It will be deleted automatically when the
|
||||||
// associated root window is destroyed.
|
// associated root window is destroyed.
|
||||||
views::Widget* window_widget_;
|
views::Widget* window_widget_ = nullptr;
|
||||||
|
|
||||||
bool has_frame_ = false;
|
bool has_frame_ = false;
|
||||||
bool called_enable_non_client_dpi_scaling_ = false;
|
bool called_enable_non_client_dpi_scaling_ = false;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
|
|
||||||
|
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
||||||
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
|
|
||||||
#include "ui/base/x/x11_util.h"
|
#include "ui/base/x/x11_util.h"
|
||||||
@ -92,7 +94,7 @@ CEF_EXPORT XDisplay* cef_get_xdisplay() {
|
|||||||
return gfx::GetXDisplay();
|
return gfx::GetXDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
CefWindowX11::CefWindowX11(CefRefPtr<AlloyBrowserHostImpl> browser,
|
CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostBase> browser,
|
||||||
::Window parent_xwindow,
|
::Window parent_xwindow,
|
||||||
const gfx::Rect& bounds,
|
const gfx::Rect& bounds,
|
||||||
const std::string& title)
|
const std::string& title)
|
||||||
@ -412,10 +414,11 @@ void CefWindowX11::ProcessXEvent(x11::Event* event) {
|
|||||||
|
|
||||||
xwindow_ = x11::None;
|
xwindow_ = x11::None;
|
||||||
|
|
||||||
if (browser_.get()) {
|
if (browser_) {
|
||||||
// Force the browser to be destroyed and release the reference
|
// Force the browser to be destroyed and release the reference
|
||||||
// added in PlatformCreateWindow().
|
// added in PlatformCreateWindow().
|
||||||
browser_->WindowDestroyed();
|
static_cast<AlloyBrowserHostImpl*>(browser_.get())
|
||||||
|
->WindowDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
|
@ -12,7 +12,7 @@ typedef unsigned long Window;
|
|||||||
struct _XDisplay;
|
struct _XDisplay;
|
||||||
typedef struct _XDisplay Display;
|
typedef struct _XDisplay Display;
|
||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "include/internal/cef_ptr.h"
|
||||||
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
#include "ui/events/platform/platform_event_dispatcher.h"
|
#include "ui/events/platform/platform_event_dispatcher.h"
|
||||||
@ -24,12 +24,14 @@ namespace views {
|
|||||||
class DesktopWindowTreeHostLinux;
|
class DesktopWindowTreeHostLinux;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class CefBrowserHostBase;
|
||||||
|
|
||||||
// Object wrapper for an X11 Window.
|
// Object wrapper for an X11 Window.
|
||||||
// Based on WindowTreeHostX11 and DesktopWindowTreeHostX11.
|
// Based on WindowTreeHostX11 and DesktopWindowTreeHostX11.
|
||||||
class CefWindowX11 : public ui::PlatformEventDispatcher,
|
class CefWindowX11 : public ui::PlatformEventDispatcher,
|
||||||
public ui::XEventDispatcher {
|
public ui::XEventDispatcher {
|
||||||
public:
|
public:
|
||||||
CefWindowX11(CefRefPtr<AlloyBrowserHostImpl> browser,
|
CefWindowX11(CefRefPtr<CefBrowserHostBase> browser,
|
||||||
::Window parent_xwindow,
|
::Window parent_xwindow,
|
||||||
const gfx::Rect& bounds,
|
const gfx::Rect& bounds,
|
||||||
const std::string& title);
|
const std::string& title);
|
||||||
@ -69,7 +71,7 @@ class CefWindowX11 : public ui::PlatformEventDispatcher,
|
|||||||
bool IsTargetedBy(const x11::Event& x11_event) const;
|
bool IsTargetedBy(const x11::Event& x11_event) const;
|
||||||
void ProcessXEvent(x11::Event* xev);
|
void ProcessXEvent(x11::Event* xev);
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser_;
|
CefRefPtr<CefBrowserHostBase> browser_;
|
||||||
|
|
||||||
// The display and the native X window hosting the root window.
|
// The display and the native X window hosting the root window.
|
||||||
::Display* xdisplay_;
|
::Display* xdisplay_;
|
||||||
|
116
libcef/browser/net/throttle_handler.cc
Normal file
116
libcef/browser/net/throttle_handler.cc
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// Copyright 2020 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/net/throttle_handler.h"
|
||||||
|
|
||||||
|
#include "libcef/browser/browser_host_base.h"
|
||||||
|
#include "libcef/browser/browser_info_manager.h"
|
||||||
|
#include "libcef/browser/frame_host_impl.h"
|
||||||
|
#include "libcef/common/request_impl.h"
|
||||||
|
|
||||||
|
#include "components/navigation_interception/intercept_navigation_throttle.h"
|
||||||
|
#include "components/navigation_interception/navigation_params.h"
|
||||||
|
#include "content/public/browser/navigation_handle.h"
|
||||||
|
#include "content/public/browser/navigation_throttle.h"
|
||||||
|
#include "content/public/browser/page_navigator.h"
|
||||||
|
|
||||||
|
namespace throttle {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// TODO(cef): We can't currently trust NavigationParams::is_main_frame() because
|
||||||
|
// it's always set to true in
|
||||||
|
// InterceptNavigationThrottle::CheckIfShouldIgnoreNavigation. Remove the
|
||||||
|
// |is_main_frame| argument once this problem is fixed.
|
||||||
|
bool NavigationOnUIThread(
|
||||||
|
bool is_main_frame,
|
||||||
|
int64_t frame_id,
|
||||||
|
int64_t parent_frame_id,
|
||||||
|
int frame_tree_node_id,
|
||||||
|
content::WebContents* source,
|
||||||
|
const navigation_interception::NavigationParams& params) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
content::OpenURLParams open_params(
|
||||||
|
params.url(), params.referrer(), WindowOpenDisposition::CURRENT_TAB,
|
||||||
|
params.transition_type(), params.is_renderer_initiated());
|
||||||
|
open_params.user_gesture = params.has_user_gesture();
|
||||||
|
open_params.initiator_origin = params.initiator_origin();
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowserHostBase> browser;
|
||||||
|
if (!CefBrowserInfoManager::GetInstance()->MaybeAllowNavigation(
|
||||||
|
source->GetMainFrame(), open_params, browser)) {
|
||||||
|
// Cancel the navigation.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ignore_navigation = false;
|
||||||
|
|
||||||
|
if (browser) {
|
||||||
|
if (auto client = browser->GetClient()) {
|
||||||
|
if (auto handler = client->GetRequestHandler()) {
|
||||||
|
CefRefPtr<CefFrame> frame;
|
||||||
|
if (is_main_frame) {
|
||||||
|
frame = browser->GetMainFrame();
|
||||||
|
} else if (frame_id >= 0) {
|
||||||
|
frame = browser->GetFrame(frame_id);
|
||||||
|
}
|
||||||
|
if (!frame && frame_tree_node_id >= 0) {
|
||||||
|
frame = browser->GetFrameForFrameTreeNode(frame_tree_node_id);
|
||||||
|
}
|
||||||
|
if (!frame) {
|
||||||
|
// Create a temporary frame object for navigation of sub-frames that
|
||||||
|
// don't yet exist.
|
||||||
|
frame = browser->browser_info()->CreateTempSubFrame(parent_frame_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefRequestImpl> request = new CefRequestImpl();
|
||||||
|
request->Set(params, is_main_frame);
|
||||||
|
request->SetReadOnly(true);
|
||||||
|
|
||||||
|
// Initiating a new navigation in OnBeforeBrowse will delete the
|
||||||
|
// InterceptNavigationThrottle that currently owns this callback,
|
||||||
|
// resulting in a crash. Use the lock to prevent that.
|
||||||
|
auto navigation_lock = browser->browser_info()->CreateNavigationLock();
|
||||||
|
ignore_navigation = handler->OnBeforeBrowse(
|
||||||
|
browser.get(), frame, request.get(), params.has_user_gesture(),
|
||||||
|
params.is_redirect());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ignore_navigation;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
|
||||||
|
NavigationThrottleList& throttles) {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
const bool is_main_frame = navigation_handle->IsInMainFrame();
|
||||||
|
|
||||||
|
// Identify the RenderFrameHost that originated the navigation.
|
||||||
|
const int64_t parent_frame_id =
|
||||||
|
!is_main_frame
|
||||||
|
? CefFrameHostImpl::MakeFrameId(navigation_handle->GetParentFrame())
|
||||||
|
: CefFrameHostImpl::kInvalidFrameId;
|
||||||
|
|
||||||
|
const int64_t frame_id = !is_main_frame && navigation_handle->HasCommitted()
|
||||||
|
? CefFrameHostImpl::MakeFrameId(
|
||||||
|
navigation_handle->GetRenderFrameHost())
|
||||||
|
: CefFrameHostImpl::kInvalidFrameId;
|
||||||
|
|
||||||
|
// Must use SynchronyMode::kSync to ensure that OnBeforeBrowse is always
|
||||||
|
// called before OnBeforeResourceLoad.
|
||||||
|
std::unique_ptr<content::NavigationThrottle> throttle =
|
||||||
|
std::make_unique<navigation_interception::InterceptNavigationThrottle>(
|
||||||
|
navigation_handle,
|
||||||
|
base::Bind(&NavigationOnUIThread, is_main_frame, frame_id,
|
||||||
|
parent_frame_id, navigation_handle->GetFrameTreeNodeId()),
|
||||||
|
navigation_interception::SynchronyMode::kSync);
|
||||||
|
throttles.push_back(std::move(throttle));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace throttle
|
27
libcef/browser/net/throttle_handler.h
Normal file
27
libcef/browser/net/throttle_handler.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2020 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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_BROWSER_NET_THROTTLE_HANDLER_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_NET_THROTTLE_HANDLER_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace content {
|
||||||
|
class NavigationHandle;
|
||||||
|
class NavigationThrottle;
|
||||||
|
} // namespace content
|
||||||
|
|
||||||
|
namespace throttle {
|
||||||
|
|
||||||
|
using NavigationThrottleList =
|
||||||
|
std::vector<std::unique_ptr<content::NavigationThrottle>>;
|
||||||
|
|
||||||
|
void CreateThrottlesForNavigation(content::NavigationHandle* navigation_handle,
|
||||||
|
NavigationThrottleList& throttles);
|
||||||
|
|
||||||
|
} // namespace throttle
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_NET_THROTTLE_HANDLER_H_
|
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
#include "libcef/browser/net_service/cookie_manager_impl.h"
|
||||||
|
|
||||||
|
#include "libcef/common/app_manager.h"
|
||||||
#include "libcef/common/net_service/net_service_util.h"
|
#include "libcef/common/net_service/net_service_util.h"
|
||||||
#include "libcef/common/time_util.h"
|
#include "libcef/common/time_util.h"
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/no_destructor.h"
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/storage_partition.h"
|
#include "content/public/browser/storage_partition.h"
|
||||||
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
#include "services/network/public/mojom/cookie_manager.mojom.h"
|
||||||
@ -115,6 +117,25 @@ void GetCookiesCallbackImpl(
|
|||||||
GetAllCookiesCallbackImpl(visitor, browser_context_getter, cookies);
|
GetAllCookiesCallbackImpl(visitor, browser_context_getter, cookies);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CefCookieManagerImpl::CookieableSchemes MakeSupportedSchemes(
|
||||||
|
const std::vector<CefString>& schemes,
|
||||||
|
bool include_defaults) {
|
||||||
|
std::vector<std::string> all_schemes;
|
||||||
|
for (const auto& scheme : schemes)
|
||||||
|
all_schemes.push_back(scheme);
|
||||||
|
|
||||||
|
if (include_defaults) {
|
||||||
|
// Add default schemes that should always support cookies.
|
||||||
|
// This list should match CookieMonster::kDefaultCookieableSchemes.
|
||||||
|
all_schemes.push_back("http");
|
||||||
|
all_schemes.push_back("https");
|
||||||
|
all_schemes.push_back("ws");
|
||||||
|
all_schemes.push_back("wss");
|
||||||
|
}
|
||||||
|
|
||||||
|
return base::make_optional(all_schemes);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
CefCookieManagerImpl::CefCookieManagerImpl() {}
|
CefCookieManagerImpl::CefCookieManagerImpl() {}
|
||||||
@ -140,19 +161,6 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> all_schemes;
|
|
||||||
for (const auto& scheme : schemes)
|
|
||||||
all_schemes.push_back(scheme);
|
|
||||||
|
|
||||||
if (include_defaults) {
|
|
||||||
// Add default schemes that should always support cookies.
|
|
||||||
// This list should match CookieMonster::kDefaultCookieableSchemes.
|
|
||||||
all_schemes.push_back("http");
|
|
||||||
all_schemes.push_back("https");
|
|
||||||
all_schemes.push_back("ws");
|
|
||||||
all_schemes.push_back("wss");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto browser_context = GetBrowserContext(browser_context_getter_);
|
auto browser_context = GetBrowserContext(browser_context_getter_);
|
||||||
if (!browser_context)
|
if (!browser_context)
|
||||||
return;
|
return;
|
||||||
@ -160,7 +168,8 @@ void CefCookieManagerImpl::SetSupportedSchemes(
|
|||||||
// This will be forwarded to the CookieMonster that lives in the
|
// This will be forwarded to the CookieMonster that lives in the
|
||||||
// NetworkService process when the NetworkContext is created via
|
// NetworkService process when the NetworkContext is created via
|
||||||
// AlloyContentBrowserClient::CreateNetworkContext.
|
// AlloyContentBrowserClient::CreateNetworkContext.
|
||||||
browser_context->set_cookieable_schemes(base::make_optional(all_schemes));
|
browser_context->set_cookieable_schemes(
|
||||||
|
MakeSupportedSchemes(schemes, include_defaults));
|
||||||
RunAsyncCompletionOnUIThread(callback);
|
RunAsyncCompletionOnUIThread(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +352,26 @@ bool CefCookieManagerImpl::FlushStore(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefCookieManagerImpl::CookieableSchemes
|
||||||
|
CefCookieManagerImpl::GetGlobalCookieableSchemes() {
|
||||||
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
|
static base::NoDestructor<CookieableSchemes> schemes(
|
||||||
|
[]() -> CefCookieManagerImpl::CookieableSchemes {
|
||||||
|
if (auto application = CefAppManager::Get()->GetApplication()) {
|
||||||
|
if (auto handler = application->GetBrowserProcessHandler()) {
|
||||||
|
std::vector<CefString> schemes;
|
||||||
|
bool include_defaults = true;
|
||||||
|
handler->GetCookieableSchemes(schemes, include_defaults);
|
||||||
|
return MakeSupportedSchemes(schemes, include_defaults);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return base::nullopt;
|
||||||
|
}());
|
||||||
|
return *schemes;
|
||||||
|
}
|
||||||
|
|
||||||
// CefCookieManager methods ----------------------------------------------------
|
// CefCookieManager methods ----------------------------------------------------
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -38,6 +38,9 @@ class CefCookieManagerImpl : public CefCookieManager {
|
|||||||
CefRefPtr<CefDeleteCookiesCallback> callback) override;
|
CefRefPtr<CefDeleteCookiesCallback> callback) override;
|
||||||
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
bool FlushStore(CefRefPtr<CefCompletionCallback> callback) override;
|
||||||
|
|
||||||
|
using CookieableSchemes = base::Optional<std::vector<std::string>>;
|
||||||
|
static CookieableSchemes GetGlobalCookieableSchemes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Only accessed on the UI thread. Will be non-null after Initialize().
|
// Only accessed on the UI thread. Will be non-null after Initialize().
|
||||||
CefBrowserContext::Getter browser_context_getter_;
|
CefBrowserContext::Getter browser_context_getter_;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "libcef/browser/net_service/login_delegate.h"
|
#include "libcef/browser/net_service/login_delegate.h"
|
||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/net_service/browser_urlrequest_impl.h"
|
#include "libcef/browser/net_service/browser_urlrequest_impl.h"
|
||||||
#include "libcef/browser/thread_util.h"
|
#include "libcef/browser/thread_util.h"
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class AuthCallbackImpl : public CefAuthCallback {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void RunCallbackOnIOThread(
|
void RunCallbackOnIOThread(
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser,
|
CefRefPtr<CefBrowserHostBase> browser,
|
||||||
base::Optional<CefBrowserURLRequest::RequestInfo> url_request_info,
|
base::Optional<CefBrowserURLRequest::RequestInfo> url_request_info,
|
||||||
const net::AuthChallengeInfo& auth_info,
|
const net::AuthChallengeInfo& auth_info,
|
||||||
const GURL& origin_url,
|
const GURL& origin_url,
|
||||||
@ -119,9 +119,9 @@ LoginDelegate::LoginDelegate(const net::AuthChallengeInfo& auth_info,
|
|||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
// May be nullptr for requests originating from CefURLRequest.
|
// May be nullptr for requests originating from CefURLRequest.
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser;
|
CefRefPtr<CefBrowserHostBase> browser;
|
||||||
if (web_contents) {
|
if (web_contents) {
|
||||||
browser = AlloyBrowserHostImpl::GetBrowserForContents(web_contents);
|
browser = CefBrowserHostBase::GetBrowserForContents(web_contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
// |callback| needs to be executed asynchronously.
|
// |callback| needs to be executed asynchronously.
|
||||||
@ -146,7 +146,7 @@ void LoginDelegate::Cancel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoginDelegate::Start(CefRefPtr<AlloyBrowserHostImpl> browser,
|
void LoginDelegate::Start(CefRefPtr<CefBrowserHostBase> browser,
|
||||||
const net::AuthChallengeInfo& auth_info,
|
const net::AuthChallengeInfo& auth_info,
|
||||||
const content::GlobalRequestID& request_id,
|
const content::GlobalRequestID& request_id,
|
||||||
const GURL& origin_url) {
|
const GURL& origin_url) {
|
||||||
|
@ -17,7 +17,7 @@ struct GlobalRequestID;
|
|||||||
class WebContents;
|
class WebContents;
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
|
||||||
class AlloyBrowserHostImpl;
|
class CefBrowserHostBase;
|
||||||
class GURL;
|
class GURL;
|
||||||
|
|
||||||
namespace net_service {
|
namespace net_service {
|
||||||
@ -36,7 +36,7 @@ class LoginDelegate : public content::LoginDelegate {
|
|||||||
void Cancel();
|
void Cancel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Start(CefRefPtr<AlloyBrowserHostImpl> browser,
|
void Start(CefRefPtr<CefBrowserHostBase> browser,
|
||||||
const net::AuthChallengeInfo& auth_info,
|
const net::AuthChallengeInfo& auth_info,
|
||||||
const content::GlobalRequestID& request_id,
|
const content::GlobalRequestID& request_id,
|
||||||
const GURL& origin_url);
|
const GURL& origin_url);
|
||||||
|
@ -52,6 +52,15 @@ bool IsOutOfBlinkCorsEnabled() {
|
|||||||
return !!state;
|
return !!state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CreateProxyHelper(
|
||||||
|
content::WebContents::Getter web_contents_getter,
|
||||||
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
|
||||||
|
std::unique_ptr<InterceptedRequestHandler> request_handler) {
|
||||||
|
ProxyURLLoaderFactory::CreateProxy(web_contents_getter,
|
||||||
|
std::move(loader_receiver),
|
||||||
|
std::move(request_handler));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Owns all of the ProxyURLLoaderFactorys for a given BrowserContext. Since
|
// Owns all of the ProxyURLLoaderFactorys for a given BrowserContext. Since
|
||||||
@ -1270,13 +1279,20 @@ void ProxyURLLoaderFactory::CreateProxy(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
ProxyURLLoaderFactory* ProxyURLLoaderFactory::CreateProxy(
|
void ProxyURLLoaderFactory::CreateProxy(
|
||||||
content::WebContents::Getter web_contents_getter,
|
content::WebContents::Getter web_contents_getter,
|
||||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_receiver,
|
||||||
std::unique_ptr<InterceptedRequestHandler> request_handler) {
|
std::unique_ptr<InterceptedRequestHandler> request_handler) {
|
||||||
CEF_REQUIRE_IOT();
|
|
||||||
DCHECK(request_handler);
|
DCHECK(request_handler);
|
||||||
|
|
||||||
|
if (!CEF_CURRENTLY_ON_IOT()) {
|
||||||
|
CEF_POST_TASK(
|
||||||
|
CEF_IOT,
|
||||||
|
base::BindOnce(CreateProxyHelper, web_contents_getter,
|
||||||
|
std::move(loader_receiver), std::move(request_handler)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto proxy = new ProxyURLLoaderFactory(
|
auto proxy = new ProxyURLLoaderFactory(
|
||||||
std::move(loader_receiver), nullptr,
|
std::move(loader_receiver), nullptr,
|
||||||
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>(),
|
mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient>(),
|
||||||
@ -1284,7 +1300,6 @@ ProxyURLLoaderFactory* ProxyURLLoaderFactory::CreateProxy(
|
|||||||
CEF_POST_TASK(CEF_UIT,
|
CEF_POST_TASK(CEF_UIT,
|
||||||
base::BindOnce(ResourceContextData::AddProxyOnUIThread,
|
base::BindOnce(ResourceContextData::AddProxyOnUIThread,
|
||||||
base::Unretained(proxy), web_contents_getter));
|
base::Unretained(proxy), web_contents_getter));
|
||||||
return proxy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProxyURLLoaderFactory::CreateLoaderAndStart(
|
void ProxyURLLoaderFactory::CreateLoaderAndStart(
|
||||||
|
@ -144,7 +144,7 @@ class ProxyURLLoaderFactory
|
|||||||
std::unique_ptr<InterceptedRequestHandler> request_handler);
|
std::unique_ptr<InterceptedRequestHandler> request_handler);
|
||||||
|
|
||||||
// Create a proxy object on the IO thread.
|
// Create a proxy object on the IO thread.
|
||||||
static ProxyURLLoaderFactory* CreateProxy(
|
static void CreateProxy(
|
||||||
content::WebContents::Getter web_contents_getter,
|
content::WebContents::Getter web_contents_getter,
|
||||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_request,
|
mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_request,
|
||||||
std::unique_ptr<InterceptedRequestHandler> request_handler);
|
std::unique_ptr<InterceptedRequestHandler> request_handler);
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
#include "libcef/browser/net_service/resource_request_handler_wrapper.h"
|
||||||
|
|
||||||
#include "libcef/browser/browser_host_base.h"
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/browser_platform_delegate.h"
|
|
||||||
#include "libcef/browser/context.h"
|
#include "libcef/browser/context.h"
|
||||||
#include "libcef/browser/iothread_state.h"
|
#include "libcef/browser/iothread_state.h"
|
||||||
#include "libcef/browser/net_service/cookie_helper.h"
|
#include "libcef/browser/net_service/cookie_helper.h"
|
||||||
@ -256,7 +255,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
|||||||
int frame_tree_node_id,
|
int frame_tree_node_id,
|
||||||
bool is_navigation,
|
bool is_navigation,
|
||||||
bool is_download,
|
bool is_download,
|
||||||
const url::Origin& request_initiator) {
|
const url::Origin& request_initiator,
|
||||||
|
const base::Closure& unhandled_request_callback) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
browser_context_ = browser_context;
|
browser_context_ = browser_context;
|
||||||
@ -264,7 +264,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
|||||||
CefBrowserContext::FromBrowserContext(browser_context);
|
CefBrowserContext::FromBrowserContext(browser_context);
|
||||||
iothread_state_ = cef_browser_context->iothread_state();
|
iothread_state_ = cef_browser_context->iothread_state();
|
||||||
DCHECK(iothread_state_);
|
DCHECK(iothread_state_);
|
||||||
cookieable_schemes_ = cef_browser_context->cookieable_schemes();
|
cookieable_schemes_ = cef_browser_context->GetCookieableSchemes();
|
||||||
|
|
||||||
// We register to be notified of CEF context or browser destruction so
|
// We register to be notified of CEF context or browser destruction so
|
||||||
// that we can stop accepting new requests and cancel pending/in-progress
|
// that we can stop accepting new requests and cancel pending/in-progress
|
||||||
@ -284,6 +284,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
|||||||
is_navigation_ = is_navigation;
|
is_navigation_ = is_navigation;
|
||||||
is_download_ = is_download;
|
is_download_ = is_download;
|
||||||
request_initiator_ = request_initiator.Serialize();
|
request_initiator_ = request_initiator.Serialize();
|
||||||
|
unhandled_request_callback_ = unhandled_request_callback;
|
||||||
|
|
||||||
// Default values for standard headers.
|
// Default values for standard headers.
|
||||||
accept_language_ = ComputeAcceptLanguageFromPref(
|
accept_language_ = ComputeAcceptLanguageFromPref(
|
||||||
@ -320,6 +321,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
|||||||
bool is_navigation_ = true;
|
bool is_navigation_ = true;
|
||||||
bool is_download_ = false;
|
bool is_download_ = false;
|
||||||
CefString request_initiator_;
|
CefString request_initiator_;
|
||||||
|
base::Closure unhandled_request_callback_;
|
||||||
|
|
||||||
// Default values for standard headers.
|
// Default values for standard headers.
|
||||||
std::string accept_language_;
|
std::string accept_language_;
|
||||||
@ -996,13 +998,14 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler {
|
|||||||
|
|
||||||
CallHandlerOnComplete(state, status);
|
CallHandlerOnComplete(state, status);
|
||||||
|
|
||||||
if (status.error_code != 0 && is_external) {
|
if (status.error_code != 0 && status.error_code != ERR_ABORTED &&
|
||||||
|
is_external) {
|
||||||
bool allow_os_execution = false;
|
bool allow_os_execution = false;
|
||||||
state->handler_->OnProtocolExecution(
|
state->handler_->OnProtocolExecution(
|
||||||
init_state_->browser_, init_state_->frame_,
|
init_state_->browser_, init_state_->frame_,
|
||||||
state->pending_request_.get(), allow_os_execution);
|
state->pending_request_.get(), allow_os_execution);
|
||||||
if (allow_os_execution) {
|
if (allow_os_execution && init_state_->unhandled_request_callback_) {
|
||||||
CefBrowserPlatformDelegate::HandleExternalProtocol(request.url);
|
init_state_->unhandled_request_callback_.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1197,7 +1200,8 @@ void InitOnUIThread(
|
|||||||
scoped_refptr<InterceptedRequestHandlerWrapper::InitHelper> init_helper,
|
scoped_refptr<InterceptedRequestHandlerWrapper::InitHelper> init_helper,
|
||||||
content::WebContents::Getter web_contents_getter,
|
content::WebContents::Getter web_contents_getter,
|
||||||
int frame_tree_node_id,
|
int frame_tree_node_id,
|
||||||
const network::ResourceRequest& request) {
|
const network::ResourceRequest& request,
|
||||||
|
const base::Closure& unhandled_request_callback) {
|
||||||
CEF_REQUIRE_UIT();
|
CEF_REQUIRE_UIT();
|
||||||
|
|
||||||
// May return nullptr if the WebContents was destroyed while this callback was
|
// May return nullptr if the WebContents was destroyed while this callback was
|
||||||
@ -1267,7 +1271,7 @@ void InitOnUIThread(
|
|||||||
init_state->Initialize(browser_context, browserPtr, framePtr,
|
init_state->Initialize(browser_context, browserPtr, framePtr,
|
||||||
render_process_id, request.render_frame_id,
|
render_process_id, request.render_frame_id,
|
||||||
frame_tree_node_id, is_navigation, is_download,
|
frame_tree_node_id, is_navigation, is_download,
|
||||||
request_initiator);
|
request_initiator, unhandled_request_callback);
|
||||||
|
|
||||||
init_helper->MaybeSetInitialized(std::move(init_state));
|
init_helper->MaybeSetInitialized(std::move(init_state));
|
||||||
}
|
}
|
||||||
@ -1304,7 +1308,8 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
|||||||
std::make_unique<InterceptedRequestHandlerWrapper::InitState>();
|
std::make_unique<InterceptedRequestHandlerWrapper::InitState>();
|
||||||
init_state->Initialize(browser_context, browserPtr, framePtr,
|
init_state->Initialize(browser_context, browserPtr, framePtr,
|
||||||
render_process_id, render_frame_id, frame_tree_node_id,
|
render_process_id, render_frame_id, frame_tree_node_id,
|
||||||
is_navigation, is_download, request_initiator);
|
is_navigation, is_download, request_initiator,
|
||||||
|
base::Closure());
|
||||||
|
|
||||||
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
|
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
|
||||||
wrapper->init_helper()->MaybeSetInitialized(std::move(init_state));
|
wrapper->init_helper()->MaybeSetInitialized(std::move(init_state));
|
||||||
@ -1315,11 +1320,12 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
|||||||
std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
||||||
content::WebContents::Getter web_contents_getter,
|
content::WebContents::Getter web_contents_getter,
|
||||||
int frame_tree_node_id,
|
int frame_tree_node_id,
|
||||||
const network::ResourceRequest& request) {
|
const network::ResourceRequest& request,
|
||||||
|
const base::Closure& unhandled_request_callback) {
|
||||||
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
|
auto wrapper = std::make_unique<InterceptedRequestHandlerWrapper>();
|
||||||
CEF_POST_TASK(CEF_UIT, base::BindOnce(InitOnUIThread, wrapper->init_helper(),
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(InitOnUIThread, wrapper->init_helper(),
|
||||||
web_contents_getter, frame_tree_node_id,
|
web_contents_getter, frame_tree_node_id,
|
||||||
request));
|
request, unhandled_request_callback));
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_RESOURCE_REQUEST_HANDLER_WRAPPER_H_
|
#ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_RESOURCE_REQUEST_HANDLER_WRAPPER_H_
|
||||||
#define CEF_LIBCEF_BROWSER_NET_SERVICE_RESOURCE_REQUEST_HANDLER_WRAPPER_H_
|
#define CEF_LIBCEF_BROWSER_NET_SERVICE_RESOURCE_REQUEST_HANDLER_WRAPPER_H_
|
||||||
|
|
||||||
|
#include "base/callback_forward.h"
|
||||||
#include "content/public/browser/web_contents.h"
|
#include "content/public/browser/web_contents.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
@ -41,7 +42,8 @@ std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
|||||||
std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
std::unique_ptr<InterceptedRequestHandler> CreateInterceptedRequestHandler(
|
||||||
content::WebContents::Getter web_contents_getter,
|
content::WebContents::Getter web_contents_getter,
|
||||||
int frame_tree_node_id,
|
int frame_tree_node_id,
|
||||||
const network::ResourceRequest& request);
|
const network::ResourceRequest& request,
|
||||||
|
const base::Closure& unhandled_request_callback);
|
||||||
|
|
||||||
} // namespace net_service
|
} // namespace net_service
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
#include "libcef/browser/image_impl.h"
|
#include "libcef/browser/image_impl.h"
|
||||||
#include "libcef/browser/osr/osr_accessibility_util.h"
|
#include "libcef/browser/osr/osr_accessibility_util.h"
|
||||||
#include "libcef/browser/osr/render_widget_host_view_osr.h"
|
#include "libcef/browser/osr/render_widget_host_view_osr.h"
|
||||||
@ -60,26 +59,25 @@ void CefBrowserPlatformDelegateOsr::RenderViewCreated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateOsr::BrowserCreated(
|
void CefBrowserPlatformDelegateOsr::BrowserCreated(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
||||||
|
|
||||||
if (browser->IsPopup()) {
|
if (browser->IsPopup()) {
|
||||||
// Associate the RenderWidget host view with the browser now because the
|
// Associate the RenderWidget host view with the browser now because the
|
||||||
// browser wasn't known at the time that the host view was created.
|
// browser wasn't known at the time that the host view was created.
|
||||||
content::RenderViewHost* host =
|
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
|
||||||
browser->web_contents()->GetRenderViewHost();
|
|
||||||
DCHECK(host);
|
DCHECK(host);
|
||||||
CefRenderWidgetHostViewOSR* view =
|
CefRenderWidgetHostViewOSR* view =
|
||||||
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
||||||
// |view| will be null if the popup is a DevTools window.
|
// |view| will be null if the popup is a DevTools window.
|
||||||
if (view)
|
if (view) {
|
||||||
view->set_browser_impl(browser);
|
view->set_browser_impl(static_cast<AlloyBrowserHostImpl*>(browser));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateOsr::NotifyBrowserDestroyed() {
|
void CefBrowserPlatformDelegateOsr::NotifyBrowserDestroyed() {
|
||||||
content::WebContents* web_contents = browser_->web_contents();
|
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
|
||||||
content::RenderViewHost* host = web_contents->GetRenderViewHost();
|
|
||||||
if (host) {
|
if (host) {
|
||||||
CefRenderWidgetHostViewOSR* view =
|
CefRenderWidgetHostViewOSR* view =
|
||||||
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
static_cast<CefRenderWidgetHostViewOSR*>(host->GetWidget()->GetView());
|
||||||
@ -92,7 +90,7 @@ void CefBrowserPlatformDelegateOsr::NotifyBrowserDestroyed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateOsr::BrowserDestroyed(
|
void CefBrowserPlatformDelegateOsr::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
||||||
|
|
||||||
view_osr_ = nullptr;
|
view_osr_ = nullptr;
|
||||||
@ -215,14 +213,10 @@ bool CefBrowserPlatformDelegateOsr::IsWindowless() const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateOsr::IsViewsHosted() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateOsr::WasHidden(bool hidden) {
|
void CefBrowserPlatformDelegateOsr::WasHidden(bool hidden) {
|
||||||
// The WebContentsImpl will notify the OSR view.
|
// The WebContentsImpl will notify the OSR view.
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (web_contents) {
|
if (web_contents) {
|
||||||
if (hidden)
|
if (hidden)
|
||||||
web_contents->WasHidden();
|
web_contents->WasHidden();
|
||||||
@ -294,7 +288,7 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragEnter(
|
|||||||
const CefMouseEvent& event,
|
const CefMouseEvent& event,
|
||||||
cef_drag_operations_mask_t allowed_ops) {
|
cef_drag_operations_mask_t allowed_ops) {
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -342,7 +336,7 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -391,7 +385,7 @@ void CefBrowserPlatformDelegateOsr::DragTargetDragOver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() {
|
void CefBrowserPlatformDelegateOsr::DragTargetDragLeave() {
|
||||||
if (current_rvh_for_drag_ != browser_->web_contents()->GetRenderViewHost() ||
|
if (current_rvh_for_drag_ != web_contents_->GetRenderViewHost() ||
|
||||||
!drag_data_) {
|
!drag_data_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -409,7 +403,7 @@ void CefBrowserPlatformDelegateOsr::DragTargetDrop(const CefMouseEvent& event) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -511,7 +505,7 @@ void CefBrowserPlatformDelegateOsr::DragSourceEndedAt(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -552,7 +546,7 @@ void CefBrowserPlatformDelegateOsr::DragSourceSystemDragEnded() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
content::WebContentsImpl* web_contents =
|
content::WebContentsImpl* web_contents =
|
||||||
static_cast<content::WebContentsImpl*>(browser_->web_contents());
|
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -600,14 +594,13 @@ gfx::Point CefBrowserPlatformDelegateOsr::GetParentScreenPoint(
|
|||||||
|
|
||||||
CefRenderWidgetHostViewOSR* CefBrowserPlatformDelegateOsr::GetOSRHostView()
|
CefRenderWidgetHostViewOSR* CefBrowserPlatformDelegateOsr::GetOSRHostView()
|
||||||
const {
|
const {
|
||||||
content::WebContents* web_contents = browser_->web_contents();
|
|
||||||
CefRenderWidgetHostViewOSR* fs_view =
|
CefRenderWidgetHostViewOSR* fs_view =
|
||||||
static_cast<CefRenderWidgetHostViewOSR*>(
|
static_cast<CefRenderWidgetHostViewOSR*>(
|
||||||
web_contents->GetFullscreenRenderWidgetHostView());
|
web_contents_->GetFullscreenRenderWidgetHostView());
|
||||||
if (fs_view)
|
if (fs_view)
|
||||||
return fs_view;
|
return fs_view;
|
||||||
|
|
||||||
content::RenderViewHost* host = web_contents->GetRenderViewHost();
|
content::RenderViewHost* host = web_contents_->GetRenderViewHost();
|
||||||
if (host) {
|
if (host) {
|
||||||
return static_cast<CefRenderWidgetHostViewOSR*>(
|
return static_cast<CefRenderWidgetHostViewOSR*>(
|
||||||
host->GetWidget()->GetView());
|
host->GetWidget()->GetView());
|
||||||
|
@ -27,9 +27,9 @@ class CefBrowserPlatformDelegateOsr
|
|||||||
void WebContentsCreated(content::WebContents* web_contents,
|
void WebContentsCreated(content::WebContents* web_contents,
|
||||||
bool owned) override;
|
bool owned) override;
|
||||||
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
|
||||||
void BrowserCreated(AlloyBrowserHostImpl* browser) override;
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||||
void NotifyBrowserDestroyed() override;
|
void NotifyBrowserDestroyed() override;
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
SkColor GetBackgroundColor() const override;
|
SkColor GetBackgroundColor() const override;
|
||||||
void WasResized() override;
|
void WasResized() override;
|
||||||
void SendKeyEvent(const CefKeyEvent& event) override;
|
void SendKeyEvent(const CefKeyEvent& event) override;
|
||||||
@ -54,7 +54,6 @@ class CefBrowserPlatformDelegateOsr
|
|||||||
override;
|
override;
|
||||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||||
bool IsWindowless() const override;
|
bool IsWindowless() const override;
|
||||||
bool IsViewsHosted() const override;
|
|
||||||
void WasHidden(bool hidden) override;
|
void WasHidden(bool hidden) override;
|
||||||
void NotifyScreenInfoChanged() override;
|
void NotifyScreenInfoChanged() override;
|
||||||
void Invalidate(cef_paint_element_type_t type) override;
|
void Invalidate(cef_paint_element_type_t type) override;
|
||||||
|
@ -298,4 +298,12 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
|||||||
return factory.CreateSyncable(registry.get());
|
return factory.CreateSyncable(registry.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetLanguagePrefs(Profile* profile) {
|
||||||
|
const std::string& accept_language_list = GetAcceptLanguageList(profile);
|
||||||
|
if (!accept_language_list.empty()) {
|
||||||
|
profile->GetPrefs()->SetString(language::prefs::kAcceptLanguages,
|
||||||
|
accept_language_list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace browser_prefs
|
} // namespace browser_prefs
|
||||||
|
@ -25,6 +25,9 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
|||||||
const base::FilePath& cache_path,
|
const base::FilePath& cache_path,
|
||||||
bool persist_user_preferences);
|
bool persist_user_preferences);
|
||||||
|
|
||||||
|
// Set language preferences on |profile|.
|
||||||
|
void SetLanguagePrefs(Profile* profile);
|
||||||
|
|
||||||
} // namespace browser_prefs
|
} // namespace browser_prefs
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_BROWSER_PREFS_BROWSER_PREFS_H_
|
#endif // CEF_LIBCEF_BROWSER_PREFS_BROWSER_PREFS_H_
|
||||||
|
@ -602,7 +602,6 @@ void CefRequestContextImpl::OnRenderFrameDeleted(int render_process_id,
|
|||||||
// static
|
// static
|
||||||
CefRefPtr<CefRequestContextImpl>
|
CefRefPtr<CefRequestContextImpl>
|
||||||
CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) {
|
CefRequestContextImpl::GetOrCreateRequestContext(const Config& config) {
|
||||||
// TODO(chrome-runtime): Add support for this method.
|
|
||||||
if (config.is_global ||
|
if (config.is_global ||
|
||||||
(config.other && config.other->IsGlobal() && !config.handler)) {
|
(config.other && config.other->IsGlobal() && !config.handler)) {
|
||||||
// Return the singleton global context.
|
// Return the singleton global context.
|
||||||
|
@ -80,7 +80,7 @@ void CefBrowserPlatformDelegateViews::WebContentsDestroyed(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateViews::BrowserCreated(
|
void CefBrowserPlatformDelegateViews::BrowserCreated(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserCreated(browser);
|
||||||
|
|
||||||
native_delegate_->BrowserCreated(browser);
|
native_delegate_->BrowserCreated(browser);
|
||||||
@ -102,7 +102,7 @@ void CefBrowserPlatformDelegateViews::NotifyBrowserDestroyed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateViews::BrowserDestroyed(
|
void CefBrowserPlatformDelegateViews::BrowserDestroyed(
|
||||||
AlloyBrowserHostImpl* browser) {
|
CefBrowserHostBase* browser) {
|
||||||
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
CefBrowserPlatformDelegateAlloy::BrowserDestroyed(browser);
|
||||||
|
|
||||||
browser_view_->BrowserDestroyed(browser);
|
browser_view_->BrowserDestroyed(browser);
|
||||||
@ -161,7 +161,7 @@ void CefBrowserPlatformDelegateViews::PopupWebContentsCreated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserPlatformDelegateViews::PopupBrowserCreated(
|
void CefBrowserPlatformDelegateViews::PopupBrowserCreated(
|
||||||
AlloyBrowserHostImpl* new_browser,
|
CefBrowserHostBase* new_browser,
|
||||||
bool is_devtools) {
|
bool is_devtools) {
|
||||||
CefRefPtr<CefBrowserView> new_browser_view =
|
CefRefPtr<CefBrowserView> new_browser_view =
|
||||||
CefBrowserView::GetForBrowser(new_browser);
|
CefBrowserView::GetForBrowser(new_browser);
|
||||||
@ -264,10 +264,6 @@ CefBrowserPlatformDelegateViews::CreateMenuRunner() {
|
|||||||
return base::WrapUnique(new CefMenuRunnerViews(browser_view_.get()));
|
return base::WrapUnique(new CefMenuRunnerViews(browser_view_.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateViews::IsWindowless() const {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefBrowserPlatformDelegateViews::IsViewsHosted() const {
|
bool CefBrowserPlatformDelegateViews::IsViewsHosted() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,10 @@ class CefBrowserPlatformDelegateViews
|
|||||||
void WebContentsCreated(content::WebContents* web_contents,
|
void WebContentsCreated(content::WebContents* web_contents,
|
||||||
bool owned) override;
|
bool owned) override;
|
||||||
void WebContentsDestroyed(content::WebContents* web_contents) override;
|
void WebContentsDestroyed(content::WebContents* web_contents) override;
|
||||||
void BrowserCreated(AlloyBrowserHostImpl* browser) override;
|
void BrowserCreated(CefBrowserHostBase* browser) override;
|
||||||
void NotifyBrowserCreated() override;
|
void NotifyBrowserCreated() override;
|
||||||
void NotifyBrowserDestroyed() override;
|
void NotifyBrowserDestroyed() override;
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser) override;
|
void BrowserDestroyed(CefBrowserHostBase* browser) override;
|
||||||
bool CreateHostWindow() override;
|
bool CreateHostWindow() override;
|
||||||
void CloseHostWindow() override;
|
void CloseHostWindow() override;
|
||||||
CefWindowHandle GetHostWindowHandle() const override;
|
CefWindowHandle GetHostWindowHandle() const override;
|
||||||
@ -39,7 +39,7 @@ class CefBrowserPlatformDelegateViews
|
|||||||
content::WebContents* new_web_contents,
|
content::WebContents* new_web_contents,
|
||||||
CefBrowserPlatformDelegate* new_platform_delegate,
|
CefBrowserPlatformDelegate* new_platform_delegate,
|
||||||
bool is_devtools) override;
|
bool is_devtools) override;
|
||||||
void PopupBrowserCreated(AlloyBrowserHostImpl* new_browser,
|
void PopupBrowserCreated(CefBrowserHostBase* new_browser,
|
||||||
bool is_devtools) override;
|
bool is_devtools) override;
|
||||||
SkColor GetBackgroundColor() const override;
|
SkColor GetBackgroundColor() const override;
|
||||||
void WasResized() override;
|
void WasResized() override;
|
||||||
@ -64,7 +64,6 @@ class CefBrowserPlatformDelegateViews
|
|||||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
||||||
override;
|
override;
|
||||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||||
bool IsWindowless() const override;
|
|
||||||
bool IsViewsHosted() const override;
|
bool IsViewsHosted() const override;
|
||||||
gfx::Point GetDialogPosition(const gfx::Size& size) override;
|
gfx::Point GetDialogPosition(const gfx::Size& size) override;
|
||||||
gfx::Size GetMaximumDialogSize() override;
|
gfx::Size GetMaximumDialogSize() override;
|
||||||
|
@ -29,7 +29,9 @@ CefRefPtr<CefBrowserView> CefBrowserView::CreateBrowserView(
|
|||||||
// static
|
// static
|
||||||
CefRefPtr<CefBrowserView> CefBrowserView::GetForBrowser(
|
CefRefPtr<CefBrowserView> CefBrowserView::GetForBrowser(
|
||||||
CefRefPtr<CefBrowser> browser) {
|
CefRefPtr<CefBrowser> browser) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||||
|
|
||||||
AlloyBrowserHostImpl* browser_impl =
|
AlloyBrowserHostImpl* browser_impl =
|
||||||
static_cast<AlloyBrowserHostImpl*>(browser.get());
|
static_cast<AlloyBrowserHostImpl*>(browser.get());
|
||||||
if (browser_impl && browser_impl->IsViewsHosted())
|
if (browser_impl && browser_impl->IsViewsHosted())
|
||||||
@ -45,10 +47,9 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::Create(
|
|||||||
CefRefPtr<CefDictionaryValue> extra_info,
|
CefRefPtr<CefDictionaryValue> extra_info,
|
||||||
CefRefPtr<CefRequestContext> request_context,
|
CefRefPtr<CefRequestContext> request_context,
|
||||||
CefRefPtr<CefBrowserViewDelegate> delegate) {
|
CefRefPtr<CefBrowserViewDelegate> delegate) {
|
||||||
// TODO(chrome-runtime): Add support for this method.
|
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
|
|
||||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||||
|
|
||||||
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
|
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
|
||||||
browser_view->SetPendingBrowserCreateParams(client, url, settings, extra_info,
|
browser_view->SetPendingBrowserCreateParams(client, url, settings, extra_info,
|
||||||
request_context);
|
request_context);
|
||||||
@ -61,7 +62,9 @@ CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::Create(
|
|||||||
CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::CreateForPopup(
|
CefRefPtr<CefBrowserViewImpl> CefBrowserViewImpl::CreateForPopup(
|
||||||
const CefBrowserSettings& settings,
|
const CefBrowserSettings& settings,
|
||||||
CefRefPtr<CefBrowserViewDelegate> delegate) {
|
CefRefPtr<CefBrowserViewDelegate> delegate) {
|
||||||
|
REQUIRE_ALLOY_RUNTIME();
|
||||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||||
|
|
||||||
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
|
CefRefPtr<CefBrowserViewImpl> browser_view = new CefBrowserViewImpl(delegate);
|
||||||
browser_view->Initialize();
|
browser_view->Initialize();
|
||||||
browser_view->SetDefaults(settings);
|
browser_view->SetDefaults(settings);
|
||||||
@ -75,13 +78,13 @@ void CefBrowserViewImpl::WebContentsCreated(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserViewImpl::BrowserCreated(
|
void CefBrowserViewImpl::BrowserCreated(
|
||||||
AlloyBrowserHostImpl* browser,
|
CefBrowserHostBase* browser,
|
||||||
base::RepeatingClosure on_bounds_changed) {
|
base::RepeatingClosure on_bounds_changed) {
|
||||||
browser_ = browser;
|
browser_ = browser;
|
||||||
on_bounds_changed_ = on_bounds_changed;
|
on_bounds_changed_ = on_bounds_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserViewImpl::BrowserDestroyed(AlloyBrowserHostImpl* browser) {
|
void CefBrowserViewImpl::BrowserDestroyed(CefBrowserHostBase* browser) {
|
||||||
DCHECK_EQ(browser, browser_);
|
DCHECK_EQ(browser, browser_);
|
||||||
browser_ = nullptr;
|
browser_ = nullptr;
|
||||||
|
|
||||||
@ -145,10 +148,10 @@ void CefBrowserViewImpl::Detach() {
|
|||||||
if (browser_) {
|
if (browser_) {
|
||||||
// |browser_| will disappear when WindowDestroyed() indirectly calls
|
// |browser_| will disappear when WindowDestroyed() indirectly calls
|
||||||
// BrowserDestroyed() so keep a reference.
|
// BrowserDestroyed() so keep a reference.
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser = browser_;
|
CefRefPtr<CefBrowserHostBase> browser = browser_;
|
||||||
|
|
||||||
// Force the browser to be destroyed.
|
// Force the browser to be destroyed.
|
||||||
browser->WindowDestroyed();
|
static_cast<AlloyBrowserHostImpl*>(browser.get())->WindowDestroyed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +191,7 @@ void CefBrowserViewImpl::SetPendingBrowserCreateParams(
|
|||||||
CefRefPtr<CefDictionaryValue> extra_info,
|
CefRefPtr<CefDictionaryValue> extra_info,
|
||||||
CefRefPtr<CefRequestContext> request_context) {
|
CefRefPtr<CefRequestContext> request_context) {
|
||||||
DCHECK(!pending_browser_create_params_);
|
DCHECK(!pending_browser_create_params_);
|
||||||
pending_browser_create_params_.reset(new CefBrowserHostBase::CreateParams());
|
pending_browser_create_params_.reset(new CefBrowserCreateParams());
|
||||||
pending_browser_create_params_->client = client;
|
pending_browser_create_params_->client = client;
|
||||||
pending_browser_create_params_->url = GURL(url.ToString());
|
pending_browser_create_params_->url = GURL(url.ToString());
|
||||||
pending_browser_create_params_->settings = settings;
|
pending_browser_create_params_->settings = settings;
|
||||||
|
@ -9,14 +9,15 @@
|
|||||||
#include "include/cef_client.h"
|
#include "include/cef_client.h"
|
||||||
#include "include/views/cef_browser_view.h"
|
#include "include/views/cef_browser_view.h"
|
||||||
#include "include/views/cef_browser_view_delegate.h"
|
#include "include/views/cef_browser_view_delegate.h"
|
||||||
|
#include "libcef/browser/browser_host_base.h"
|
||||||
#include "libcef/browser/alloy/alloy_browser_host_impl.h"
|
|
||||||
#include "libcef/browser/views/browser_view_view.h"
|
#include "libcef/browser/views/browser_view_view.h"
|
||||||
#include "libcef/browser/views/view_impl.h"
|
#include "libcef/browser/views/view_impl.h"
|
||||||
|
|
||||||
#include "base/callback_forward.h"
|
#include "base/callback_forward.h"
|
||||||
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||||
|
|
||||||
|
class CefBrowserHostBase;
|
||||||
|
|
||||||
class CefBrowserViewImpl : public CefViewImpl<CefBrowserViewView,
|
class CefBrowserViewImpl : public CefViewImpl<CefBrowserViewView,
|
||||||
CefBrowserView,
|
CefBrowserView,
|
||||||
CefBrowserViewDelegate>,
|
CefBrowserViewDelegate>,
|
||||||
@ -44,9 +45,9 @@ class CefBrowserViewImpl : public CefViewImpl<CefBrowserViewView,
|
|||||||
|
|
||||||
// Called from CefBrowserPlatformDelegateViews.
|
// Called from CefBrowserPlatformDelegateViews.
|
||||||
void WebContentsCreated(content::WebContents* web_contents);
|
void WebContentsCreated(content::WebContents* web_contents);
|
||||||
void BrowserCreated(AlloyBrowserHostImpl* browser,
|
void BrowserCreated(CefBrowserHostBase* browser,
|
||||||
base::RepeatingClosure on_bounds_changed);
|
base::RepeatingClosure on_bounds_changed);
|
||||||
void BrowserDestroyed(AlloyBrowserHostImpl* browser);
|
void BrowserDestroyed(CefBrowserHostBase* browser);
|
||||||
|
|
||||||
// Called to handle accelerators when the event is unhandled by the web
|
// Called to handle accelerators when the event is unhandled by the web
|
||||||
// content and the browser client.
|
// content and the browser client.
|
||||||
@ -95,10 +96,9 @@ class CefBrowserViewImpl : public CefViewImpl<CefBrowserViewView,
|
|||||||
bool HandleAccelerator(const content::NativeWebKeyboardEvent& event,
|
bool HandleAccelerator(const content::NativeWebKeyboardEvent& event,
|
||||||
views::FocusManager* focus_manager);
|
views::FocusManager* focus_manager);
|
||||||
|
|
||||||
std::unique_ptr<CefBrowserHostBase::CreateParams>
|
std::unique_ptr<CefBrowserCreateParams> pending_browser_create_params_;
|
||||||
pending_browser_create_params_;
|
|
||||||
|
|
||||||
CefRefPtr<AlloyBrowserHostImpl> browser_;
|
CefRefPtr<CefBrowserHostBase> browser_;
|
||||||
|
|
||||||
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
|
views::UnhandledKeyboardEventHandler unhandled_keyboard_event_handler_;
|
||||||
bool ignore_next_char_event_ = false;
|
bool ignore_next_char_event_ = false;
|
||||||
|
@ -125,6 +125,10 @@ const char kDevToolsProtocolLogFile[] = "devtools-protocol-log-file";
|
|||||||
// Enable use of the Chrome runtime in CEF. See issue #2969 for details.
|
// Enable use of the Chrome runtime in CEF. See issue #2969 for details.
|
||||||
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
|
const char kEnableChromeRuntime[] = "enable-chrome-runtime";
|
||||||
|
|
||||||
|
// Delegate all login requests to the client GetAuthCredentials callback when
|
||||||
|
// using the Chrome runtime.
|
||||||
|
const char kDisableChromeLoginPrompt[] = "disable-chrome-login-prompt";
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
// Path to the framework directory.
|
// Path to the framework directory.
|
||||||
const char kFrameworkDirPath[] = "framework-dir-path";
|
const char kFrameworkDirPath[] = "framework-dir-path";
|
||||||
|
@ -55,6 +55,7 @@ extern const char kEnablePrintPreview[];
|
|||||||
extern const char kDisableNewBrowserInfoTimeout[];
|
extern const char kDisableNewBrowserInfoTimeout[];
|
||||||
extern const char kDevToolsProtocolLogFile[];
|
extern const char kDevToolsProtocolLogFile[];
|
||||||
extern const char kEnableChromeRuntime[];
|
extern const char kEnableChromeRuntime[];
|
||||||
|
extern const char kDisableChromeLoginPrompt[];
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
extern const char kFrameworkDirPath[];
|
extern const char kFrameworkDirPath[];
|
||||||
|
@ -7,16 +7,29 @@
|
|||||||
|
|
||||||
#include "libcef/browser/chrome/chrome_browser_context.h"
|
#include "libcef/browser/chrome/chrome_browser_context.h"
|
||||||
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
#include "libcef/browser/chrome/chrome_content_browser_client_cef.h"
|
||||||
|
#include "libcef/common/cef_switches.h"
|
||||||
|
#include "libcef/common/command_line_impl.h"
|
||||||
#include "libcef/common/crash_reporting.h"
|
#include "libcef/common/crash_reporting.h"
|
||||||
#include "libcef/common/resource_util.h"
|
#include "libcef/common/resource_util.h"
|
||||||
|
#include "libcef/renderer/chrome/chrome_content_renderer_client_cef.h"
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/lazy_instance.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
|
#include "sandbox/policy/switches.h"
|
||||||
|
#include "services/service_manager/embedder/switches.h"
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
#include "libcef/common/util_mac.h"
|
#include "libcef/common/util_mac.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
base::LazyInstance<ChromeContentRendererClientCef>::DestructorAtExit
|
||||||
|
g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner,
|
ChromeMainDelegateCef::ChromeMainDelegateCef(CefMainRunnerHandler* runner,
|
||||||
CefSettings* settings,
|
CefSettings* settings,
|
||||||
CefRefPtr<CefApp> application)
|
CefRefPtr<CefApp> application)
|
||||||
@ -34,21 +47,71 @@ ChromeMainDelegateCef::~ChromeMainDelegateCef() = default;
|
|||||||
bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
|
bool ChromeMainDelegateCef::BasicStartupComplete(int* exit_code) {
|
||||||
// Returns false if startup should proceed.
|
// Returns false if startup should proceed.
|
||||||
bool result = ChromeMainDelegate::BasicStartupComplete(exit_code);
|
bool result = ChromeMainDelegate::BasicStartupComplete(exit_code);
|
||||||
|
if (result)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
#if defined(OS_POSIX)
|
#if defined(OS_POSIX)
|
||||||
// Read the crash configuration file. Platforms using Breakpad also add a
|
// Read the crash configuration file. Platforms using Breakpad also add a
|
||||||
// command-line switch. On Windows this is done from chrome_elf.
|
// command-line switch. On Windows this is done from chrome_elf.
|
||||||
crash_reporting::BasicStartupComplete(
|
crash_reporting::BasicStartupComplete(command_line);
|
||||||
base::CommandLine::ForCurrentProcess());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const std::string& process_type =
|
||||||
|
command_line->GetSwitchValueASCII(switches::kProcessType);
|
||||||
|
if (process_type.empty()) {
|
||||||
|
// In the browser process. Populate the global command-line object.
|
||||||
|
// TODO(chrome-runtime): Copy more settings from AlloyMainDelegate and test.
|
||||||
|
if (settings_->command_line_args_disabled) {
|
||||||
|
// Remove any existing command-line arguments.
|
||||||
|
base::CommandLine::StringVector argv;
|
||||||
|
argv.push_back(command_line->GetProgram().value());
|
||||||
|
command_line->InitFromArgv(argv);
|
||||||
|
|
||||||
|
const base::CommandLine::SwitchMap& map = command_line->GetSwitches();
|
||||||
|
const_cast<base::CommandLine::SwitchMap*>(&map)->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool no_sandbox = settings_->no_sandbox ? true : false;
|
||||||
|
|
||||||
|
if (no_sandbox) {
|
||||||
|
command_line->AppendSwitch(sandbox::policy::switches::kNoSandbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings_->javascript_flags.length > 0) {
|
||||||
|
command_line->AppendSwitchASCII(switches::kJavaScriptFlags,
|
||||||
|
CefString(&settings_->javascript_flags));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings_->remote_debugging_port >= 1024 &&
|
||||||
|
settings_->remote_debugging_port <= 65535) {
|
||||||
|
command_line->AppendSwitchASCII(
|
||||||
|
switches::kRemoteDebuggingPort,
|
||||||
|
base::NumberToString(settings_->remote_debugging_port));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings_->uncaught_exception_stack_size > 0) {
|
||||||
|
command_line->AppendSwitchASCII(
|
||||||
|
switches::kUncaughtExceptionStackSize,
|
||||||
|
base::NumberToString(settings_->uncaught_exception_stack_size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (application_) {
|
||||||
|
// Give the application a chance to view/modify the command line.
|
||||||
|
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
||||||
|
new CefCommandLineImpl(command_line, false, false));
|
||||||
|
application_->OnBeforeCommandLineProcessing(process_type,
|
||||||
|
commandLinePtr.get());
|
||||||
|
commandLinePtr->Detach(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
util_mac::BasicStartupComplete();
|
util_mac::BasicStartupComplete();
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChromeMainDelegateCef::PreSandboxStartup() {
|
void ChromeMainDelegateCef::PreSandboxStartup() {
|
||||||
@ -124,6 +187,11 @@ ChromeMainDelegateCef::CreateContentBrowserClient() {
|
|||||||
return chrome_content_browser_client_.get();
|
return chrome_content_browser_client_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
content::ContentRendererClient*
|
||||||
|
ChromeMainDelegateCef::CreateContentRendererClient() {
|
||||||
|
return g_chrome_content_renderer_client.Pointer();
|
||||||
|
}
|
||||||
|
|
||||||
CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
|
CefRefPtr<CefRequestContext> ChromeMainDelegateCef::GetGlobalRequestContext() {
|
||||||
auto browser_client = content_browser_client();
|
auto browser_client = content_browser_client();
|
||||||
if (browser_client)
|
if (browser_client)
|
||||||
@ -164,15 +232,17 @@ ChromeMainDelegateCef::GetUserBlockingTaskRunner() {
|
|||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner>
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
ChromeMainDelegateCef::GetRenderTaskRunner() {
|
ChromeMainDelegateCef::GetRenderTaskRunner() {
|
||||||
// TODO: Implement.
|
auto renderer_client = content_renderer_client();
|
||||||
NOTREACHED();
|
if (renderer_client)
|
||||||
|
return renderer_client->render_task_runner();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner>
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
ChromeMainDelegateCef::GetWebWorkerTaskRunner() {
|
ChromeMainDelegateCef::GetWebWorkerTaskRunner() {
|
||||||
// TODO: Implement.
|
auto renderer_client = content_renderer_client();
|
||||||
NOTREACHED();
|
if (renderer_client)
|
||||||
|
return renderer_client->GetCurrentTaskRunner();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,3 +251,10 @@ ChromeContentBrowserClientCef* ChromeMainDelegateCef::content_browser_client()
|
|||||||
return static_cast<ChromeContentBrowserClientCef*>(
|
return static_cast<ChromeContentBrowserClientCef*>(
|
||||||
chrome_content_browser_client_.get());
|
chrome_content_browser_client_.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChromeContentRendererClientCef* ChromeMainDelegateCef::content_renderer_client()
|
||||||
|
const {
|
||||||
|
if (!g_chrome_content_renderer_client.IsCreated())
|
||||||
|
return nullptr;
|
||||||
|
return g_chrome_content_renderer_client.Pointer();
|
||||||
|
}
|
@ -18,6 +18,7 @@
|
|||||||
#include "chrome/app/chrome_main_delegate.h"
|
#include "chrome/app/chrome_main_delegate.h"
|
||||||
|
|
||||||
class ChromeContentBrowserClientCef;
|
class ChromeContentBrowserClientCef;
|
||||||
|
class ChromeContentRendererClientCef;
|
||||||
|
|
||||||
// CEF override of ChromeMainDelegate
|
// CEF override of ChromeMainDelegate
|
||||||
class ChromeMainDelegateCef : public ChromeMainDelegate,
|
class ChromeMainDelegateCef : public ChromeMainDelegate,
|
||||||
@ -43,6 +44,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
|
|||||||
#endif
|
#endif
|
||||||
content::ContentClient* CreateContentClient() override;
|
content::ContentClient* CreateContentClient() override;
|
||||||
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
content::ContentBrowserClient* CreateContentBrowserClient() override;
|
||||||
|
content::ContentRendererClient* CreateContentRendererClient() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// CefAppManager overrides.
|
// CefAppManager overrides.
|
||||||
@ -66,6 +68,7 @@ class ChromeMainDelegateCef : public ChromeMainDelegate,
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ChromeContentBrowserClientCef* content_browser_client() const;
|
ChromeContentBrowserClientCef* content_browser_client() const;
|
||||||
|
ChromeContentRendererClientCef* content_renderer_client() const;
|
||||||
|
|
||||||
CefMainRunnerHandler* const runner_;
|
CefMainRunnerHandler* const runner_;
|
||||||
CefSettings* const settings_;
|
CefSettings* const settings_;
|
||||||
|
@ -7,12 +7,16 @@
|
|||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/location.h"
|
#include "base/location.h"
|
||||||
|
#include "base/logging.h"
|
||||||
|
|
||||||
bool CefCurrentlyOn(CefThreadId threadId) {
|
bool CefCurrentlyOn(CefThreadId threadId) {
|
||||||
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
scoped_refptr<base::SequencedTaskRunner> task_runner =
|
||||||
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
CefTaskRunnerImpl::GetTaskRunner(threadId);
|
||||||
if (task_runner.get())
|
if (task_runner.get()) {
|
||||||
return task_runner->RunsTasksInCurrentSequence();
|
return task_runner->RunsTasksInCurrentSequence();
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,6 +27,8 @@ bool CefPostTask(CefThreadId threadId, CefRefPtr<CefTask> task) {
|
|||||||
return task_runner->PostTask(FROM_HERE,
|
return task_runner->PostTask(FROM_HERE,
|
||||||
base::Bind(&CefTask::Execute, task.get()));
|
base::Bind(&CefTask::Execute, task.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,5 +42,7 @@ bool CefPostDelayedTask(CefThreadId threadId,
|
|||||||
FROM_HERE, base::Bind(&CefTask::Execute, task.get()),
|
FROM_HERE, base::Bind(&CefTask::Execute, task.get()),
|
||||||
base::TimeDelta::FromMilliseconds(delay_ms));
|
base::TimeDelta::FromMilliseconds(delay_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG(WARNING) << "No task runner for threadId " << threadId;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,6 @@ CefRefPtr<CefURLRequest> CefURLRequest::Create(
|
|||||||
CefRefPtr<CefRequest> request,
|
CefRefPtr<CefRequest> request,
|
||||||
CefRefPtr<CefURLRequestClient> client,
|
CefRefPtr<CefURLRequestClient> client,
|
||||||
CefRefPtr<CefRequestContext> request_context) {
|
CefRefPtr<CefRequestContext> request_context) {
|
||||||
// TODO(chrome-runtime): Add support for this method.
|
|
||||||
REQUIRE_ALLOY_RUNTIME();
|
|
||||||
|
|
||||||
if (!request.get() || !client.get()) {
|
if (!request.get() || !client.get()) {
|
||||||
NOTREACHED() << "called with invalid parameters";
|
NOTREACHED() << "called with invalid parameters";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -28,19 +28,16 @@
|
|||||||
#include "libcef/common/cef_switches.h"
|
#include "libcef/common/cef_switches.h"
|
||||||
#include "libcef/common/extensions/extensions_client.h"
|
#include "libcef/common/extensions/extensions_client.h"
|
||||||
#include "libcef/common/extensions/extensions_util.h"
|
#include "libcef/common/extensions/extensions_util.h"
|
||||||
#include "libcef/common/net/scheme_info.h"
|
|
||||||
#include "libcef/common/request_impl.h"
|
#include "libcef/common/request_impl.h"
|
||||||
#include "libcef/common/values_impl.h"
|
|
||||||
#include "libcef/features/runtime_checks.h"
|
#include "libcef/features/runtime_checks.h"
|
||||||
#include "libcef/renderer/blink_glue.h"
|
#include "libcef/renderer/alloy/alloy_render_frame_observer.h"
|
||||||
|
#include "libcef/renderer/alloy/alloy_render_thread_observer.h"
|
||||||
|
#include "libcef/renderer/alloy/url_loader_throttle_provider_impl.h"
|
||||||
#include "libcef/renderer/browser_impl.h"
|
#include "libcef/renderer/browser_impl.h"
|
||||||
|
#include "libcef/renderer/browser_manager.h"
|
||||||
#include "libcef/renderer/extensions/extensions_renderer_client.h"
|
#include "libcef/renderer/extensions/extensions_renderer_client.h"
|
||||||
#include "libcef/renderer/extensions/print_render_frame_helper_delegate.h"
|
#include "libcef/renderer/extensions/print_render_frame_helper_delegate.h"
|
||||||
#include "libcef/renderer/render_frame_observer.h"
|
|
||||||
#include "libcef/renderer/render_thread_observer.h"
|
|
||||||
#include "libcef/renderer/thread_util.h"
|
#include "libcef/renderer/thread_util.h"
|
||||||
#include "libcef/renderer/url_loader_throttle_provider_impl.h"
|
|
||||||
#include "libcef/renderer/v8_impl.h"
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
@ -48,7 +45,6 @@
|
|||||||
#include "base/metrics/user_metrics_action.h"
|
#include "base/metrics/user_metrics_action.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "base/task/post_task.h"
|
#include "base/task/post_task.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@ -145,29 +141,9 @@ bool IsStandaloneExtensionProcess() {
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Placeholder object for guest views.
|
|
||||||
class CefGuestView : public content::RenderViewObserver {
|
|
||||||
public:
|
|
||||||
CefGuestView(content::RenderView* render_view, bool is_windowless)
|
|
||||||
: content::RenderViewObserver(render_view),
|
|
||||||
is_windowless_(is_windowless) {}
|
|
||||||
|
|
||||||
bool is_windowless() const { return is_windowless_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
// RenderViewObserver methods.
|
|
||||||
void OnDestruct() override {
|
|
||||||
AlloyContentRendererClient::Get()->OnGuestViewDestroyed(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool is_windowless_;
|
|
||||||
};
|
|
||||||
|
|
||||||
AlloyContentRendererClient::AlloyContentRendererClient()
|
AlloyContentRendererClient::AlloyContentRendererClient()
|
||||||
: main_entry_time_(base::TimeTicks::Now()),
|
: main_entry_time_(base::TimeTicks::Now()),
|
||||||
devtools_agent_count_(0),
|
browser_manager_(new CefBrowserManager) {
|
||||||
uncaught_exception_stack_size_(0),
|
|
||||||
single_process_cleanup_complete_(false) {
|
|
||||||
if (extensions::ExtensionsEnabled()) {
|
if (extensions::ExtensionsEnabled()) {
|
||||||
extensions_client_.reset(new extensions::CefExtensionsClient);
|
extensions_client_.reset(new extensions::CefExtensionsClient);
|
||||||
extensions::ExtensionsClient::Set(extensions_client_.get());
|
extensions::ExtensionsClient::Set(extensions_client_.get());
|
||||||
@ -187,139 +163,6 @@ AlloyContentRendererClient* AlloyContentRendererClient::Get() {
|
|||||||
CefAppManager::Get()->GetContentClient()->renderer());
|
CefAppManager::Get()->GetContentClient()->renderer());
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> AlloyContentRendererClient::GetBrowserForView(
|
|
||||||
content::RenderView* view) {
|
|
||||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
|
||||||
|
|
||||||
BrowserMap::const_iterator it = browsers_.find(view);
|
|
||||||
if (it != browsers_.end())
|
|
||||||
return it->second;
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> AlloyContentRendererClient::GetBrowserForMainFrame(
|
|
||||||
blink::WebFrame* frame) {
|
|
||||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
|
||||||
|
|
||||||
BrowserMap::const_iterator it = browsers_.begin();
|
|
||||||
for (; it != browsers_.end(); ++it) {
|
|
||||||
content::RenderView* render_view = it->second->render_view();
|
|
||||||
if (render_view && render_view->GetWebView() &&
|
|
||||||
render_view->GetWebView()->MainFrame() == frame) {
|
|
||||||
return it->second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyContentRendererClient::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
|
||||||
BrowserMap::iterator it = browsers_.begin();
|
|
||||||
for (; it != browsers_.end(); ++it) {
|
|
||||||
if (it->second.get() == browser) {
|
|
||||||
browsers_.erase(it);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No browser was found in the map.
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
CefGuestView* AlloyContentRendererClient::GetGuestViewForView(
|
|
||||||
content::RenderView* view) {
|
|
||||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
|
||||||
|
|
||||||
GuestViewMap::const_iterator it = guest_views_.find(view);
|
|
||||||
if (it != guest_views_.end())
|
|
||||||
return it->second.get();
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyContentRendererClient::OnGuestViewDestroyed(
|
|
||||||
CefGuestView* guest_view) {
|
|
||||||
GuestViewMap::iterator it = guest_views_.begin();
|
|
||||||
for (; it != guest_views_.end(); ++it) {
|
|
||||||
if (it->second.get() == guest_view) {
|
|
||||||
guest_views_.erase(it);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// No guest view was found in the map.
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AlloyContentRendererClient::WebKitInitialized() {
|
|
||||||
const base::CommandLine* command_line =
|
|
||||||
base::CommandLine::ForCurrentProcess();
|
|
||||||
|
|
||||||
// Create global objects associated with the default Isolate.
|
|
||||||
CefV8IsolateCreated();
|
|
||||||
|
|
||||||
const CefAppManager::SchemeInfoList* schemes =
|
|
||||||
CefAppManager::Get()->GetCustomSchemes();
|
|
||||||
if (!schemes->empty()) {
|
|
||||||
// Register the custom schemes. The |is_standard| value is excluded here
|
|
||||||
// because it's not explicitly registered with Blink.
|
|
||||||
CefAppManager::SchemeInfoList::const_iterator it = schemes->begin();
|
|
||||||
for (; it != schemes->end(); ++it) {
|
|
||||||
const CefSchemeInfo& info = *it;
|
|
||||||
const blink::WebString& scheme =
|
|
||||||
blink::WebString::FromUTF8(info.scheme_name);
|
|
||||||
if (info.is_local)
|
|
||||||
blink_glue::RegisterURLSchemeAsLocal(scheme);
|
|
||||||
if (info.is_display_isolated)
|
|
||||||
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
|
|
||||||
if (info.is_secure)
|
|
||||||
blink_glue::RegisterURLSchemeAsSecure(scheme);
|
|
||||||
if (info.is_fetch_enabled)
|
|
||||||
blink_glue::RegisterURLSchemeAsSupportingFetchAPI(scheme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cross_origin_whitelist_entries_.empty()) {
|
|
||||||
// Add the cross-origin white list entries.
|
|
||||||
for (size_t i = 0; i < cross_origin_whitelist_entries_.size(); ++i) {
|
|
||||||
const Cef_CrossOriginWhiteListEntry_Params& entry =
|
|
||||||
cross_origin_whitelist_entries_[i];
|
|
||||||
GURL gurl = GURL(entry.source_origin);
|
|
||||||
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
|
|
||||||
gurl, blink::WebString::FromUTF8(entry.target_protocol),
|
|
||||||
blink::WebString::FromUTF8(entry.target_domain),
|
|
||||||
/*destination_port=*/0,
|
|
||||||
entry.allow_target_subdomains
|
|
||||||
? network::mojom::CorsDomainMatchMode::kAllowSubdomains
|
|
||||||
: network::mojom::CorsDomainMatchMode::kDisallowSubdomains,
|
|
||||||
network::mojom::CorsPortMatchMode::kAllowAnyPort,
|
|
||||||
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
|
|
||||||
}
|
|
||||||
cross_origin_whitelist_entries_.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
// The number of stack trace frames to capture for uncaught exceptions.
|
|
||||||
if (command_line->HasSwitch(switches::kUncaughtExceptionStackSize)) {
|
|
||||||
int uncaught_exception_stack_size = 0;
|
|
||||||
base::StringToInt(command_line->GetSwitchValueASCII(
|
|
||||||
switches::kUncaughtExceptionStackSize),
|
|
||||||
&uncaught_exception_stack_size);
|
|
||||||
|
|
||||||
if (uncaught_exception_stack_size > 0) {
|
|
||||||
uncaught_exception_stack_size_ = uncaught_exception_stack_size;
|
|
||||||
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Notify the render process handler.
|
|
||||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
|
||||||
if (application.get()) {
|
|
||||||
CefRefPtr<CefRenderProcessHandler> handler =
|
|
||||||
application->GetRenderProcessHandler();
|
|
||||||
if (handler.get())
|
|
||||||
handler->OnWebKitInitialized();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner>
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
AlloyContentRendererClient::GetCurrentTaskRunner() {
|
AlloyContentRendererClient::GetCurrentTaskRunner() {
|
||||||
// Check if currently on the render thread.
|
// Check if currently on the render thread.
|
||||||
@ -372,7 +215,7 @@ void AlloyContentRendererClient::RenderThreadStarted() {
|
|||||||
base::CommandLine::ForCurrentProcess();
|
base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
render_task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
render_task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
||||||
observer_ = std::make_unique<CefRenderThreadObserver>();
|
observer_ = std::make_unique<AlloyRenderThreadObserver>();
|
||||||
web_cache_impl_ = std::make_unique<web_cache::WebCacheImpl>();
|
web_cache_impl_ = std::make_unique<web_cache::WebCacheImpl>();
|
||||||
visited_link_slave_ = std::make_unique<visitedlink::VisitedLinkReader>();
|
visited_link_slave_ = std::make_unique<visitedlink::VisitedLinkReader>();
|
||||||
|
|
||||||
@ -449,25 +292,17 @@ void AlloyContentRendererClient::ExposeInterfacesToBrowser(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AlloyContentRendererClient::RenderThreadConnected() {
|
void AlloyContentRendererClient::RenderThreadConnected() {
|
||||||
content::RenderThread* thread = content::RenderThread::Get();
|
|
||||||
|
|
||||||
// Retrieve the new render thread information synchronously.
|
|
||||||
CefProcessHostMsg_GetNewRenderThreadInfo_Params params;
|
|
||||||
thread->Send(new CefProcessHostMsg_GetNewRenderThreadInfo(¶ms));
|
|
||||||
|
|
||||||
// Cross-origin entries need to be added after WebKit is initialized.
|
|
||||||
cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries;
|
|
||||||
|
|
||||||
// Register extensions last because it will trigger WebKit initialization.
|
// Register extensions last because it will trigger WebKit initialization.
|
||||||
|
content::RenderThread* thread = content::RenderThread::Get();
|
||||||
thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get());
|
thread->RegisterExtension(extensions_v8::LoadTimesExtension::Get());
|
||||||
|
|
||||||
WebKitInitialized();
|
browser_manager_->RenderThreadConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyContentRendererClient::RenderFrameCreated(
|
void AlloyContentRendererClient::RenderFrameCreated(
|
||||||
content::RenderFrame* render_frame) {
|
content::RenderFrame* render_frame) {
|
||||||
CefRenderFrameObserver* render_frame_observer =
|
AlloyRenderFrameObserver* render_frame_observer =
|
||||||
new CefRenderFrameObserver(render_frame);
|
new AlloyRenderFrameObserver(render_frame);
|
||||||
service_manager::BinderRegistry* registry = render_frame_observer->registry();
|
service_manager::BinderRegistry* registry = render_frame_observer->registry();
|
||||||
|
|
||||||
new PepperHelper(render_frame);
|
new PepperHelper(render_frame);
|
||||||
@ -488,14 +323,12 @@ void AlloyContentRendererClient::RenderFrameCreated(
|
|||||||
new SpellCheckProvider(render_frame, spellcheck_.get(), this);
|
new SpellCheckProvider(render_frame, spellcheck_.get(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool browser_created;
|
||||||
base::Optional<bool> is_windowless;
|
base::Optional<bool> is_windowless;
|
||||||
|
browser_manager_->RenderFrameCreated(render_frame, render_frame_observer,
|
||||||
auto browser = MaybeCreateBrowser(render_frame->GetRenderView(), render_frame,
|
browser_created, is_windowless);
|
||||||
&is_windowless);
|
if (browser_created) {
|
||||||
if (browser) {
|
OnBrowserCreated(render_frame->GetRenderView(), is_windowless);
|
||||||
// Attach the frame to the observer for message routing purposes.
|
|
||||||
render_frame_observer->AttachFrame(
|
|
||||||
browser->GetWebFrameImpl(render_frame->GetWebFrame()).get());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_windowless.has_value()) {
|
if (is_windowless.has_value()) {
|
||||||
@ -510,7 +343,13 @@ void AlloyContentRendererClient::RenderViewCreated(
|
|||||||
content::RenderView* render_view) {
|
content::RenderView* render_view) {
|
||||||
new CefPrerendererClient(render_view);
|
new CefPrerendererClient(render_view);
|
||||||
|
|
||||||
MaybeCreateBrowser(render_view, render_view->GetMainRenderFrame(), nullptr);
|
bool browser_created;
|
||||||
|
base::Optional<bool> is_windowless;
|
||||||
|
browser_manager_->RenderViewCreated(render_view, browser_created,
|
||||||
|
is_windowless);
|
||||||
|
if (browser_created) {
|
||||||
|
OnBrowserCreated(render_view, is_windowless);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlloyContentRendererClient::IsPluginHandledExternally(
|
bool AlloyContentRendererClient::IsPluginHandledExternally(
|
||||||
@ -649,7 +488,7 @@ void AlloyContentRendererClient::DevToolsAgentAttached() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
++devtools_agent_count_;
|
browser_manager_->DevToolsAgentAttached();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyContentRendererClient::DevToolsAgentDetached() {
|
void AlloyContentRendererClient::DevToolsAgentDetached() {
|
||||||
@ -662,12 +501,7 @@ void AlloyContentRendererClient::DevToolsAgentDetached() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
--devtools_agent_count_;
|
browser_manager_->DevToolsAgentDetached();
|
||||||
if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) {
|
|
||||||
// When the last DevToolsAgent is detached the stack size is set to 0.
|
|
||||||
// Restore the user-specified stack size here.
|
|
||||||
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<content::URLLoaderThrottleProvider>
|
std::unique_ptr<content::URLLoaderThrottleProvider>
|
||||||
@ -700,84 +534,18 @@ void AlloyContentRendererClient::WillDestroyCurrentMessageLoop() {
|
|||||||
single_process_cleanup_complete_ = true;
|
single_process_cleanup_complete_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CefRefPtr<CefBrowserImpl> AlloyContentRendererClient::MaybeCreateBrowser(
|
void AlloyContentRendererClient::OnBrowserCreated(
|
||||||
content::RenderView* render_view,
|
content::RenderView* render_view,
|
||||||
content::RenderFrame* render_frame,
|
base::Optional<bool> is_windowless) {
|
||||||
base::Optional<bool>* is_windowless) {
|
|
||||||
if (!render_view || !render_frame)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// Don't create another browser or guest view object if one already exists for
|
|
||||||
// the view.
|
|
||||||
auto browser = GetBrowserForView(render_view);
|
|
||||||
if (browser) {
|
|
||||||
if (is_windowless) {
|
|
||||||
*is_windowless = browser->is_windowless();
|
|
||||||
}
|
|
||||||
return browser;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto guest_view = GetGuestViewForView(render_view);
|
|
||||||
if (guest_view) {
|
|
||||||
if (is_windowless) {
|
|
||||||
*is_windowless = guest_view->is_windowless();
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int render_frame_routing_id = render_frame->GetRoutingID();
|
|
||||||
|
|
||||||
// Retrieve the browser information synchronously. This will also register
|
|
||||||
// the routing ids with the browser info object in the browser process.
|
|
||||||
CefProcessHostMsg_GetNewBrowserInfo_Params params;
|
|
||||||
content::RenderThread::Get()->Send(new CefProcessHostMsg_GetNewBrowserInfo(
|
|
||||||
render_frame_routing_id, ¶ms));
|
|
||||||
|
|
||||||
if (is_windowless) {
|
|
||||||
*is_windowless = params.is_windowless;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.browser_id == 0) {
|
|
||||||
// The popup may have been canceled during creation.
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.is_guest_view || params.browser_id < 0) {
|
|
||||||
// Don't create a CefBrowser for guest views, or if the new browser info
|
|
||||||
// response has timed out.
|
|
||||||
guest_views_.insert(std::make_pair(
|
|
||||||
render_view,
|
|
||||||
std::make_unique<CefGuestView>(render_view, params.is_windowless)));
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(OS_MAC)
|
#if defined(OS_MAC)
|
||||||
|
const bool windowless = is_windowless.has_value() && *is_windowless;
|
||||||
|
|
||||||
// FIXME: It would be better if this API would be a callback from the
|
// FIXME: It would be better if this API would be a callback from the
|
||||||
// WebKit layer, or if it would be exposed as an WebView instance method; the
|
// WebKit layer, or if it would be exposed as an WebView instance method; the
|
||||||
// current implementation uses a static variable, and WebKit needs to be
|
// current implementation uses a static variable, and WebKit needs to be
|
||||||
// patched in order to make it work for each WebView instance
|
// patched in order to make it work for each WebView instance
|
||||||
render_view->GetWebView()->SetUseExternalPopupMenusThisInstance(
|
render_view->GetWebView()->SetUseExternalPopupMenusThisInstance(!windowless);
|
||||||
!params.is_windowless);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
browser = new CefBrowserImpl(render_view, params.browser_id, params.is_popup,
|
|
||||||
params.is_windowless);
|
|
||||||
browsers_.insert(std::make_pair(render_view, browser));
|
|
||||||
|
|
||||||
// Notify the render process handler.
|
|
||||||
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
|
||||||
if (application.get()) {
|
|
||||||
CefRefPtr<CefRenderProcessHandler> handler =
|
|
||||||
application->GetRenderProcessHandler();
|
|
||||||
if (handler.get()) {
|
|
||||||
CefRefPtr<CefDictionaryValueImpl> dictValuePtr(
|
|
||||||
new CefDictionaryValueImpl(¶ms.extra_info, false, true));
|
|
||||||
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
|
|
||||||
dictValuePtr->Detach(nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return browser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlloyContentRendererClient::RunSingleProcessCleanupOnUIThread() {
|
void AlloyContentRendererClient::RunSingleProcessCleanupOnUIThread() {
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
#include "libcef/renderer/browser_impl.h"
|
#include "libcef/renderer/browser_impl.h"
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/optional.h"
|
#include "base/single_thread_task_runner.h"
|
||||||
#include "base/sequenced_task_runner.h"
|
|
||||||
#include "base/task/current_thread.h"
|
#include "base/task/current_thread.h"
|
||||||
#include "chrome/common/plugin.mojom.h"
|
#include "chrome/common/plugin.mojom.h"
|
||||||
#include "content/public/renderer/content_renderer_client.h"
|
#include "content/public/renderer/content_renderer_client.h"
|
||||||
@ -43,9 +42,8 @@ namespace web_cache {
|
|||||||
class WebCacheImpl;
|
class WebCacheImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CefGuestView;
|
class CefBrowserManager;
|
||||||
class CefRenderThreadObserver;
|
class CefRenderThreadObserver;
|
||||||
struct Cef_CrossOriginWhiteListEntry_Params;
|
|
||||||
class ChromePDFPrintClient;
|
class ChromePDFPrintClient;
|
||||||
class SpellCheck;
|
class SpellCheck;
|
||||||
|
|
||||||
@ -61,32 +59,11 @@ class AlloyContentRendererClient
|
|||||||
// This method is deprecated and should not be used in new callsites.
|
// This method is deprecated and should not be used in new callsites.
|
||||||
static AlloyContentRendererClient* Get();
|
static AlloyContentRendererClient* Get();
|
||||||
|
|
||||||
// Returns the browser associated with the specified RenderView.
|
|
||||||
CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
||||||
|
|
||||||
// Returns the browser associated with the specified main WebFrame.
|
|
||||||
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(blink::WebFrame* frame);
|
|
||||||
|
|
||||||
// Called from CefBrowserImpl::OnDestruct().
|
|
||||||
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
||||||
|
|
||||||
// Returns the guest view associated with the specified RenderView if any.
|
|
||||||
CefGuestView* GetGuestViewForView(content::RenderView* view);
|
|
||||||
|
|
||||||
// Called from CefGuestView::OnDestruct().
|
|
||||||
void OnGuestViewDestroyed(CefGuestView* guest_view);
|
|
||||||
|
|
||||||
// Render thread task runner.
|
// Render thread task runner.
|
||||||
base::SingleThreadTaskRunner* render_task_runner() const {
|
base::SingleThreadTaskRunner* render_task_runner() const {
|
||||||
return render_task_runner_.get();
|
return render_task_runner_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int uncaught_exception_stack_size() const {
|
|
||||||
return uncaught_exception_stack_size_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void WebKitInitialized();
|
|
||||||
|
|
||||||
// Returns the task runner for the current thread. Returns NULL if the current
|
// Returns the task runner for the current thread. Returns NULL if the current
|
||||||
// thread is not the main render process thread.
|
// thread is not the main render process thread.
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
|
scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
|
||||||
@ -146,12 +123,8 @@ class AlloyContentRendererClient
|
|||||||
void WillDestroyCurrentMessageLoop() override;
|
void WillDestroyCurrentMessageLoop() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Maybe create a new browser object, return the existing one, or return
|
void OnBrowserCreated(content::RenderView* render_view,
|
||||||
// nullptr for guest views.
|
base::Optional<bool> is_windowless);
|
||||||
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
|
|
||||||
content::RenderView* render_view,
|
|
||||||
content::RenderFrame* render_frame,
|
|
||||||
base::Optional<bool>* is_windowless);
|
|
||||||
|
|
||||||
// Perform cleanup work for single-process mode.
|
// Perform cleanup work for single-process mode.
|
||||||
void RunSingleProcessCleanupOnUIThread();
|
void RunSingleProcessCleanupOnUIThread();
|
||||||
@ -160,37 +133,23 @@ class AlloyContentRendererClient
|
|||||||
// which the RendererMain function was entered.
|
// which the RendererMain function was entered.
|
||||||
base::TimeTicks main_entry_time_;
|
base::TimeTicks main_entry_time_;
|
||||||
|
|
||||||
|
std::unique_ptr<CefBrowserManager> browser_manager_;
|
||||||
|
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
|
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
|
||||||
std::unique_ptr<CefRenderThreadObserver> observer_;
|
std::unique_ptr<CefRenderThreadObserver> observer_;
|
||||||
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
|
std::unique_ptr<web_cache::WebCacheImpl> web_cache_impl_;
|
||||||
std::unique_ptr<SpellCheck> spellcheck_;
|
std::unique_ptr<SpellCheck> spellcheck_;
|
||||||
std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_slave_;
|
std::unique_ptr<visitedlink::VisitedLinkReader> visited_link_slave_;
|
||||||
|
|
||||||
// Map of RenderView pointers to CefBrowserImpl references.
|
|
||||||
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;
|
|
||||||
BrowserMap browsers_;
|
|
||||||
|
|
||||||
// Map of RenderView poiners to CefGuestView implementations.
|
|
||||||
typedef std::map<content::RenderView*, std::unique_ptr<CefGuestView>>
|
|
||||||
GuestViewMap;
|
|
||||||
GuestViewMap guest_views_;
|
|
||||||
|
|
||||||
// Cross-origin white list entries that need to be registered with WebKit.
|
|
||||||
typedef std::vector<Cef_CrossOriginWhiteListEntry_Params> CrossOriginList;
|
|
||||||
CrossOriginList cross_origin_whitelist_entries_;
|
|
||||||
|
|
||||||
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
|
std::unique_ptr<ChromePDFPrintClient> pdf_print_client_;
|
||||||
|
|
||||||
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
std::unique_ptr<extensions::ExtensionsClient> extensions_client_;
|
||||||
std::unique_ptr<extensions::CefExtensionsRendererClient>
|
std::unique_ptr<extensions::CefExtensionsRendererClient>
|
||||||
extensions_renderer_client_;
|
extensions_renderer_client_;
|
||||||
|
|
||||||
int devtools_agent_count_;
|
|
||||||
int uncaught_exception_stack_size_;
|
|
||||||
|
|
||||||
// Used in single-process mode to test when cleanup is complete.
|
// Used in single-process mode to test when cleanup is complete.
|
||||||
// Access must be protected by |single_process_cleanup_lock_|.
|
// Access must be protected by |single_process_cleanup_lock_|.
|
||||||
bool single_process_cleanup_complete_;
|
bool single_process_cleanup_complete_ = false;
|
||||||
base::Lock single_process_cleanup_lock_;
|
base::Lock single_process_cleanup_lock_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AlloyContentRendererClient);
|
DISALLOW_COPY_AND_ASSIGN(AlloyContentRendererClient);
|
||||||
|
23
libcef/renderer/alloy/alloy_render_frame_observer.cc
Normal file
23
libcef/renderer/alloy/alloy_render_frame_observer.cc
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2014 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/renderer/alloy/alloy_render_frame_observer.h"
|
||||||
|
|
||||||
|
AlloyRenderFrameObserver::AlloyRenderFrameObserver(
|
||||||
|
content::RenderFrame* render_frame)
|
||||||
|
: CefRenderFrameObserver(render_frame) {}
|
||||||
|
|
||||||
|
AlloyRenderFrameObserver::~AlloyRenderFrameObserver() = default;
|
||||||
|
|
||||||
|
void AlloyRenderFrameObserver::OnInterfaceRequestForFrame(
|
||||||
|
const std::string& interface_name,
|
||||||
|
mojo::ScopedMessagePipeHandle* interface_pipe) {
|
||||||
|
registry_.TryBindInterface(interface_name, interface_pipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AlloyRenderFrameObserver::OnAssociatedInterfaceRequestForFrame(
|
||||||
|
const std::string& interface_name,
|
||||||
|
mojo::ScopedInterfaceEndpointHandle* handle) {
|
||||||
|
return associated_interfaces_.TryBindInterface(interface_name, handle);
|
||||||
|
}
|
38
libcef/renderer/alloy/alloy_render_frame_observer.h
Normal file
38
libcef/renderer/alloy/alloy_render_frame_observer.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
#ifndef LIBCEF_RENDERER_ALLOY_ALLOY_RENDER_FRAME_OBSERVER_H_
|
||||||
|
#define LIBCEF_RENDERER_ALLOY_ALLOY_RENDER_FRAME_OBSERVER_H_
|
||||||
|
|
||||||
|
#include "libcef/renderer/render_frame_observer.h"
|
||||||
|
|
||||||
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
||||||
|
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||||
|
|
||||||
|
class AlloyRenderFrameObserver : public CefRenderFrameObserver {
|
||||||
|
public:
|
||||||
|
explicit AlloyRenderFrameObserver(content::RenderFrame* render_frame);
|
||||||
|
~AlloyRenderFrameObserver() override;
|
||||||
|
|
||||||
|
// RenderFrameObserver methods:
|
||||||
|
void OnInterfaceRequestForFrame(
|
||||||
|
const std::string& interface_name,
|
||||||
|
mojo::ScopedMessagePipeHandle* interface_pipe) override;
|
||||||
|
bool OnAssociatedInterfaceRequestForFrame(
|
||||||
|
const std::string& interface_name,
|
||||||
|
mojo::ScopedInterfaceEndpointHandle* handle) override;
|
||||||
|
|
||||||
|
service_manager::BinderRegistry* registry() { return ®istry_; }
|
||||||
|
blink::AssociatedInterfaceRegistry* associated_interfaces() {
|
||||||
|
return &associated_interfaces_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
service_manager::BinderRegistry registry_;
|
||||||
|
blink::AssociatedInterfaceRegistry associated_interfaces_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(AlloyRenderFrameObserver);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIBCEF_RENDERER_ALLOY_ALLOY_RENDER_FRAME_OBSERVER_H_
|
70
libcef/renderer/alloy/alloy_render_thread_observer.cc
Normal file
70
libcef/renderer/alloy/alloy_render_thread_observer.cc
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
||||||
|
// Portions (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.
|
||||||
|
|
||||||
|
#include "libcef/renderer/alloy/alloy_render_thread_observer.h"
|
||||||
|
|
||||||
|
#include "libcef/common/net/net_resource_provider.h"
|
||||||
|
|
||||||
|
#include "base/no_destructor.h"
|
||||||
|
#include "mojo/public/cpp/bindings/strong_binding.h"
|
||||||
|
#include "net/base/net_module.h"
|
||||||
|
#include "services/service_manager/public/cpp/connector.h"
|
||||||
|
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
chrome::mojom::DynamicParams* GetDynamicConfigParams() {
|
||||||
|
static base::NoDestructor<chrome::mojom::DynamicParams> dynamic_params;
|
||||||
|
return dynamic_params.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
bool AlloyRenderThreadObserver::is_incognito_process_ = false;
|
||||||
|
|
||||||
|
AlloyRenderThreadObserver::AlloyRenderThreadObserver() {
|
||||||
|
net::NetModule::SetResourceProvider(NetResourceProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
AlloyRenderThreadObserver::~AlloyRenderThreadObserver() {}
|
||||||
|
|
||||||
|
// static
|
||||||
|
const chrome::mojom::DynamicParams&
|
||||||
|
AlloyRenderThreadObserver::GetDynamicParams() {
|
||||||
|
return *GetDynamicConfigParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::RegisterMojoInterfaces(
|
||||||
|
blink::AssociatedInterfaceRegistry* associated_interfaces) {
|
||||||
|
associated_interfaces->AddInterface(base::Bind(
|
||||||
|
&AlloyRenderThreadObserver::OnRendererConfigurationAssociatedRequest,
|
||||||
|
base::Unretained(this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::UnregisterMojoInterfaces(
|
||||||
|
blink::AssociatedInterfaceRegistry* associated_interfaces) {
|
||||||
|
associated_interfaces->RemoveInterface(
|
||||||
|
chrome::mojom::RendererConfiguration::Name_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::SetInitialConfiguration(
|
||||||
|
bool is_incognito_process,
|
||||||
|
mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener) {
|
||||||
|
is_incognito_process_ = is_incognito_process;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::SetConfiguration(
|
||||||
|
chrome::mojom::DynamicParamsPtr params) {
|
||||||
|
*GetDynamicConfigParams() = std::move(*params);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::SetContentSettingRules(
|
||||||
|
const RendererContentSettingRules& rules) {}
|
||||||
|
|
||||||
|
void AlloyRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
|
||||||
|
mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
|
||||||
|
receiver) {
|
||||||
|
renderer_configuration_receivers_.Add(this, std::move(receiver));
|
||||||
|
}
|
61
libcef/renderer/alloy/alloy_render_thread_observer.h
Normal file
61
libcef/renderer/alloy/alloy_render_thread_observer.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
// Copyright (c) 2013 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_RENDERER_ALLOY_ALLOY_RENDER_THREAD_OBSERVER_H_
|
||||||
|
#define CEF_LIBCEF_RENDERER_ALLOY_ALLOY_RENDER_THREAD_OBSERVER_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "libcef/renderer/render_thread_observer.h"
|
||||||
|
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#include "chrome/common/renderer_configuration.mojom.h"
|
||||||
|
#include "components/content_settings/core/common/content_settings.h"
|
||||||
|
#include "content/public/renderer/render_thread_observer.h"
|
||||||
|
#include "mojo/public/cpp/bindings/associated_binding_set.h"
|
||||||
|
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
|
||||||
|
|
||||||
|
// This class sends and receives control messages in the renderer process.
|
||||||
|
class AlloyRenderThreadObserver : public CefRenderThreadObserver,
|
||||||
|
public chrome::mojom::RendererConfiguration {
|
||||||
|
public:
|
||||||
|
AlloyRenderThreadObserver();
|
||||||
|
~AlloyRenderThreadObserver() override;
|
||||||
|
|
||||||
|
static bool is_incognito_process() { return is_incognito_process_; }
|
||||||
|
|
||||||
|
// Return the dynamic parameters - those that may change while the
|
||||||
|
// render process is running.
|
||||||
|
static const chrome::mojom::DynamicParams& GetDynamicParams();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// content::RenderThreadObserver:
|
||||||
|
void RegisterMojoInterfaces(
|
||||||
|
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
|
||||||
|
void UnregisterMojoInterfaces(
|
||||||
|
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
|
||||||
|
|
||||||
|
// chrome::mojom::RendererConfiguration:
|
||||||
|
void SetInitialConfiguration(
|
||||||
|
bool is_incognito_process,
|
||||||
|
mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener)
|
||||||
|
override;
|
||||||
|
void SetConfiguration(chrome::mojom::DynamicParamsPtr params) override;
|
||||||
|
void SetContentSettingRules(
|
||||||
|
const RendererContentSettingRules& rules) override;
|
||||||
|
|
||||||
|
void OnRendererConfigurationAssociatedRequest(
|
||||||
|
mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
|
||||||
|
receiver);
|
||||||
|
|
||||||
|
static bool is_incognito_process_;
|
||||||
|
|
||||||
|
mojo::AssociatedReceiverSet<chrome::mojom::RendererConfiguration>
|
||||||
|
renderer_configuration_receivers_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(AlloyRenderThreadObserver);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_RENDERER_ALLOY_ALLOY_RENDER_THREAD_OBSERVER_H_
|
@ -2,10 +2,10 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "libcef/renderer/url_loader_throttle_provider_impl.h"
|
#include "libcef/renderer/alloy/url_loader_throttle_provider_impl.h"
|
||||||
|
|
||||||
#include "libcef/common/extensions/extensions_util.h"
|
#include "libcef/common/extensions/extensions_util.h"
|
||||||
#include "libcef/renderer/render_thread_observer.h"
|
#include "libcef/renderer/alloy/alloy_render_thread_observer.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ CefURLLoaderThrottleProviderImpl::CreateThrottles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
throttles.push_back(std::make_unique<GoogleURLLoaderThrottle>(
|
throttles.push_back(std::make_unique<GoogleURLLoaderThrottle>(
|
||||||
CefRenderThreadObserver::GetDynamicParams()));
|
AlloyRenderThreadObserver::GetDynamicParams()));
|
||||||
|
|
||||||
return throttles;
|
return throttles;
|
||||||
}
|
}
|
@ -2,8 +2,8 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
#ifndef CEF_LIBCEF_RENDERER_ALLOY_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
||||||
#define CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
#define CEF_LIBCEF_RENDERER_ALLOY_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -41,4 +41,4 @@ class CefURLLoaderThrottleProviderImpl
|
|||||||
DISALLOW_ASSIGN(CefURLLoaderThrottleProviderImpl);
|
DISALLOW_ASSIGN(CefURLLoaderThrottleProviderImpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CEF_LIBCEF_RENDERER_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
#endif // CEF_LIBCEF_RENDERER_ALLOY_URL_LOADER_THROTTLE_PROVIDER_IMPL_H_
|
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
#include "libcef/common/app_manager.h"
|
#include "libcef/common/app_manager.h"
|
||||||
#include "libcef/common/cef_messages.h"
|
#include "libcef/common/cef_messages.h"
|
||||||
#include "libcef/renderer/alloy/alloy_content_renderer_client.h"
|
|
||||||
#include "libcef/renderer/blink_glue.h"
|
#include "libcef/renderer/blink_glue.h"
|
||||||
|
#include "libcef/renderer/browser_manager.h"
|
||||||
#include "libcef/renderer/render_frame_util.h"
|
#include "libcef/renderer/render_frame_util.h"
|
||||||
#include "libcef/renderer/thread_util.h"
|
#include "libcef/renderer/thread_util.h"
|
||||||
|
|
||||||
@ -38,13 +38,13 @@
|
|||||||
// static
|
// static
|
||||||
CefRefPtr<CefBrowserImpl> CefBrowserImpl::GetBrowserForView(
|
CefRefPtr<CefBrowserImpl> CefBrowserImpl::GetBrowserForView(
|
||||||
content::RenderView* view) {
|
content::RenderView* view) {
|
||||||
return AlloyContentRendererClient::Get()->GetBrowserForView(view);
|
return CefBrowserManager::Get()->GetBrowserForView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
CefRefPtr<CefBrowserImpl> CefBrowserImpl::GetBrowserForMainFrame(
|
CefRefPtr<CefBrowserImpl> CefBrowserImpl::GetBrowserForMainFrame(
|
||||||
blink::WebFrame* frame) {
|
blink::WebFrame* frame) {
|
||||||
return AlloyContentRendererClient::Get()->GetBrowserForMainFrame(frame);
|
return CefBrowserManager::Get()->GetBrowserForMainFrame(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
// CefBrowser methods.
|
// CefBrowser methods.
|
||||||
@ -352,7 +352,7 @@ void CefBrowserImpl::OnDestruct() {
|
|||||||
handler->OnBrowserDestroyed(this);
|
handler->OnBrowserDestroyed(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
AlloyContentRendererClient::Get()->OnBrowserDestroyed(this);
|
CefBrowserManager::Get()->OnBrowserDestroyed(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefBrowserImpl::FrameDetached(int64_t frame_id) {
|
void CefBrowserImpl::FrameDetached(int64_t frame_id) {
|
||||||
|
342
libcef/renderer/browser_manager.cc
Normal file
342
libcef/renderer/browser_manager.cc
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
// 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/renderer/browser_manager.h"
|
||||||
|
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
|
||||||
|
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic error "-Wdeprecated-declarations"
|
||||||
|
#else
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(default : 4996)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "libcef/common/app_manager.h"
|
||||||
|
#include "libcef/common/cef_messages.h"
|
||||||
|
#include "libcef/common/cef_switches.h"
|
||||||
|
#include "libcef/common/net/scheme_info.h"
|
||||||
|
#include "libcef/common/values_impl.h"
|
||||||
|
#include "libcef/renderer/blink_glue.h"
|
||||||
|
#include "libcef/renderer/browser_impl.h"
|
||||||
|
#include "libcef/renderer/render_frame_observer.h"
|
||||||
|
#include "libcef/renderer/thread_util.h"
|
||||||
|
#include "libcef/renderer/v8_impl.h"
|
||||||
|
|
||||||
|
#include "base/command_line.h"
|
||||||
|
#include "base/strings/string_number_conversions.h"
|
||||||
|
#include "content/public/renderer/render_frame.h"
|
||||||
|
#include "content/public/renderer/render_thread.h"
|
||||||
|
#include "content/public/renderer/render_view.h"
|
||||||
|
#include "content/public/renderer/render_view_observer.h"
|
||||||
|
#include "services/network/public/mojom/cors_origin_pattern.mojom.h"
|
||||||
|
#include "third_party/blink/public/web/web_security_policy.h"
|
||||||
|
#include "third_party/blink/public/web/web_view.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
CefBrowserManager* g_manager = nullptr;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
// Placeholder object for guest views.
|
||||||
|
class CefGuestView : public content::RenderViewObserver {
|
||||||
|
public:
|
||||||
|
CefGuestView(CefBrowserManager* manager,
|
||||||
|
content::RenderView* render_view,
|
||||||
|
bool is_windowless)
|
||||||
|
: content::RenderViewObserver(render_view),
|
||||||
|
manager_(manager),
|
||||||
|
is_windowless_(is_windowless) {}
|
||||||
|
|
||||||
|
bool is_windowless() const { return is_windowless_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
// RenderViewObserver methods.
|
||||||
|
void OnDestruct() override { manager_->OnGuestViewDestroyed(this); }
|
||||||
|
|
||||||
|
CefBrowserManager* const manager_;
|
||||||
|
const bool is_windowless_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CefBrowserManager::CefBrowserManager() {
|
||||||
|
DCHECK(!g_manager);
|
||||||
|
g_manager = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefBrowserManager::~CefBrowserManager() {
|
||||||
|
g_manager = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
CefBrowserManager* CefBrowserManager::Get() {
|
||||||
|
CEF_REQUIRE_RT_RETURN(nullptr);
|
||||||
|
return g_manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::RenderThreadConnected() {
|
||||||
|
content::RenderThread* thread = content::RenderThread::Get();
|
||||||
|
|
||||||
|
// Retrieve the new render thread information synchronously.
|
||||||
|
CefProcessHostMsg_GetNewRenderThreadInfo_Params params;
|
||||||
|
thread->Send(new CefProcessHostMsg_GetNewRenderThreadInfo(¶ms));
|
||||||
|
|
||||||
|
// Cross-origin entries need to be added after WebKit is initialized.
|
||||||
|
cross_origin_whitelist_entries_ = params.cross_origin_whitelist_entries;
|
||||||
|
|
||||||
|
WebKitInitialized();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::RenderFrameCreated(
|
||||||
|
content::RenderFrame* render_frame,
|
||||||
|
CefRenderFrameObserver* render_frame_observer,
|
||||||
|
bool& browser_created,
|
||||||
|
base::Optional<bool>& is_windowless) {
|
||||||
|
auto browser = MaybeCreateBrowser(render_frame->GetRenderView(), render_frame,
|
||||||
|
&browser_created, &is_windowless);
|
||||||
|
if (browser) {
|
||||||
|
// Attach the frame to the observer for message routing purposes.
|
||||||
|
render_frame_observer->AttachFrame(
|
||||||
|
browser->GetWebFrameImpl(render_frame->GetWebFrame()).get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::RenderViewCreated(content::RenderView* render_view,
|
||||||
|
bool& browser_created,
|
||||||
|
base::Optional<bool>& is_windowless) {
|
||||||
|
MaybeCreateBrowser(render_view, render_view->GetMainRenderFrame(),
|
||||||
|
&browser_created, &is_windowless);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::DevToolsAgentAttached() {
|
||||||
|
++devtools_agent_count_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::DevToolsAgentDetached() {
|
||||||
|
--devtools_agent_count_;
|
||||||
|
if (devtools_agent_count_ == 0 && uncaught_exception_stack_size_ > 0) {
|
||||||
|
// When the last DevToolsAgent is detached the stack size is set to 0.
|
||||||
|
// Restore the user-specified stack size here.
|
||||||
|
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowserImpl> CefBrowserManager::GetBrowserForView(
|
||||||
|
content::RenderView* view) {
|
||||||
|
BrowserMap::const_iterator it = browsers_.find(view);
|
||||||
|
if (it != browsers_.end())
|
||||||
|
return it->second;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowserImpl> CefBrowserManager::GetBrowserForMainFrame(
|
||||||
|
blink::WebFrame* frame) {
|
||||||
|
BrowserMap::const_iterator it = browsers_.begin();
|
||||||
|
for (; it != browsers_.end(); ++it) {
|
||||||
|
content::RenderView* render_view = it->second->render_view();
|
||||||
|
if (render_view && render_view->GetWebView() &&
|
||||||
|
render_view->GetWebView()->MainFrame() == frame) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::WebKitInitialized() {
|
||||||
|
const base::CommandLine* command_line =
|
||||||
|
base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
|
// Create global objects associated with the default Isolate.
|
||||||
|
CefV8IsolateCreated();
|
||||||
|
|
||||||
|
const CefAppManager::SchemeInfoList* schemes =
|
||||||
|
CefAppManager::Get()->GetCustomSchemes();
|
||||||
|
if (!schemes->empty()) {
|
||||||
|
// Register the custom schemes. The |is_standard| value is excluded here
|
||||||
|
// because it's not explicitly registered with Blink.
|
||||||
|
CefAppManager::SchemeInfoList::const_iterator it = schemes->begin();
|
||||||
|
for (; it != schemes->end(); ++it) {
|
||||||
|
const CefSchemeInfo& info = *it;
|
||||||
|
const blink::WebString& scheme =
|
||||||
|
blink::WebString::FromUTF8(info.scheme_name);
|
||||||
|
if (info.is_local)
|
||||||
|
blink_glue::RegisterURLSchemeAsLocal(scheme);
|
||||||
|
if (info.is_display_isolated)
|
||||||
|
blink::WebSecurityPolicy::RegisterURLSchemeAsDisplayIsolated(scheme);
|
||||||
|
if (info.is_secure)
|
||||||
|
blink_glue::RegisterURLSchemeAsSecure(scheme);
|
||||||
|
if (info.is_fetch_enabled)
|
||||||
|
blink_glue::RegisterURLSchemeAsSupportingFetchAPI(scheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cross_origin_whitelist_entries_.empty()) {
|
||||||
|
// Add the cross-origin white list entries.
|
||||||
|
for (size_t i = 0; i < cross_origin_whitelist_entries_.size(); ++i) {
|
||||||
|
const Cef_CrossOriginWhiteListEntry_Params& entry =
|
||||||
|
cross_origin_whitelist_entries_[i];
|
||||||
|
GURL gurl = GURL(entry.source_origin);
|
||||||
|
blink::WebSecurityPolicy::AddOriginAccessAllowListEntry(
|
||||||
|
gurl, blink::WebString::FromUTF8(entry.target_protocol),
|
||||||
|
blink::WebString::FromUTF8(entry.target_domain),
|
||||||
|
/*destination_port=*/0,
|
||||||
|
entry.allow_target_subdomains
|
||||||
|
? network::mojom::CorsDomainMatchMode::kAllowSubdomains
|
||||||
|
: network::mojom::CorsDomainMatchMode::kDisallowSubdomains,
|
||||||
|
network::mojom::CorsPortMatchMode::kAllowAnyPort,
|
||||||
|
network::mojom::CorsOriginAccessMatchPriority::kDefaultPriority);
|
||||||
|
}
|
||||||
|
cross_origin_whitelist_entries_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// The number of stack trace frames to capture for uncaught exceptions.
|
||||||
|
if (command_line->HasSwitch(switches::kUncaughtExceptionStackSize)) {
|
||||||
|
int uncaught_exception_stack_size = 0;
|
||||||
|
base::StringToInt(command_line->GetSwitchValueASCII(
|
||||||
|
switches::kUncaughtExceptionStackSize),
|
||||||
|
&uncaught_exception_stack_size);
|
||||||
|
|
||||||
|
if (uncaught_exception_stack_size > 0) {
|
||||||
|
uncaught_exception_stack_size_ = uncaught_exception_stack_size;
|
||||||
|
CefV8SetUncaughtExceptionStackSize(uncaught_exception_stack_size_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify the render process handler.
|
||||||
|
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||||
|
if (application.get()) {
|
||||||
|
CefRefPtr<CefRenderProcessHandler> handler =
|
||||||
|
application->GetRenderProcessHandler();
|
||||||
|
if (handler.get())
|
||||||
|
handler->OnWebKitInitialized();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CefRefPtr<CefBrowserImpl> CefBrowserManager::MaybeCreateBrowser(
|
||||||
|
content::RenderView* render_view,
|
||||||
|
content::RenderFrame* render_frame,
|
||||||
|
bool* browser_created,
|
||||||
|
base::Optional<bool>* is_windowless) {
|
||||||
|
if (browser_created)
|
||||||
|
*browser_created = false;
|
||||||
|
|
||||||
|
if (!render_view || !render_frame)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// Don't create another browser or guest view object if one already exists for
|
||||||
|
// the view.
|
||||||
|
auto browser = GetBrowserForView(render_view);
|
||||||
|
if (browser) {
|
||||||
|
if (is_windowless) {
|
||||||
|
*is_windowless = browser->is_windowless();
|
||||||
|
}
|
||||||
|
return browser;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto guest_view = GetGuestViewForView(render_view);
|
||||||
|
if (guest_view) {
|
||||||
|
if (is_windowless) {
|
||||||
|
*is_windowless = guest_view->is_windowless();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int render_frame_routing_id = render_frame->GetRoutingID();
|
||||||
|
|
||||||
|
// Retrieve the browser information synchronously. This will also register
|
||||||
|
// the routing ids with the browser info object in the browser process.
|
||||||
|
CefProcessHostMsg_GetNewBrowserInfo_Params params;
|
||||||
|
content::RenderThread::Get()->Send(new CefProcessHostMsg_GetNewBrowserInfo(
|
||||||
|
render_frame_routing_id, ¶ms));
|
||||||
|
|
||||||
|
if (is_windowless) {
|
||||||
|
*is_windowless = params.is_windowless;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.browser_id == 0) {
|
||||||
|
// The popup may have been canceled during creation.
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.is_guest_view || params.browser_id < 0) {
|
||||||
|
// Don't create a CefBrowser for guest views, or if the new browser info
|
||||||
|
// response has timed out.
|
||||||
|
guest_views_.insert(std::make_pair(
|
||||||
|
render_view, std::make_unique<CefGuestView>(this, render_view,
|
||||||
|
params.is_windowless)));
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser = new CefBrowserImpl(render_view, params.browser_id, params.is_popup,
|
||||||
|
params.is_windowless);
|
||||||
|
browsers_.insert(std::make_pair(render_view, browser));
|
||||||
|
|
||||||
|
// Notify the render process handler.
|
||||||
|
CefRefPtr<CefApp> application = CefAppManager::Get()->GetApplication();
|
||||||
|
if (application.get()) {
|
||||||
|
CefRefPtr<CefRenderProcessHandler> handler =
|
||||||
|
application->GetRenderProcessHandler();
|
||||||
|
if (handler.get()) {
|
||||||
|
CefRefPtr<CefDictionaryValueImpl> dictValuePtr(
|
||||||
|
new CefDictionaryValueImpl(¶ms.extra_info, false, true));
|
||||||
|
handler->OnBrowserCreated(browser.get(), dictValuePtr.get());
|
||||||
|
dictValuePtr->Detach(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (browser_created)
|
||||||
|
*browser_created = true;
|
||||||
|
|
||||||
|
return browser;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::OnBrowserDestroyed(CefBrowserImpl* browser) {
|
||||||
|
BrowserMap::iterator it = browsers_.begin();
|
||||||
|
for (; it != browsers_.end(); ++it) {
|
||||||
|
if (it->second.get() == browser) {
|
||||||
|
browsers_.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No browser was found in the map.
|
||||||
|
NOTREACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
CefGuestView* CefBrowserManager::GetGuestViewForView(
|
||||||
|
content::RenderView* view) {
|
||||||
|
CEF_REQUIRE_RT_RETURN(nullptr);
|
||||||
|
|
||||||
|
GuestViewMap::const_iterator it = guest_views_.find(view);
|
||||||
|
if (it != guest_views_.end())
|
||||||
|
return it->second.get();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefBrowserManager::OnGuestViewDestroyed(CefGuestView* guest_view) {
|
||||||
|
GuestViewMap::iterator it = guest_views_.begin();
|
||||||
|
for (; it != guest_views_.end(); ++it) {
|
||||||
|
if (it->second.get() == guest_view) {
|
||||||
|
guest_views_.erase(it);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No guest view was found in the map.
|
||||||
|
NOTREACHED();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable deprecation warnings on Windows. See http://crbug.com/585142.
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#else
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
#endif
|
100
libcef/renderer/browser_manager.h
Normal file
100
libcef/renderer/browser_manager.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_RENDERER_BROWSER_MANAGER_H_
|
||||||
|
#define CEF_LIBCEF_RENDERER_BROWSER_MANAGER_H_
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "include/internal/cef_ptr.h"
|
||||||
|
|
||||||
|
#include "base/optional.h"
|
||||||
|
|
||||||
|
namespace blink {
|
||||||
|
class WebFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace content {
|
||||||
|
class RenderFrame;
|
||||||
|
class RenderView;
|
||||||
|
} // namespace content
|
||||||
|
|
||||||
|
struct Cef_CrossOriginWhiteListEntry_Params;
|
||||||
|
class CefBrowserImpl;
|
||||||
|
class CefGuestView;
|
||||||
|
class CefRenderFrameObserver;
|
||||||
|
|
||||||
|
// Singleton object for managing BrowserImpl instances. Only accessed on the
|
||||||
|
// main renderer thread.
|
||||||
|
class CefBrowserManager {
|
||||||
|
public:
|
||||||
|
CefBrowserManager();
|
||||||
|
~CefBrowserManager();
|
||||||
|
|
||||||
|
// Returns this singleton instance of this class.
|
||||||
|
static CefBrowserManager* Get();
|
||||||
|
|
||||||
|
// Called from ContentRendererClient methods of the same name.
|
||||||
|
void RenderThreadConnected();
|
||||||
|
void RenderFrameCreated(content::RenderFrame* render_frame,
|
||||||
|
CefRenderFrameObserver* render_frame_observer,
|
||||||
|
bool& browser_created,
|
||||||
|
base::Optional<bool>& is_windowless);
|
||||||
|
void RenderViewCreated(content::RenderView* render_view,
|
||||||
|
bool& browser_created,
|
||||||
|
base::Optional<bool>& is_windowless);
|
||||||
|
void DevToolsAgentAttached();
|
||||||
|
void DevToolsAgentDetached();
|
||||||
|
|
||||||
|
// Returns the browser associated with the specified RenderView.
|
||||||
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
||||||
|
|
||||||
|
// Returns the browser associated with the specified main WebFrame.
|
||||||
|
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(blink::WebFrame* frame);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class CefBrowserImpl;
|
||||||
|
friend class CefGuestView;
|
||||||
|
|
||||||
|
void WebKitInitialized();
|
||||||
|
|
||||||
|
// Maybe create a new browser object, return the existing one, or return
|
||||||
|
// nullptr for guest views.
|
||||||
|
CefRefPtr<CefBrowserImpl> MaybeCreateBrowser(
|
||||||
|
content::RenderView* render_view,
|
||||||
|
content::RenderFrame* render_frame,
|
||||||
|
bool* browser_created,
|
||||||
|
base::Optional<bool>* is_windowless);
|
||||||
|
|
||||||
|
// Called from CefBrowserImpl::OnDestruct().
|
||||||
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
||||||
|
|
||||||
|
// Returns the guest view associated with the specified RenderView if any.
|
||||||
|
CefGuestView* GetGuestViewForView(content::RenderView* view);
|
||||||
|
|
||||||
|
// Called from CefGuestView::OnDestruct().
|
||||||
|
void OnGuestViewDestroyed(CefGuestView* guest_view);
|
||||||
|
|
||||||
|
// Map of RenderView pointers to CefBrowserImpl references.
|
||||||
|
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl>> BrowserMap;
|
||||||
|
BrowserMap browsers_;
|
||||||
|
|
||||||
|
// Map of RenderView poiners to CefGuestView implementations.
|
||||||
|
typedef std::map<content::RenderView*, std::unique_ptr<CefGuestView>>
|
||||||
|
GuestViewMap;
|
||||||
|
GuestViewMap guest_views_;
|
||||||
|
|
||||||
|
// Cross-origin white list entries that need to be registered with WebKit.
|
||||||
|
typedef std::vector<Cef_CrossOriginWhiteListEntry_Params> CrossOriginList;
|
||||||
|
CrossOriginList cross_origin_whitelist_entries_;
|
||||||
|
|
||||||
|
int devtools_agent_count_ = 0;
|
||||||
|
int uncaught_exception_stack_size_ = 0;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserManager);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_RENDERER_BROWSER_MANAGER_H_
|
98
libcef/renderer/chrome/chrome_content_renderer_client_cef.cc
Normal file
98
libcef/renderer/chrome/chrome_content_renderer_client_cef.cc
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
// Copyright 2020 The Chromium Embedded Framework Authors.
|
||||||
|
// Portions copyright 2012 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.
|
||||||
|
|
||||||
|
#include "libcef/renderer/chrome/chrome_content_renderer_client_cef.h"
|
||||||
|
|
||||||
|
#include "libcef/renderer/browser_manager.h"
|
||||||
|
#include "libcef/renderer/render_frame_observer.h"
|
||||||
|
#include "libcef/renderer/render_thread_observer.h"
|
||||||
|
#include "libcef/renderer/thread_util.h"
|
||||||
|
|
||||||
|
#include "content/public/renderer/render_thread.h"
|
||||||
|
|
||||||
|
ChromeContentRendererClientCef::ChromeContentRendererClientCef()
|
||||||
|
: browser_manager_(new CefBrowserManager) {}
|
||||||
|
|
||||||
|
ChromeContentRendererClientCef::~ChromeContentRendererClientCef() = default;
|
||||||
|
|
||||||
|
scoped_refptr<base::SingleThreadTaskRunner>
|
||||||
|
ChromeContentRendererClientCef::GetCurrentTaskRunner() {
|
||||||
|
// Check if currently on the render thread.
|
||||||
|
if (CEF_CURRENTLY_ON_RT())
|
||||||
|
return render_task_runner_;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::RenderThreadStarted() {
|
||||||
|
ChromeContentRendererClient::RenderThreadStarted();
|
||||||
|
|
||||||
|
render_task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
||||||
|
observer_ = std::make_unique<CefRenderThreadObserver>();
|
||||||
|
|
||||||
|
content::RenderThread* thread = content::RenderThread::Get();
|
||||||
|
thread->AddObserver(observer_.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::RenderThreadConnected() {
|
||||||
|
ChromeContentRendererClient::RenderThreadConnected();
|
||||||
|
|
||||||
|
browser_manager_->RenderThreadConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::RenderFrameCreated(
|
||||||
|
content::RenderFrame* render_frame) {
|
||||||
|
ChromeContentRendererClient::RenderFrameCreated(render_frame);
|
||||||
|
|
||||||
|
// Will delete itself when no longer needed.
|
||||||
|
CefRenderFrameObserver* render_frame_observer =
|
||||||
|
new CefRenderFrameObserver(render_frame);
|
||||||
|
|
||||||
|
bool browser_created;
|
||||||
|
base::Optional<bool> is_windowless;
|
||||||
|
browser_manager_->RenderFrameCreated(render_frame, render_frame_observer,
|
||||||
|
browser_created, is_windowless);
|
||||||
|
if (is_windowless.has_value() && *is_windowless) {
|
||||||
|
LOG(ERROR) << "The chrome runtime does not support windowless browsers";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::RenderViewCreated(
|
||||||
|
content::RenderView* render_view) {
|
||||||
|
ChromeContentRendererClient::RenderViewCreated(render_view);
|
||||||
|
|
||||||
|
bool browser_created;
|
||||||
|
base::Optional<bool> is_windowless;
|
||||||
|
browser_manager_->RenderViewCreated(render_view, browser_created,
|
||||||
|
is_windowless);
|
||||||
|
if (is_windowless.has_value() && *is_windowless) {
|
||||||
|
LOG(ERROR) << "The chrome runtime does not support windowless browsers";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::DevToolsAgentAttached() {
|
||||||
|
// WebWorkers may be creating agents on a different thread.
|
||||||
|
if (!render_task_runner_->BelongsToCurrentThread()) {
|
||||||
|
render_task_runner_->PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
base::BindOnce(&ChromeContentRendererClientCef::DevToolsAgentAttached,
|
||||||
|
base::Unretained(this)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser_manager_->DevToolsAgentAttached();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChromeContentRendererClientCef::DevToolsAgentDetached() {
|
||||||
|
// WebWorkers may be creating agents on a different thread.
|
||||||
|
if (!render_task_runner_->BelongsToCurrentThread()) {
|
||||||
|
render_task_runner_->PostTask(
|
||||||
|
FROM_HERE,
|
||||||
|
base::BindOnce(&ChromeContentRendererClientCef::DevToolsAgentDetached,
|
||||||
|
base::Unretained(this)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
browser_manager_->DevToolsAgentDetached();
|
||||||
|
}
|
51
libcef/renderer/chrome/chrome_content_renderer_client_cef.h
Normal file
51
libcef/renderer/chrome/chrome_content_renderer_client_cef.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Copyright 2020 The Chromium Embedded Framework Authors.
|
||||||
|
// Portions copyright 2012 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_RENDERER_CHROME_CHROME_CONTENT_RENDERER_CLIENT_CEF_
|
||||||
|
#define CEF_LIBCEF_RENDERER_CHROME_CHROME_CONTENT_RENDERER_CLIENT_CEF_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "base/macros.h"
|
||||||
|
#include "base/memory/scoped_refptr.h"
|
||||||
|
#include "base/single_thread_task_runner.h"
|
||||||
|
#include "chrome/renderer/chrome_content_renderer_client.h"
|
||||||
|
|
||||||
|
class CefBrowserManager;
|
||||||
|
class CefRenderThreadObserver;
|
||||||
|
|
||||||
|
// CEF override of ChromeContentRendererClient.
|
||||||
|
class ChromeContentRendererClientCef : public ChromeContentRendererClient {
|
||||||
|
public:
|
||||||
|
ChromeContentRendererClientCef();
|
||||||
|
~ChromeContentRendererClientCef() override;
|
||||||
|
|
||||||
|
// Render thread task runner.
|
||||||
|
base::SingleThreadTaskRunner* render_task_runner() const {
|
||||||
|
return render_task_runner_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the task runner for the current thread. Returns NULL if the current
|
||||||
|
// thread is not the main render process thread.
|
||||||
|
scoped_refptr<base::SingleThreadTaskRunner> GetCurrentTaskRunner();
|
||||||
|
|
||||||
|
// ChromeContentRendererClient overrides.
|
||||||
|
void RenderThreadStarted() override;
|
||||||
|
void RenderThreadConnected() override;
|
||||||
|
void RenderFrameCreated(content::RenderFrame* render_frame) override;
|
||||||
|
void RenderViewCreated(content::RenderView* render_view) override;
|
||||||
|
void DevToolsAgentAttached() override;
|
||||||
|
void DevToolsAgentDetached() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<CefBrowserManager> browser_manager_;
|
||||||
|
|
||||||
|
scoped_refptr<base::SingleThreadTaskRunner> render_task_runner_;
|
||||||
|
std::unique_ptr<CefRenderThreadObserver> observer_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(ChromeContentRendererClientCef);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_RENDERER_CHROME_CHROME_CONTENT_RENDERER_CLIENT_CEF_
|
@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
#include "libcef/renderer/extensions/extensions_renderer_client.h"
|
#include "libcef/renderer/extensions/extensions_renderer_client.h"
|
||||||
|
|
||||||
#include "libcef/common/cef_messages.h"
|
#include "libcef/renderer/alloy/alloy_render_thread_observer.h"
|
||||||
#include "libcef/renderer/extensions/extensions_dispatcher_delegate.h"
|
#include "libcef/renderer/extensions/extensions_dispatcher_delegate.h"
|
||||||
#include "libcef/renderer/render_thread_observer.h"
|
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "chrome/common/url_constants.h"
|
#include "chrome/common/url_constants.h"
|
||||||
@ -50,7 +49,7 @@ CefExtensionsRendererClient::CefExtensionsRendererClient() {}
|
|||||||
CefExtensionsRendererClient::~CefExtensionsRendererClient() {}
|
CefExtensionsRendererClient::~CefExtensionsRendererClient() {}
|
||||||
|
|
||||||
bool CefExtensionsRendererClient::IsIncognitoProcess() const {
|
bool CefExtensionsRendererClient::IsIncognitoProcess() const {
|
||||||
return CefRenderThreadObserver::is_incognito_process();
|
return AlloyRenderThreadObserver::is_incognito_process();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CefExtensionsRendererClient::GetLowestIsolatedWorldId() const {
|
int CefExtensionsRendererClient::GetLowestIsolatedWorldId() const {
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
#include "content/public/renderer/render_frame.h"
|
#include "content/public/renderer/render_frame.h"
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
|
||||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
|
||||||
#include "third_party/blink/public/web/blink.h"
|
#include "third_party/blink/public/web/blink.h"
|
||||||
#include "third_party/blink/public/web/web_document.h"
|
#include "third_party/blink/public/web/web_document.h"
|
||||||
#include "third_party/blink/public/web/web_local_frame.h"
|
#include "third_party/blink/public/web/web_local_frame.h"
|
||||||
@ -36,19 +34,7 @@ CefRenderFrameObserver::CefRenderFrameObserver(
|
|||||||
content::RenderFrame* render_frame)
|
content::RenderFrame* render_frame)
|
||||||
: content::RenderFrameObserver(render_frame) {}
|
: content::RenderFrameObserver(render_frame) {}
|
||||||
|
|
||||||
CefRenderFrameObserver::~CefRenderFrameObserver() {}
|
CefRenderFrameObserver::~CefRenderFrameObserver() = default;
|
||||||
|
|
||||||
void CefRenderFrameObserver::OnInterfaceRequestForFrame(
|
|
||||||
const std::string& interface_name,
|
|
||||||
mojo::ScopedMessagePipeHandle* interface_pipe) {
|
|
||||||
registry_.TryBindInterface(interface_name, interface_pipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefRenderFrameObserver::OnAssociatedInterfaceRequestForFrame(
|
|
||||||
const std::string& interface_name,
|
|
||||||
mojo::ScopedInterfaceEndpointHandle* handle) {
|
|
||||||
return associated_interfaces_.TryBindInterface(interface_name, handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderFrameObserver::DidCommitProvisionalLoad(
|
void CefRenderFrameObserver::DidCommitProvisionalLoad(
|
||||||
ui::PageTransition transition) {
|
ui::PageTransition transition) {
|
||||||
|
@ -6,8 +6,6 @@
|
|||||||
#define LIBCEF_RENDERER_RENDER_FRAME_OBSERVER_H_
|
#define LIBCEF_RENDERER_RENDER_FRAME_OBSERVER_H_
|
||||||
|
|
||||||
#include "content/public/renderer/render_frame_observer.h"
|
#include "content/public/renderer/render_frame_observer.h"
|
||||||
#include "services/service_manager/public/cpp/binder_registry.h"
|
|
||||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
class RenderFrame;
|
class RenderFrame;
|
||||||
@ -22,12 +20,6 @@ class CefRenderFrameObserver : public content::RenderFrameObserver {
|
|||||||
~CefRenderFrameObserver() override;
|
~CefRenderFrameObserver() override;
|
||||||
|
|
||||||
// RenderFrameObserver methods:
|
// RenderFrameObserver methods:
|
||||||
void OnInterfaceRequestForFrame(
|
|
||||||
const std::string& interface_name,
|
|
||||||
mojo::ScopedMessagePipeHandle* interface_pipe) override;
|
|
||||||
bool OnAssociatedInterfaceRequestForFrame(
|
|
||||||
const std::string& interface_name,
|
|
||||||
mojo::ScopedInterfaceEndpointHandle* handle) override;
|
|
||||||
void DidCommitProvisionalLoad(ui::PageTransition transition) override;
|
void DidCommitProvisionalLoad(ui::PageTransition transition) override;
|
||||||
void DidFailProvisionalLoad() override;
|
void DidFailProvisionalLoad() override;
|
||||||
void DidFinishLoad() override;
|
void DidFinishLoad() override;
|
||||||
@ -41,19 +33,12 @@ class CefRenderFrameObserver : public content::RenderFrameObserver {
|
|||||||
void OnDestruct() override;
|
void OnDestruct() override;
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
service_manager::BinderRegistry* registry() { return ®istry_; }
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_interfaces() {
|
|
||||||
return &associated_interfaces_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachFrame(CefFrameImpl* frame);
|
void AttachFrame(CefFrameImpl* frame);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnLoadStart();
|
void OnLoadStart();
|
||||||
void OnLoadError();
|
void OnLoadError();
|
||||||
|
|
||||||
service_manager::BinderRegistry registry_;
|
|
||||||
blink::AssociatedInterfaceRegistry associated_interfaces_;
|
|
||||||
CefFrameImpl* frame_ = nullptr;
|
CefFrameImpl* frame_ = nullptr;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefRenderFrameObserver);
|
DISALLOW_COPY_AND_ASSIGN(CefRenderFrameObserver);
|
||||||
|
@ -6,42 +6,14 @@
|
|||||||
#include "libcef/renderer/render_thread_observer.h"
|
#include "libcef/renderer/render_thread_observer.h"
|
||||||
|
|
||||||
#include "libcef/common/cef_messages.h"
|
#include "libcef/common/cef_messages.h"
|
||||||
#include "libcef/common/net/net_resource_provider.h"
|
|
||||||
#include "libcef/renderer/blink_glue.h"
|
#include "libcef/renderer/blink_glue.h"
|
||||||
|
|
||||||
#include "components/visitedlink/renderer/visitedlink_reader.h"
|
|
||||||
#include "content/public/child/child_thread.h"
|
|
||||||
#include "content/public/renderer/render_thread.h"
|
|
||||||
#include "mojo/public/cpp/bindings/strong_binding.h"
|
|
||||||
#include "net/base/net_module.h"
|
|
||||||
#include "services/service_manager/public/cpp/connector.h"
|
|
||||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
|
||||||
#include "third_party/blink/public/platform/web_string.h"
|
#include "third_party/blink/public/platform/web_string.h"
|
||||||
#include "third_party/blink/public/platform/web_url.h"
|
#include "third_party/blink/public/platform/web_url.h"
|
||||||
#include "third_party/blink/public/web/web_security_policy.h"
|
#include "third_party/blink/public/web/web_security_policy.h"
|
||||||
|
|
||||||
namespace {
|
CefRenderThreadObserver::CefRenderThreadObserver() = default;
|
||||||
|
CefRenderThreadObserver::~CefRenderThreadObserver() = default;
|
||||||
chrome::mojom::DynamicParams* GetDynamicConfigParams() {
|
|
||||||
static base::NoDestructor<chrome::mojom::DynamicParams> dynamic_params;
|
|
||||||
return dynamic_params.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
bool CefRenderThreadObserver::is_incognito_process_ = false;
|
|
||||||
|
|
||||||
CefRenderThreadObserver::CefRenderThreadObserver() {
|
|
||||||
net::NetModule::SetResourceProvider(NetResourceProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
CefRenderThreadObserver::~CefRenderThreadObserver() {}
|
|
||||||
|
|
||||||
// static
|
|
||||||
const chrome::mojom::DynamicParams&
|
|
||||||
CefRenderThreadObserver::GetDynamicParams() {
|
|
||||||
return *GetDynamicConfigParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CefRenderThreadObserver::OnControlMessageReceived(
|
bool CefRenderThreadObserver::OnControlMessageReceived(
|
||||||
const IPC::Message& message) {
|
const IPC::Message& message) {
|
||||||
@ -56,39 +28,6 @@ bool CefRenderThreadObserver::OnControlMessageReceived(
|
|||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CefRenderThreadObserver::RegisterMojoInterfaces(
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_interfaces) {
|
|
||||||
associated_interfaces->AddInterface(base::Bind(
|
|
||||||
&CefRenderThreadObserver::OnRendererConfigurationAssociatedRequest,
|
|
||||||
base::Unretained(this)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::UnregisterMojoInterfaces(
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_interfaces) {
|
|
||||||
associated_interfaces->RemoveInterface(
|
|
||||||
chrome::mojom::RendererConfiguration::Name_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::SetInitialConfiguration(
|
|
||||||
bool is_incognito_process,
|
|
||||||
mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener) {
|
|
||||||
is_incognito_process_ = is_incognito_process;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::SetConfiguration(
|
|
||||||
chrome::mojom::DynamicParamsPtr params) {
|
|
||||||
*GetDynamicConfigParams() = std::move(*params);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::SetContentSettingRules(
|
|
||||||
const RendererContentSettingRules& rules) {}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::OnRendererConfigurationAssociatedRequest(
|
|
||||||
mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
|
|
||||||
receiver) {
|
|
||||||
renderer_configuration_receivers_.Add(this, std::move(receiver));
|
|
||||||
}
|
|
||||||
|
|
||||||
void CefRenderThreadObserver::OnModifyCrossOriginWhitelistEntry(
|
void CefRenderThreadObserver::OnModifyCrossOriginWhitelistEntry(
|
||||||
bool add,
|
bool add,
|
||||||
const Cef_CrossOriginWhiteListEntry_Params& params) {
|
const Cef_CrossOriginWhiteListEntry_Params& params) {
|
||||||
|
@ -9,47 +9,19 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "chrome/common/renderer_configuration.mojom.h"
|
|
||||||
#include "components/content_settings/core/common/content_settings.h"
|
|
||||||
#include "content/public/renderer/render_thread_observer.h"
|
#include "content/public/renderer/render_thread_observer.h"
|
||||||
#include "mojo/public/cpp/bindings/associated_binding_set.h"
|
|
||||||
#include "mojo/public/cpp/bindings/associated_receiver_set.h"
|
|
||||||
|
|
||||||
struct Cef_CrossOriginWhiteListEntry_Params;
|
struct Cef_CrossOriginWhiteListEntry_Params;
|
||||||
|
|
||||||
// This class sends and receives control messages in the renderer process.
|
// This class sends and receives control messages in the renderer process.
|
||||||
class CefRenderThreadObserver : public content::RenderThreadObserver,
|
class CefRenderThreadObserver : public content::RenderThreadObserver {
|
||||||
public chrome::mojom::RendererConfiguration {
|
|
||||||
public:
|
public:
|
||||||
CefRenderThreadObserver();
|
CefRenderThreadObserver();
|
||||||
~CefRenderThreadObserver() override;
|
~CefRenderThreadObserver() override;
|
||||||
|
|
||||||
static bool is_incognito_process() { return is_incognito_process_; }
|
|
||||||
|
|
||||||
// Return the dynamic parameters - those that may change while the
|
|
||||||
// render process is running.
|
|
||||||
static const chrome::mojom::DynamicParams& GetDynamicParams();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// content::RenderThreadObserver:
|
// content::RenderThreadObserver:
|
||||||
bool OnControlMessageReceived(const IPC::Message& message) override;
|
bool OnControlMessageReceived(const IPC::Message& message) override;
|
||||||
void RegisterMojoInterfaces(
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
|
|
||||||
void UnregisterMojoInterfaces(
|
|
||||||
blink::AssociatedInterfaceRegistry* associated_interfaces) override;
|
|
||||||
|
|
||||||
// chrome::mojom::RendererConfiguration:
|
|
||||||
void SetInitialConfiguration(
|
|
||||||
bool is_incognito_process,
|
|
||||||
mojo::PendingReceiver<chrome::mojom::ChromeOSListener> chromeos_listener)
|
|
||||||
override;
|
|
||||||
void SetConfiguration(chrome::mojom::DynamicParamsPtr params) override;
|
|
||||||
void SetContentSettingRules(
|
|
||||||
const RendererContentSettingRules& rules) override;
|
|
||||||
|
|
||||||
void OnRendererConfigurationAssociatedRequest(
|
|
||||||
mojo::PendingAssociatedReceiver<chrome::mojom::RendererConfiguration>
|
|
||||||
receiver);
|
|
||||||
|
|
||||||
// Message handlers called on the render thread.
|
// Message handlers called on the render thread.
|
||||||
void OnModifyCrossOriginWhitelistEntry(
|
void OnModifyCrossOriginWhitelistEntry(
|
||||||
@ -57,11 +29,6 @@ class CefRenderThreadObserver : public content::RenderThreadObserver,
|
|||||||
const Cef_CrossOriginWhiteListEntry_Params& params);
|
const Cef_CrossOriginWhiteListEntry_Params& params);
|
||||||
void OnClearCrossOriginWhitelist();
|
void OnClearCrossOriginWhitelist();
|
||||||
|
|
||||||
static bool is_incognito_process_;
|
|
||||||
|
|
||||||
mojo::AssociatedReceiverSet<chrome::mojom::RendererConfiguration>
|
|
||||||
renderer_configuration_receivers_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefRenderThreadObserver);
|
DISALLOW_COPY_AND_ASSIGN(CefRenderThreadObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,18 +9,56 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=94217ee1df26d037136df93adda612261606c569$
|
// $hash=51e9102befaf6a5e88a1a409932316a7571d84f8$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
#include "libcef_dll/cpptoc/client_cpptoc.h"
|
||||||
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||||
|
|
||||||
|
void CEF_CALLBACK browser_process_handler_get_cookieable_schemes(
|
||||||
|
struct _cef_browser_process_handler_t* self,
|
||||||
|
cef_string_list_t schemes,
|
||||||
|
int* include_defaults) {
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
DCHECK(self);
|
||||||
|
if (!self)
|
||||||
|
return;
|
||||||
|
// Verify param: schemes; type: string_vec_byref
|
||||||
|
DCHECK(schemes);
|
||||||
|
if (!schemes)
|
||||||
|
return;
|
||||||
|
// Verify param: include_defaults; type: bool_byref
|
||||||
|
DCHECK(include_defaults);
|
||||||
|
if (!include_defaults)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Translate param: schemes; type: string_vec_byref
|
||||||
|
std::vector<CefString> schemesList;
|
||||||
|
transfer_string_list_contents(schemes, schemesList);
|
||||||
|
// Translate param: include_defaults; type: bool_byref
|
||||||
|
bool include_defaultsBool =
|
||||||
|
(include_defaults && *include_defaults) ? true : false;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
CefBrowserProcessHandlerCppToC::Get(self)->GetCookieableSchemes(
|
||||||
|
schemesList, include_defaultsBool);
|
||||||
|
|
||||||
|
// Restore param: schemes; type: string_vec_byref
|
||||||
|
cef_string_list_clear(schemes);
|
||||||
|
transfer_string_list_contents(schemesList, schemes);
|
||||||
|
// Restore param: include_defaults; type: bool_byref
|
||||||
|
if (include_defaults)
|
||||||
|
*include_defaults = include_defaultsBool ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
void CEF_CALLBACK browser_process_handler_on_context_initialized(
|
void CEF_CALLBACK browser_process_handler_on_context_initialized(
|
||||||
struct _cef_browser_process_handler_t* self) {
|
struct _cef_browser_process_handler_t* self) {
|
||||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
@ -103,6 +141,8 @@ struct _cef_client_t* CEF_CALLBACK browser_process_handler_get_default_client(
|
|||||||
// CONSTRUCTOR - Do not edit by hand.
|
// CONSTRUCTOR - Do not edit by hand.
|
||||||
|
|
||||||
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
|
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
|
||||||
|
GetStruct()->get_cookieable_schemes =
|
||||||
|
browser_process_handler_get_cookieable_schemes;
|
||||||
GetStruct()->on_context_initialized =
|
GetStruct()->on_context_initialized =
|
||||||
browser_process_handler_on_context_initialized;
|
browser_process_handler_on_context_initialized;
|
||||||
GetStruct()->on_before_child_process_launch =
|
GetStruct()->on_before_child_process_launch =
|
||||||
|
@ -9,16 +9,48 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=9e8f283905d68b7b97c13a568040dc12c2859ad3$
|
// $hash=d591d5b715b75ccb712f18d29774836580bec514$
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||||
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
|
||||||
|
#include "libcef_dll/transfer_util.h"
|
||||||
|
|
||||||
// VIRTUAL METHODS - Body may be edited by hand.
|
// VIRTUAL METHODS - Body may be edited by hand.
|
||||||
|
|
||||||
|
NO_SANITIZE("cfi-icall")
|
||||||
|
void CefBrowserProcessHandlerCToCpp::GetCookieableSchemes(
|
||||||
|
std::vector<CefString>& schemes,
|
||||||
|
bool& include_defaults) {
|
||||||
|
cef_browser_process_handler_t* _struct = GetStruct();
|
||||||
|
if (CEF_MEMBER_MISSING(_struct, get_cookieable_schemes))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||||
|
|
||||||
|
// Translate param: schemes; type: string_vec_byref
|
||||||
|
cef_string_list_t schemesList = cef_string_list_alloc();
|
||||||
|
DCHECK(schemesList);
|
||||||
|
if (schemesList)
|
||||||
|
transfer_string_list_contents(schemes, schemesList);
|
||||||
|
// Translate param: include_defaults; type: bool_byref
|
||||||
|
int include_defaultsInt = include_defaults;
|
||||||
|
|
||||||
|
// Execute
|
||||||
|
_struct->get_cookieable_schemes(_struct, schemesList, &include_defaultsInt);
|
||||||
|
|
||||||
|
// Restore param:schemes; type: string_vec_byref
|
||||||
|
if (schemesList) {
|
||||||
|
schemes.clear();
|
||||||
|
transfer_string_list_contents(schemesList, schemes);
|
||||||
|
cef_string_list_free(schemesList);
|
||||||
|
}
|
||||||
|
// Restore param:include_defaults; type: bool_byref
|
||||||
|
include_defaults = include_defaultsInt ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
NO_SANITIZE("cfi-icall")
|
NO_SANITIZE("cfi-icall")
|
||||||
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
||||||
cef_browser_process_handler_t* _struct = GetStruct();
|
cef_browser_process_handler_t* _struct = GetStruct();
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
// implementations. See the translator.README.txt file in the tools directory
|
// implementations. See the translator.README.txt file in the tools directory
|
||||||
// for more information.
|
// for more information.
|
||||||
//
|
//
|
||||||
// $hash=857a8ad51f8b7ca9e62b9ce35d0cf510d84fb8b1$
|
// $hash=be0f9481659ed425a96ebfb004f6e5590953cf49$
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#error This file can be included DLL-side only
|
#error This file can be included DLL-side only
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include "include/capi/cef_browser_process_handler_capi.h"
|
#include "include/capi/cef_browser_process_handler_capi.h"
|
||||||
#include "include/cef_browser_process_handler.h"
|
#include "include/cef_browser_process_handler.h"
|
||||||
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
||||||
@ -35,6 +36,8 @@ class CefBrowserProcessHandlerCToCpp
|
|||||||
virtual ~CefBrowserProcessHandlerCToCpp();
|
virtual ~CefBrowserProcessHandlerCToCpp();
|
||||||
|
|
||||||
// CefBrowserProcessHandler methods.
|
// CefBrowserProcessHandler methods.
|
||||||
|
void GetCookieableSchemes(std::vector<CefString>& schemes,
|
||||||
|
bool& include_defaults) override;
|
||||||
void OnContextInitialized() override;
|
void OnContextInitialized() override;
|
||||||
void OnBeforeChildProcessLaunch(
|
void OnBeforeChildProcessLaunch(
|
||||||
CefRefPtr<CefCommandLine> command_line) override;
|
CefRefPtr<CefCommandLine> command_line) override;
|
||||||
|
@ -225,6 +225,9 @@ patches = [
|
|||||||
{
|
{
|
||||||
# Don't initialize ExtensionSystemFactory when extensions are disabled.
|
# Don't initialize ExtensionSystemFactory when extensions are disabled.
|
||||||
# https://bitbucket.org/chromiumembedded/cef/issues/2359
|
# https://bitbucket.org/chromiumembedded/cef/issues/2359
|
||||||
|
#
|
||||||
|
# Remove NOTREACHED() in GetContentSettingFromRulesImpl triggered by
|
||||||
|
# NavigationTest.LoadCrossOriginLoadURL with the chrome runtime.
|
||||||
'name': 'chrome_browser_content_settings',
|
'name': 'chrome_browser_content_settings',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
|
diff --git chrome/browser/browser_about_handler.cc chrome/browser/browser_about_handler.cc
|
||||||
|
index af2282034336..c49d920f73b5 100644
|
||||||
|
--- chrome/browser/browser_about_handler.cc
|
||||||
|
+++ chrome/browser/browser_about_handler.cc
|
||||||
|
@@ -95,6 +95,9 @@ bool HandleNonNavigationAboutURL(const GURL& url) {
|
||||||
|
FROM_HERE, base::BindOnce(&chrome::AttemptExit));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
+ if (base::LowerCaseEqualsASCII(spec, "chrome://ignore/")) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
||||||
index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
index 71ec3bbbf1b6..10d47a4f021e 100644
|
||||||
--- chrome/browser/ui/browser.cc
|
--- chrome/browser/ui/browser.cc
|
||||||
+++ chrome/browser/ui/browser.cc
|
+++ chrome/browser/ui/browser.cc
|
||||||
@@ -257,6 +257,20 @@
|
@@ -257,6 +257,20 @@
|
||||||
@ -37,7 +51,58 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
tab_strip_model_->AddObserver(this);
|
tab_strip_model_->AddObserver(this);
|
||||||
|
|
||||||
location_bar_model_ = std::make_unique<LocationBarModelImpl>(
|
location_bar_model_ = std::make_unique<LocationBarModelImpl>(
|
||||||
@@ -1713,6 +1734,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
@@ -1318,6 +1339,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
||||||
|
if (exclusive_access_manager_->HandleUserKeyEvent(event))
|
||||||
|
return content::KeyboardEventProcessingResult::HANDLED;
|
||||||
|
|
||||||
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
|
+ if (cef_browser_delegate_) {
|
||||||
|
+ auto result = cef_browser_delegate_->PreHandleKeyboardEvent(source, event);
|
||||||
|
+ if (result != content::KeyboardEventProcessingResult::NOT_HANDLED)
|
||||||
|
+ return result;
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
return window()->PreHandleKeyboardEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1325,8 +1354,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
||||||
|
const NativeWebKeyboardEvent& event) {
|
||||||
|
DevToolsWindow* devtools_window =
|
||||||
|
DevToolsWindow::GetInstanceForInspectedWebContents(source);
|
||||||
|
- return (devtools_window && devtools_window->ForwardKeyboardEvent(event)) ||
|
||||||
|
- window()->HandleKeyboardEvent(event);
|
||||||
|
+ if (devtools_window && devtools_window->ForwardKeyboardEvent(event)) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
|
+ if (cef_browser_delegate_ &&
|
||||||
|
+ cef_browser_delegate_->HandleKeyboardEvent(source, event)) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ return window()->HandleKeyboardEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Browser::TabsNeedBeforeUnloadFired() {
|
||||||
|
@@ -1601,6 +1640,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
||||||
|
return window->OpenURLFromTab(source, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
|
+ if (cef_browser_delegate_) {
|
||||||
|
+ auto web_contents = cef_browser_delegate_->OpenURLFromTab(source, params);
|
||||||
|
+ if (!web_contents)
|
||||||
|
+ return nullptr;
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
NavigateParams nav_params(this, params.url, params.transition);
|
||||||
|
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
||||||
|
nav_params.source_contents = source;
|
||||||
|
@@ -1713,6 +1760,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
||||||
bool to_different_document) {
|
bool to_different_document) {
|
||||||
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
|
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
|
||||||
UpdateWindowForLoadingStateChanged(source, to_different_document);
|
UpdateWindowForLoadingStateChanged(source, to_different_document);
|
||||||
@ -46,7 +111,7 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Browser::CloseContents(WebContents* source) {
|
void Browser::CloseContents(WebContents* source) {
|
||||||
@@ -1740,6 +1763,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
@@ -1740,6 +1789,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||||
@ -55,7 +120,7 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
if (!GetStatusBubble())
|
if (!GetStatusBubble())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1747,6 +1772,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
@@ -1747,6 +1798,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||||
GetStatusBubble()->SetURL(url);
|
GetStatusBubble()->SetURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +138,18 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
void Browser::ContentsMouseEvent(WebContents* source,
|
void Browser::ContentsMouseEvent(WebContents* source,
|
||||||
bool motion,
|
bool motion,
|
||||||
bool exited) {
|
bool exited) {
|
||||||
@@ -1899,6 +1935,8 @@ void Browser::RendererResponsive(
|
@@ -1863,6 +1925,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||||
|
|
||||||
|
// Make the tab show up in the task manager.
|
||||||
|
task_manager::WebContentsTags::CreateForTabContents(new_contents);
|
||||||
|
+
|
||||||
|
+ CALL_CEF_DELEGATE(WebContentsCreated, source_contents,
|
||||||
|
+ opener_render_process_id, opener_render_frame_id,
|
||||||
|
+ frame_name, target_url, new_contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) {
|
||||||
|
@@ -1899,6 +1965,8 @@ void Browser::RendererResponsive(
|
||||||
void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) {
|
void Browser::DidNavigateMainFramePostCommit(WebContents* web_contents) {
|
||||||
if (web_contents == tab_strip_model_->GetActiveWebContents())
|
if (web_contents == tab_strip_model_->GetActiveWebContents())
|
||||||
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
|
UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
|
||||||
@ -82,7 +158,7 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
|
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
|
||||||
@@ -1949,11 +1987,15 @@ void Browser::EnterFullscreenModeForTab(
|
@@ -1949,11 +2017,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||||
const blink::mojom::FullscreenOptions& options) {
|
const blink::mojom::FullscreenOptions& options) {
|
||||||
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
|
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
|
||||||
requesting_frame, options.display_id);
|
requesting_frame, options.display_id);
|
||||||
@ -98,7 +174,7 @@ index 71ec3bbbf1b6..8b99a3ac7de2 100644
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
|
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
|
||||||
@@ -2814,6 +2856,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
@@ -2814,6 +2886,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||||
content_translate_driver->RemoveObserver(this);
|
content_translate_driver->RemoveObserver(this);
|
||||||
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
||||||
}
|
}
|
||||||
@ -178,3 +254,40 @@ index ab2a03e6e878..aef94abf4fd8 100644
|
|||||||
const base::ElapsedTimer creation_timer_;
|
const base::ElapsedTimer creation_timer_;
|
||||||
|
|
||||||
// Stores the list of browser windows showing via a menu.
|
// Stores the list of browser windows showing via a menu.
|
||||||
|
diff --git chrome/browser/ui/browser_navigator.cc chrome/browser/ui/browser_navigator.cc
|
||||||
|
index 6d6a3b90dcad..fbfe4a0c959c 100644
|
||||||
|
--- chrome/browser/ui/browser_navigator.cc
|
||||||
|
+++ chrome/browser/ui/browser_navigator.cc
|
||||||
|
@@ -435,6 +435,13 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
|
||||||
|
std::unique_ptr<WebContents> target_contents =
|
||||||
|
WebContents::Create(create_params);
|
||||||
|
|
||||||
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
|
+ auto cef_delegate = params.browser->cef_delegate();
|
||||||
|
+ if (cef_delegate) {
|
||||||
|
+ cef_delegate->OnWebContentsCreated(target_contents.get());
|
||||||
|
+ }
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
// New tabs can have WebUI URLs that will make calls back to arbitrary
|
||||||
|
// tab helpers, so the entire set of tab helpers needs to be set up
|
||||||
|
// immediately.
|
||||||
|
diff --git chrome/browser/ui/browser_tabstrip.cc chrome/browser/ui/browser_tabstrip.cc
|
||||||
|
index c8df2ade2443..0e350adda289 100644
|
||||||
|
--- chrome/browser/ui/browser_tabstrip.cc
|
||||||
|
+++ chrome/browser/ui/browser_tabstrip.cc
|
||||||
|
@@ -28,9 +28,13 @@ void AddTabAt(Browser* browser,
|
||||||
|
// Time new tab page creation time. We keep track of the timing data in
|
||||||
|
// WebContents, but we want to include the time it takes to create the
|
||||||
|
// WebContents object too.
|
||||||
|
+ // For CEF use a PageTransition that matches
|
||||||
|
+ // CefFrameHostImpl::kPageTransitionExplicit.
|
||||||
|
base::TimeTicks new_tab_start_time = base::TimeTicks::Now();
|
||||||
|
NavigateParams params(browser, url.is_empty() ? browser->GetNewTabURL() : url,
|
||||||
|
- ui::PAGE_TRANSITION_TYPED);
|
||||||
|
+ static_cast<ui::PageTransition>(
|
||||||
|
+ ui::PAGE_TRANSITION_TYPED |
|
||||||
|
+ ui::PAGE_TRANSITION_FROM_ADDRESS_BAR));
|
||||||
|
params.disposition = foreground ? WindowOpenDisposition::NEW_FOREGROUND_TAB
|
||||||
|
: WindowOpenDisposition::NEW_BACKGROUND_TAB;
|
||||||
|
params.tabstrip_index = idx;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
diff --git chrome/browser/content_settings/host_content_settings_map_factory.cc chrome/browser/content_settings/host_content_settings_map_factory.cc
|
diff --git chrome/browser/content_settings/host_content_settings_map_factory.cc chrome/browser/content_settings/host_content_settings_map_factory.cc
|
||||||
index 3e2d1221d91e..b0572e99c613 100644
|
index 3e2d1221d91e..4fbf30796bdb 100644
|
||||||
--- chrome/browser/content_settings/host_content_settings_map_factory.cc
|
--- chrome/browser/content_settings/host_content_settings_map_factory.cc
|
||||||
+++ chrome/browser/content_settings/host_content_settings_map_factory.cc
|
+++ chrome/browser/content_settings/host_content_settings_map_factory.cc
|
||||||
@@ -8,6 +8,7 @@
|
@@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "base/feature_list.h"
|
#include "base/feature_list.h"
|
||||||
#include "build/buildflag.h"
|
#include "build/buildflag.h"
|
||||||
+#include "cef/libcef/features/features.h"
|
+#include "cef/libcef/features/runtime.h"
|
||||||
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
|
#include "chrome/browser/profiles/off_the_record_profile_impl.h"
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "chrome/browser/search_engines/template_url_service_factory.h"
|
#include "chrome/browser/search_engines/template_url_service_factory.h"
|
||||||
@ -26,7 +26,7 @@ index 3e2d1221d91e..b0572e99c613 100644
|
|||||||
#endif
|
#endif
|
||||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||||
+#if BUILDFLAG(ENABLE_CEF)
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
+ if (extensions::ExtensionsEnabled()) {
|
+ if (!cef::IsAlloyRuntimeEnabled() || extensions::ExtensionsEnabled()) {
|
||||||
+#endif
|
+#endif
|
||||||
DependsOn(
|
DependsOn(
|
||||||
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
|
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
|
||||||
@ -41,7 +41,7 @@ index 3e2d1221d91e..b0572e99c613 100644
|
|||||||
|
|
||||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||||
+#if BUILDFLAG(ENABLE_CEF)
|
+#if BUILDFLAG(ENABLE_CEF)
|
||||||
+ if (extensions::ExtensionsEnabled()) {
|
+ if (!cef::IsAlloyRuntimeEnabled() || extensions::ExtensionsEnabled()) {
|
||||||
+#endif
|
+#endif
|
||||||
// These must be registered before before the HostSettings are passed over to
|
// These must be registered before before the HostSettings are passed over to
|
||||||
// the IOThread. Simplest to do this on construction.
|
// the IOThread. Simplest to do this on construction.
|
||||||
@ -53,3 +53,16 @@ index 3e2d1221d91e..b0572e99c613 100644
|
|||||||
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
||||||
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
|
||||||
SupervisedUserSettingsService* supervised_service =
|
SupervisedUserSettingsService* supervised_service =
|
||||||
|
diff --git components/content_settings/renderer/content_settings_agent_impl.cc components/content_settings/renderer/content_settings_agent_impl.cc
|
||||||
|
index 450005f9fc0b..13fca8b3e2d2 100644
|
||||||
|
--- components/content_settings/renderer/content_settings_agent_impl.cc
|
||||||
|
+++ components/content_settings/renderer/content_settings_agent_impl.cc
|
||||||
|
@@ -183,7 +183,7 @@ ContentSetting GetContentSettingFromRulesImpl(
|
||||||
|
return rule.GetContentSetting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
- NOTREACHED();
|
||||||
|
+ // NOTREACHED();
|
||||||
|
return CONTENT_SETTING_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user