diff --git chrome/browser/download/download_target_determiner.cc chrome/browser/download/download_target_determiner.cc index bf1ca3fd565b..7e758b4da15c 100644 --- chrome/browser/download/download_target_determiner.cc +++ chrome/browser/download/download_target_determiner.cc @@ -630,8 +630,8 @@ void IsHandledBySafePlugin(content::ResourceContext* resource_context, content::PluginService* plugin_service = content::PluginService::GetInstance(); bool plugin_found = plugin_service->GetPluginInfo( - -1, -1, resource_context, url, url::Origin(), mime_type, false, &is_stale, - &plugin_info, &actual_mime_type); + -1, -1, resource_context, url, true, url::Origin(), mime_type, false, + &is_stale, &plugin_info, &actual_mime_type); if (is_stale && stale_plugin_action == RETRY_IF_STALE_PLUGIN_LIST) { // The GetPlugins call causes the plugin list to be refreshed. Once that's // done we can retry the GetPluginInfo call. We break out of this cycle diff --git chrome/browser/plugins/chrome_plugin_service_filter.cc chrome/browser/plugins/chrome_plugin_service_filter.cc index 55801ac0fee7..8e993e959ca2 100644 --- chrome/browser/plugins/chrome_plugin_service_filter.cc +++ chrome/browser/plugins/chrome_plugin_service_filter.cc @@ -167,6 +167,7 @@ bool ChromePluginServiceFilter::IsPluginAvailable( int render_frame_id, const void* context, const GURL& plugin_content_url, + bool is_main_frame, const url::Origin& main_frame_origin, content::WebPluginInfo* plugin) { base::AutoLock auto_lock(lock_); diff --git chrome/browser/plugins/chrome_plugin_service_filter.h chrome/browser/plugins/chrome_plugin_service_filter.h index c707c8773a74..20bdf74abf01 100644 --- chrome/browser/plugins/chrome_plugin_service_filter.h +++ chrome/browser/plugins/chrome_plugin_service_filter.h @@ -65,6 +65,7 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, int render_frame_id, const void* context, const GURL& plugin_content_url, + bool is_main_frame, const url::Origin& main_frame_origin, content::WebPluginInfo* plugin) override; diff --git chrome/browser/plugins/pdf_iframe_navigation_throttle.cc chrome/browser/plugins/pdf_iframe_navigation_throttle.cc index 2eb7f21919fd..4218d3352d70 100644 --- chrome/browser/plugins/pdf_iframe_navigation_throttle.cc +++ chrome/browser/plugins/pdf_iframe_navigation_throttle.cc @@ -71,8 +71,8 @@ bool IsPDFPluginEnabled(content::NavigationHandle* navigation_handle, content::WebPluginInfo plugin_info; return content::PluginService::GetInstance()->GetPluginInfo( process_id, routing_id, resource_context, navigation_handle->GetURL(), - web_contents->GetMainFrame()->GetLastCommittedOrigin(), kPDFMimeType, - false /* allow_wildcard */, is_stale, &plugin_info, + false, web_contents->GetMainFrame()->GetLastCommittedOrigin(), + kPDFMimeType, false /* allow_wildcard */, is_stale, &plugin_info, nullptr /* actual_mime_type */); } #endif diff --git chrome/browser/ui/views/frame/browser_root_view.cc chrome/browser/ui/views/frame/browser_root_view.cc index 786365927e71..27d32872d8d0 100644 --- chrome/browser/ui/views/frame/browser_root_view.cc +++ chrome/browser/ui/views/frame/browser_root_view.cc @@ -70,7 +70,7 @@ void OnFindURLMimeType(const GURL& url, content::PluginService::GetInstance()->GetPluginInfo( -1, // process ID MSG_ROUTING_NONE, // routing ID - profile->GetResourceContext(), url, url::Origin(), mime_type, + profile->GetResourceContext(), url, true, url::Origin(), mime_type, false, nullptr, &plugin, nullptr)); } diff --git content/browser/devtools/devtools_http_handler.cc content/browser/devtools/devtools_http_handler.cc index 83772ae8cca7..0eadd7c9a37a 100644 --- content/browser/devtools/devtools_http_handler.cc +++ content/browser/devtools/devtools_http_handler.cc @@ -572,7 +572,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/frame_host/render_frame_message_filter.cc content/browser/frame_host/render_frame_message_filter.cc index 5815fdfd6259..307c222c0d40 100644 --- content/browser/frame_host/render_frame_message_filter.cc +++ content/browser/frame_host/render_frame_message_filter.cc @@ -493,6 +493,7 @@ void RenderFrameMessageFilter::OnAre3DAPIsBlocked(int render_frame_id, void RenderFrameMessageFilter::OnGetPluginInfo( int render_frame_id, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool* found, @@ -504,8 +505,8 @@ void RenderFrameMessageFilter::OnGetPluginInfo( bool allow_wildcard = true; *found = plugin_service_->GetPluginInfo( render_process_id_, render_frame_id, resource_context_, url, - main_frame_origin, mime_type, allow_wildcard, nullptr, info, - actual_mime_type); + is_main_frame, main_frame_origin, mime_type, allow_wildcard, nullptr, + info, actual_mime_type); } void RenderFrameMessageFilter::OnOpenChannelToPepperPlugin( diff --git content/browser/frame_host/render_frame_message_filter.h content/browser/frame_host/render_frame_message_filter.h index e7900ef22a0d..f05d2ee128bd 100644 --- content/browser/frame_host/render_frame_message_filter.h +++ content/browser/frame_host/render_frame_message_filter.h @@ -113,6 +113,7 @@ class CONTENT_EXPORT RenderFrameMessageFilter : public BrowserMessageFilter { #if BUILDFLAG(ENABLE_PLUGINS) void OnGetPluginInfo(int render_frame_id, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool* found, diff --git content/browser/loader/mime_sniffing_resource_handler.cc content/browser/loader/mime_sniffing_resource_handler.cc index b0458c1168d9..98f7ae7b7899 100644 --- content/browser/loader/mime_sniffing_resource_handler.cc +++ content/browser/loader/mime_sniffing_resource_handler.cc @@ -510,8 +510,8 @@ bool MimeSniffingResourceHandler::CheckForPluginHandler( WebPluginInfo plugin; bool has_plugin = plugin_service_->GetPluginInfo( info->GetChildID(), info->GetRenderFrameID(), info->GetContext(), - request()->url(), url::Origin(), response_->head.mime_type, - allow_wildcard, &stale, &plugin, nullptr); + request()->url(), info->IsMainFrame(), url::Origin(), + response_->head.mime_type, allow_wildcard, &stale, &plugin, nullptr); if (stale) { // Refresh the plugins asynchronously. diff --git content/browser/loader/navigation_url_loader_impl.cc content/browser/loader/navigation_url_loader_impl.cc index 8a5502430547..689f5dbfe4a6 100644 --- content/browser/loader/navigation_url_loader_impl.cc +++ content/browser/loader/navigation_url_loader_impl.cc @@ -1061,6 +1061,13 @@ class NavigationURLLoaderImpl::URLLoaderRequestController static_cast(resource_request_->transition_type), resource_request_->has_user_gesture, &loader_factory); + if (!handled) { + handled = GetContentClient()->browser()->HandleExternalProtocol( + web_contents_getter_, frame_tree_node_id_, + navigation_ui_data_.get(), *resource_request_, + &proxied_factory_request_, &loader_factory); + } + if (loader_factory) { factory = base::MakeRefCounted( @@ -1310,7 +1317,7 @@ class NavigationURLLoaderImpl::URLLoaderRequestController // path does as well for navigations. bool has_plugin = PluginService::GetInstance()->GetPluginInfo( -1 /* render_process_id */, -1 /* render_frame_id */, resource_context_, - resource_request_->url, url::Origin(), head.mime_type, + resource_request_->url, true, url::Origin(), head.mime_type, false /* allow_wildcard */, &stale, &plugin, nullptr); if (stale) { diff --git content/browser/plugin_service_impl.cc content/browser/plugin_service_impl.cc index a599f989065f..115867edec92 100644 --- content/browser/plugin_service_impl.cc +++ content/browser/plugin_service_impl.cc @@ -302,6 +302,7 @@ bool PluginServiceImpl::GetPluginInfo(int render_process_id, int render_frame_id, ResourceContext* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, @@ -318,7 +319,8 @@ bool PluginServiceImpl::GetPluginInfo(int render_process_id, for (size_t i = 0; i < plugins.size(); ++i) { if (!filter_ || filter_->IsPluginAvailable(render_process_id, render_frame_id, context, - url, main_frame_origin, &plugins[i])) { + url, is_main_frame, main_frame_origin, + &plugins[i])) { *info = plugins[i]; if (actual_mime_type) *actual_mime_type = mime_types[i]; diff --git content/browser/plugin_service_impl.h content/browser/plugin_service_impl.h index c4c0ed551697..b234e239bba4 100644 --- content/browser/plugin_service_impl.h +++ content/browser/plugin_service_impl.h @@ -57,6 +57,7 @@ class CONTENT_EXPORT PluginServiceImpl : public PluginService { int render_frame_id, ResourceContext* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, diff --git content/browser/renderer_host/plugin_registry_impl.cc content/browser/renderer_host/plugin_registry_impl.cc index 717db1507d66..d44142b67ff7 100644 --- content/browser/renderer_host/plugin_registry_impl.cc +++ content/browser/renderer_host/plugin_registry_impl.cc @@ -27,6 +27,7 @@ void PluginRegistryImpl::Bind(blink::mojom::PluginRegistryRequest request) { } void PluginRegistryImpl::GetPlugins(bool refresh, + bool is_main_frame, const url::Origin& main_frame_origin, GetPluginsCallback callback) { auto* plugin_service = PluginServiceImpl::GetInstance(); @@ -48,10 +49,11 @@ void PluginRegistryImpl::GetPlugins(bool refresh, plugin_service->GetPlugins(base::BindOnce( &PluginRegistryImpl::GetPluginsComplete, weak_factory_.GetWeakPtr(), - main_frame_origin, std::move(callback))); + is_main_frame, main_frame_origin, std::move(callback))); } void PluginRegistryImpl::GetPluginsComplete( + bool is_main_frame, const url::Origin& main_frame_origin, GetPluginsCallback callback, const std::vector& all_plugins) { @@ -61,7 +63,7 @@ void PluginRegistryImpl::GetPluginsComplete( GetContentClient()->browser()->GetPluginMimeTypesWithExternalHandlers( resource_context_); - const int child_process_id = -1; + const int child_process_id = render_process_id_; const int routing_id = MSG_ROUTING_NONE; // In this loop, copy the WebPluginInfo (and do not use a reference) because // the filter might mutate it. @@ -70,7 +72,7 @@ void PluginRegistryImpl::GetPluginsComplete( if (!filter || filter->IsPluginAvailable(child_process_id, routing_id, resource_context_, main_frame_origin.GetURL(), - main_frame_origin, &plugin)) { + is_main_frame, main_frame_origin, &plugin)) { auto plugin_blink = blink::mojom::PluginInfo::New(); plugin_blink->name = plugin.name; plugin_blink->description = plugin.desc; diff --git content/browser/renderer_host/plugin_registry_impl.h content/browser/renderer_host/plugin_registry_impl.h index 061dd21cbbd1..a418b8d08091 100644 --- content/browser/renderer_host/plugin_registry_impl.h +++ content/browser/renderer_host/plugin_registry_impl.h @@ -24,17 +24,24 @@ class PluginRegistryImpl : public blink::mojom::PluginRegistry { // blink::mojom::PluginRegistry void GetPlugins(bool refresh, + bool is_main_frame, const url::Origin& main_frame_origin, GetPluginsCallback callback) override; + void set_render_process_id(int render_process_id) { + render_process_id_ = render_process_id; + } + private: - void GetPluginsComplete(const url::Origin& main_frame_origin, + void GetPluginsComplete(bool is_main_frame, + const url::Origin& main_frame_origin, GetPluginsCallback callback, const std::vector& all_plugins); ResourceContext* const resource_context_; mojo::BindingSet bindings_; base::TimeTicks last_plugin_refresh_time_; + int render_process_id_ = -1; base::WeakPtrFactory weak_factory_{this}; }; diff --git content/common/frame_messages.h content/common/frame_messages.h index 60077e7ec11a..1e703ba07b4d 100644 --- content/common/frame_messages.h +++ content/common/frame_messages.h @@ -1228,9 +1228,10 @@ IPC_MESSAGE_ROUTED1(FrameHostMsg_PepperStopsPlayback, // type. If there is no matching plugin, |found| is false. // |actual_mime_type| is the actual mime type supported by the // found plugin. -IPC_SYNC_MESSAGE_CONTROL4_3(FrameHostMsg_GetPluginInfo, +IPC_SYNC_MESSAGE_CONTROL5_3(FrameHostMsg_GetPluginInfo, int /* render_frame_id */, GURL /* url */, + bool /* is_main_frame */, url::Origin /* main_frame_origin */, std::string /* mime_type */, bool /* found */, diff --git content/public/browser/content_browser_client.h content/public/browser/content_browser_client.h index a14b357dca01..780861333a4b 100644 --- content/public/browser/content_browser_client.h +++ content/public/browser/content_browser_client.h @@ -1492,6 +1492,15 @@ class CONTENT_EXPORT ContentBrowserClient { bool has_user_gesture, network::mojom::URLLoaderFactoryPtr* out_factory); + // Same as above, but exposing the whole ResourceRequest object. + virtual bool HandleExternalProtocol( + ResourceRequestInfo::WebContentsGetter web_contents_getter, + int frame_tree_node_id, + NavigationUIData* navigation_data, + const network::ResourceRequest& request, + network::mojom::URLLoaderFactoryRequest* factory_request, + network::mojom::URLLoaderFactoryPtr* 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. @@ -1562,6 +1571,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/browser/plugin_service.h content/public/browser/plugin_service.h index 7646bdad2061..887ac022f2a1 100644 --- content/public/browser/plugin_service.h +++ content/public/browser/plugin_service.h @@ -75,6 +75,7 @@ class CONTENT_EXPORT PluginService { int render_frame_id, ResourceContext* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, diff --git content/public/browser/plugin_service_filter.h content/public/browser/plugin_service_filter.h index 3b610b1f554e..7c439e060779 100644 --- content/public/browser/plugin_service_filter.h +++ content/public/browser/plugin_service_filter.h @@ -33,6 +33,7 @@ class PluginServiceFilter { int render_frame_id, const void* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, WebPluginInfo* plugin) = 0; diff --git content/public/renderer/content_renderer_client.h content/public/renderer/content_renderer_client.h index bfc62d176668..b9f695eaad5a 100644 --- content/public/renderer/content_renderer_client.h +++ content/public/renderer/content_renderer_client.h @@ -74,6 +74,9 @@ class CONTENT_EXPORT ContentRendererClient { // Notifies us that the RenderThread has been created. virtual void RenderThreadStarted() {} + // 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) {} @@ -326,6 +329,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/public/renderer/render_frame_observer.h content/public/renderer/render_frame_observer.h index 0e2e86e6a2af..b44e90f69263 100644 --- content/public/renderer/render_frame_observer.h +++ content/public/renderer/render_frame_observer.h @@ -214,6 +214,9 @@ class CONTENT_EXPORT RenderFrameObserver : public IPC::Listener, virtual void DidReceiveTransferSizeUpdate(int resource_id, int received_data_length) {} + // Called when this frame gains focus. + virtual void FrameFocused() {} + // Called when the focused element has changed to |element|. virtual void FocusedElementChanged(const blink::WebElement& element) {} diff --git content/renderer/render_frame_impl.cc content/renderer/render_frame_impl.cc index f5f11bd31f7a..031ac3d689db 100644 --- content/renderer/render_frame_impl.cc +++ content/renderer/render_frame_impl.cc @@ -4118,7 +4118,8 @@ blink::WebPlugin* RenderFrameImpl::CreatePlugin( std::string mime_type; bool found = false; Send(new FrameHostMsg_GetPluginInfo( - routing_id_, params.url, frame_->Top()->GetSecurityOrigin(), + routing_id_, params.url, frame_->Parent() == nullptr, + frame_->Top()->GetSecurityOrigin(), params.mime_type.Utf8(), &found, &info, &mime_type)); if (!found) return nullptr; @@ -4533,6 +4534,8 @@ void RenderFrameImpl::FrameDetached(DetachType type) { void RenderFrameImpl::FrameFocused() { Send(new FrameHostMsg_FrameFocused(routing_id_)); + for (auto& observer : observers_) + observer.FrameFocused(); } void RenderFrameImpl::DidChangeName(const blink::WebString& name) { diff --git content/renderer/render_thread_impl.cc content/renderer/render_thread_impl.cc index f2d4f932341e..409eabcdabc3 100644 --- content/renderer/render_thread_impl.cc +++ content/renderer/render_thread_impl.cc @@ -786,6 +786,8 @@ void RenderThreadImpl::Init() { StartServiceManagerConnection(); + GetContentClient()->renderer()->RenderThreadConnected(); + GetAssociatedInterfaceRegistry()->AddInterface(base::BindRepeating( &RenderThreadImpl::OnRendererInterfaceRequest, base::Unretained(this))); diff --git content/renderer/renderer_blink_platform_impl.cc content/renderer/renderer_blink_platform_impl.cc index a89a61d35a4b..5d8369cc2eda 100644 --- content/renderer/renderer_blink_platform_impl.cc +++ content/renderer/renderer_blink_platform_impl.cc @@ -949,6 +949,15 @@ RendererBlinkPlatformImpl::GetGpuFactories() { //------------------------------------------------------------------------------ +void RendererBlinkPlatformImpl::DevToolsAgentAttached() { + GetContentClient()->renderer()->DevToolsAgentAttached(); +} +void RendererBlinkPlatformImpl::DevToolsAgentDetached() { + GetContentClient()->renderer()->DevToolsAgentDetached(); +} + +//------------------------------------------------------------------------------ + blink::mojom::CodeCacheHost& RendererBlinkPlatformImpl::GetCodeCacheHost() { if (!code_cache_host_) { code_cache_host_ = blink::mojom::ThreadSafeCodeCacheHostPtr::Create( diff --git content/renderer/renderer_blink_platform_impl.h content/renderer/renderer_blink_platform_impl.h index f1bc21b53606..0706ff050349 100644 --- content/renderer/renderer_blink_platform_impl.h +++ content/renderer/renderer_blink_platform_impl.h @@ -211,6 +211,9 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { media::GpuVideoAcceleratorFactories* GetGpuFactories() override; + void DevToolsAgentAttached() override; + void DevToolsAgentDetached() override; + // Returns non-null. // It is invalid to call this in an incomplete env where // RenderThreadImpl::current() returns nullptr (e.g. in some tests). diff --git content/shell/browser/shell_plugin_service_filter.cc content/shell/browser/shell_plugin_service_filter.cc index 3a48c59b7e3e..d10ef64adbba 100644 --- content/shell/browser/shell_plugin_service_filter.cc +++ content/shell/browser/shell_plugin_service_filter.cc @@ -18,6 +18,7 @@ bool ShellPluginServiceFilter::IsPluginAvailable( int render_frame_id, const void* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, WebPluginInfo* plugin) { return plugin->name == base::ASCIIToUTF16("Blink Test Plugin") || diff --git content/shell/browser/shell_plugin_service_filter.h content/shell/browser/shell_plugin_service_filter.h index 7767a620a9fd..8a95377f5f3b 100644 --- content/shell/browser/shell_plugin_service_filter.h +++ content/shell/browser/shell_plugin_service_filter.h @@ -21,6 +21,7 @@ class ShellPluginServiceFilter : public PluginServiceFilter { int render_frame_id, const void* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, WebPluginInfo* plugin) override; diff --git content/test/fake_plugin_service.cc content/test/fake_plugin_service.cc index 6500af1d859f..0d078a4a4281 100644 --- content/test/fake_plugin_service.cc +++ content/test/fake_plugin_service.cc @@ -29,6 +29,7 @@ bool FakePluginService::GetPluginInfo(int render_process_id, int render_frame_id, ResourceContext* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard, diff --git content/test/fake_plugin_service.h content/test/fake_plugin_service.h index 205dfc39dfa7..ec250828b0ba 100644 --- content/test/fake_plugin_service.h +++ content/test/fake_plugin_service.h @@ -30,6 +30,7 @@ class FakePluginService : public PluginService { int render_frame_id, ResourceContext* context, const GURL& url, + bool is_main_frame, const url::Origin& main_frame_origin, const std::string& mime_type, bool allow_wildcard,