Renderer preferences changes should propagate to OOPIFs
Per suggestion in discussion in https://crbug.com/983683, the method
SyncRendererPrefs() now calls WebContentsImpl::SendPageMessage to
broadcast renderer preferences changes, going through
RenderFrameHostManager to send the IPC to all processes involved in a
page (via RenderFrameProxyHosts in the main frame). SyncRendererPrefs
was also moved to from RenderViewHostImpl to WebContentsImpl where
it more logically belongs. New test coverage is added
(WebContentsImplBrowserTest.SyncRendererPrefs), which fails without
the fix in this change because the SetRendererPrefs IPC is never
sent from the render process hosts associated with subframes.
Bug: 983683
Change-Id: I70ad24b5f7a8537edfbe40db239522f13f5388b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1857398
Reviewed-by: Ken Buchanan <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Giovanni Ortuño Urquidi <[email protected]>
Commit-Queue: Bruce Long <[email protected]>
Cr-Commit-Position: refs/heads/master@{#706530}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 45ba11b..04d7825 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1286,10 +1286,8 @@
renderer_preferences_.user_agent_override = override;
- // Send the new override string to the renderer.
- RenderViewHost* host = GetRenderViewHost();
- if (host)
- host->SyncRendererPrefs();
+ // Send the new override string to all renderers in the current page.
+ SyncRendererPrefs();
// Reload the page if a load is currently in progress to avoid having
// different parts of the page loaded using different user agents.
@@ -2022,6 +2020,14 @@
render_view_host->OnWebkitPreferencesChanged();
}
+void WebContentsImpl::SyncRendererPrefs() {
+ blink::mojom::RendererPreferences renderer_preferences =
+ GetRendererPrefs(GetBrowserContext());
+ RenderViewHostImpl::GetPlatformSpecificPrefs(&renderer_preferences);
+ SendPageMessage(
+ new PageMsg_SetRendererPrefs(MSG_ROUTING_NONE, renderer_preferences));
+}
+
void WebContentsImpl::OnCookiesRead(const GURL& url,
const GURL& first_party_url,
const net::CookieList& cookie_list,