diff --git content/browser/devtools/devtools_http_handler.cc content/browser/devtools/devtools_http_handler.cc index 687de58ebbf49..b2588b21b2462 100644 --- content/browser/devtools/devtools_http_handler.cc +++ content/browser/devtools/devtools_http_handler.cc @@ -575,7 +575,7 @@ void DevToolsHttpHandler::OnJsonRequest( version.SetString("Protocol-Version", DevToolsAgentHost::GetProtocolVersion()); version.SetString("WebKit-Version", GetWebKitVersion()); - version.SetString("Browser", GetContentClient()->browser()->GetProduct()); + version.SetString("Browser", GetContentClient()->browser()->GetChromeProduct()); version.SetString("User-Agent", GetContentClient()->browser()->GetUserAgent()); version.SetString("V8-Version", V8_VERSION_STRING); diff --git content/browser/loader/navigation_url_loader_impl.cc content/browser/loader/navigation_url_loader_impl.cc index 20748b3098d8b..f6a7e94f8d0af 100644 --- content/browser/loader/navigation_url_loader_impl.cc +++ content/browser/loader/navigation_url_loader_impl.cc @@ -660,6 +660,13 @@ NavigationURLLoaderImpl::PrepareForNonInterceptedRequest( resource_request_->has_user_gesture, initiating_origin, &loader_factory); + if (!handled) { + handled = GetContentClient()->browser()->HandleExternalProtocol( + web_contents_getter_, frame_tree_node_id_, + navigation_ui_data_.get(), request_info_->sandbox_flags, + *resource_request_, &loader_factory); + } + if (loader_factory) { factory = base::MakeRefCounted( std::move(loader_factory)); diff --git content/public/browser/content_browser_client.cc content/public/browser/content_browser_client.cc index 85f0857a66fd6..00ff3cb1cfaec 100644 --- content/public/browser/content_browser_client.cc +++ content/public/browser/content_browser_client.cc @@ -9,7 +9,7 @@ // declarations instead of including more headers. If that is infeasible, adjust // the limit. For more info, see // https://chromium.googlesource.com/chromium/src/+/HEAD/docs/wmax_tokens.md -#pragma clang max_tokens_here 850000 +// #pragma clang max_tokens_here 850000 #include @@ -867,7 +867,7 @@ ContentBrowserClient::CreateURLLoaderHandlerForServiceWorkerNavigationPreload( void ContentBrowserClient::OnNetworkServiceCreated( network::mojom::NetworkService* network_service) {} -void ContentBrowserClient::ConfigureNetworkContextParams( +bool ContentBrowserClient::ConfigureNetworkContextParams( BrowserContext* context, bool in_memory, const base::FilePath& relative_partition_path, @@ -876,6 +876,7 @@ void ContentBrowserClient::ConfigureNetworkContextParams( cert_verifier_creation_params) { network_context_params->user_agent = GetUserAgent(); network_context_params->accept_language = "en-us,en"; + return true; } std::vector diff --git content/public/browser/content_browser_client.h content/public/browser/content_browser_client.h index ec5a3515a248f..637e4edfc2738 100644 --- content/public/browser/content_browser_client.h +++ content/public/browser/content_browser_client.h @@ -33,6 +33,7 @@ #include "content/public/browser/login_delegate.h" #include "content/public/browser/mojo_binder_policy_map.h" #include "content/public/browser/storage_partition_config.h" +#include "content/public/browser/web_contents.h" #include "content/public/browser/web_ui_browser_interface_broker_registry.h" #include "content/public/common/page_visibility_state.h" #include "content/public/common/window_container_type.mojom-forward.h" @@ -1619,7 +1620,7 @@ class CONTENT_EXPORT ContentBrowserClient { // // If |relative_partition_path| is the empty string, it means this needs to // create the default NetworkContext for the BrowserContext. - virtual void ConfigureNetworkContextParams( + virtual bool ConfigureNetworkContextParams( BrowserContext* context, bool in_memory, const base::FilePath& relative_partition_path, @@ -1803,6 +1804,15 @@ class CONTENT_EXPORT ContentBrowserClient { const absl::optional& initiating_origin, mojo::PendingRemote* out_factory); + // Same as above, but exposing the whole ResourceRequest object. + virtual bool HandleExternalProtocol( + WebContents::Getter web_contents_getter, + int frame_tree_node_id, + NavigationUIData* navigation_data, + network::mojom::WebSandboxFlags sandbox_flags, + const network::ResourceRequest& request, + mojo::PendingRemote* out_factory) { return false; } + // Creates an OverlayWindow to be used for Picture-in-Picture. This window // will house the content shown when in Picture-in-Picture mode. This will // return a new OverlayWindow. @@ -1880,6 +1890,10 @@ class CONTENT_EXPORT ContentBrowserClient { // Used as part of the user agent string. virtual std::string GetProduct(); + // Returns the Chrome-specific product string. This is used for compatibility + // purposes with external tools like Selenium. + virtual std::string GetChromeProduct() { return GetProduct(); } + // Returns the user agent.Content may cache this value. virtual std::string GetUserAgent(); diff --git content/public/renderer/content_renderer_client.h content/public/renderer/content_renderer_client.h index 0b098038d2f56..bd85dbf2727c1 100644 --- content/public/renderer/content_renderer_client.h +++ content/public/renderer/content_renderer_client.h @@ -86,6 +86,9 @@ class CONTENT_EXPORT ContentRendererClient { // binding requests from RenderProcessHost::BindReceiver(). virtual void ExposeInterfacesToBrowser(mojo::BinderMap* binders) {} + // Notifies that the RenderThread can now send sync IPC messages. + virtual void RenderThreadConnected() {} + // Notifies that a new RenderFrame has been created. virtual void RenderFrameCreated(RenderFrame* render_frame) {} @@ -297,6 +300,10 @@ class CONTENT_EXPORT ContentRendererClient { // This method may invalidate the frame. virtual void RunScriptsAtDocumentIdle(RenderFrame* render_frame) {} + // Notifies that a DevTools agent has attached or detached. + virtual void DevToolsAgentAttached() {} + virtual void DevToolsAgentDetached() {} + // Allows subclasses to enable some runtime features before Blink has // started. virtual void SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {} diff --git content/renderer/render_thread_impl.cc content/renderer/render_thread_impl.cc index 4f7ea9bd9117e..3e325c0514de0 100644 --- content/renderer/render_thread_impl.cc +++ content/renderer/render_thread_impl.cc @@ -663,6 +663,8 @@ void RenderThreadImpl::Init() { GetContentClient()->renderer()->CreateURLLoaderThrottleProvider( blink::URLLoaderThrottleProviderType::kFrame); + GetContentClient()->renderer()->RenderThreadConnected(); + GetAssociatedInterfaceRegistry()->AddInterface(base::BindRepeating( &RenderThreadImpl::OnRendererInterfaceReceiver, base::Unretained(this))); diff --git content/renderer/renderer_blink_platform_impl.cc content/renderer/renderer_blink_platform_impl.cc index 6616ad76bc307..95524ec98ce5c 100644 --- content/renderer/renderer_blink_platform_impl.cc +++ content/renderer/renderer_blink_platform_impl.cc @@ -1086,6 +1086,15 @@ SkBitmap* RendererBlinkPlatformImpl::GetSadPageBitmap() { //------------------------------------------------------------------------------ +void RendererBlinkPlatformImpl::DevToolsAgentAttached() { + GetContentClient()->renderer()->DevToolsAgentAttached(); +} +void RendererBlinkPlatformImpl::DevToolsAgentDetached() { + GetContentClient()->renderer()->DevToolsAgentDetached(); +} + +//------------------------------------------------------------------------------ + mojo::SharedRemote RendererBlinkPlatformImpl::GetCodeCacheHost() { base::AutoLock lock(code_cache_host_lock_); diff --git content/renderer/renderer_blink_platform_impl.h content/renderer/renderer_blink_platform_impl.h index 745204f21d304..87b7767fcba68 100644 --- content/renderer/renderer_blink_platform_impl.h +++ content/renderer/renderer_blink_platform_impl.h @@ -262,6 +262,9 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { const blink::WebURL& url, blink::WebVector* csp) override; + void DevToolsAgentAttached() override; + void DevToolsAgentDetached() override; + // Tells this platform that the renderer is locked to a site (i.e., a scheme // plus eTLD+1, such as https://google.com), or to a more specific origin. void SetIsLockedToSite();