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

@ -13,13 +13,13 @@
#include "atom/common/options_switches.h"
#include "atom/renderer/atom_autofill_agent.h"
#include "atom/renderer/atom_render_frame_observer.h"
#include "atom/renderer/atom_render_view_observer.h"
#include "atom/renderer/content_settings_observer.h"
#include "atom/renderer/electron_api_service_impl.h"
#include "atom/renderer/preferences_manager.h"
#include "base/command_line.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
#include "content/common/buildflags.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_switches.h"
#include "content/public/renderer/render_frame.h"
@ -142,6 +142,15 @@ void RendererClientBase::AddRenderBindings(
void RendererClientBase::RenderThreadStarted() {
auto* command_line = base::CommandLine::ForCurrentProcess();
#if BUILDFLAG(USE_EXTERNAL_POPUP_MENU)
// On macOS, popup menus are rendered by the main process by default.
// This causes problems in OSR, since when the popup is rendered separately,
// it won't be captured in the rendered image.
if (command_line->HasSwitch(options::kOffscreen)) {
blink::WebView::SetUseExternalPopupMenus(false);
}
#endif
blink::WebCustomElement::AddEmbedderCustomElementName("webview");
blink::WebCustomElement::AddEmbedderCustomElementName("browserplugin");
@ -252,10 +261,6 @@ void RendererClientBase::RenderFrameCreated(
}
}
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
new AtomRenderViewObserver(render_view);
}
void RendererClientBase::DidClearWindowObject(
content::RenderFrame* render_frame) {
// Make sure every page will get a script context created.