refactor: turn OnOffscreen message into a command-line flag (#17687)

This turns the AtomViewMsg_Offscreen message, which only called the global setter blink::WebView::SetUseExternalPopupMenus(false) to get Chrome to render popup menus in the renderer instead of externally on macOS, into a command-line renderer flag --offscreen which does the same thing, except at render thread startup time, which is where Chromium sets the flag: https://chromium.googlesource.com/chromium/src/+/refs/tags/75.0.3755.3/content/renderer/render_thread_impl.cc#728.

This was the last usage of RenderViewObserver in our codebase, so this PR also removes that class.
This commit is contained in:
Jeremy Apthorp 2019-04-19 12:55:20 -07:00 committed by Shelley Vohr
parent 1249c6ebf4
commit ab009bba26
9 changed files with 32 additions and 83 deletions

View file

@ -147,6 +147,23 @@ WebContentsPreferences::WebContentsPreferences(
#endif
SetDefaultBoolIfUndefined(options::kOffscreen, false);
// If this is a <webview> tag, and the embedder is offscreen-rendered, then
// this WebContents is also offscreen-rendered.
int guest_instance_id = 0;
if (web_preferences.Get(options::kGuestInstanceID, &guest_instance_id)) {
auto* manager = WebViewManager::GetWebViewManager(web_contents);
if (manager) {
auto* embedder = manager->GetEmbedder(guest_instance_id);
if (embedder) {
auto* embedder_preferences = WebContentsPreferences::From(embedder);
if (embedder_preferences &&
embedder_preferences->IsEnabled(options::kOffscreen)) {
preference_.SetKey(options::kOffscreen, base::Value(true));
}
}
}
}
last_preference_ = preference_.Clone();
}
@ -309,6 +326,11 @@ void WebContentsPreferences::AppendCommandLineSwitches(
command_line->AppendSwitchASCII(switches::kBackgroundColor, "#fff");
}
// --offscreen
if (IsEnabled(options::kOffscreen)) {
command_line->AppendSwitch(options::kOffscreen);
}
// --guest-instance-id, which is used to identify guest WebContents.
int guest_instance_id = 0;
if (GetAsInteger(&preference_, options::kGuestInstanceID, &guest_instance_id))