Commit 874b1b97 authored by joaoe's avatar joaoe Committed by Commit bot

ChromeContentRendererClient should not rely on Dispatcher::is_extension_process

The extensions::Dispatcher::is_extension_process flag is set for both the
standalone extensions renderer and single process mode. This caused
ChromeContentRendererClient to act differently in single process mode, like
returning true from ShouldFork for any navigation started by blink, which
would cause a new WebView to be created for each navigation.

BUG=462210

Review URL: https://codereview.chromium.org/956313002

Cr-Commit-Position: refs/heads/master@{#318938}
parent b903612e
...@@ -328,6 +328,12 @@ GURL GetPluginInstancePosterImage(const blink::WebPluginParams& params, ...@@ -328,6 +328,12 @@ GURL GetPluginInstancePosterImage(const blink::WebPluginParams& params,
} }
#endif #endif
#if defined(ENABLE_EXTENSIONS)
bool IsStandaloneExtensionProcess() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
extensions::switches::kExtensionProcess);
}
#endif
} // namespace } // namespace
ChromeContentRendererClient::ChromeContentRendererClient() { ChromeContentRendererClient::ChromeContentRendererClient() {
...@@ -1206,7 +1212,7 @@ void ChromeContentRendererClient::GetNavigationErrorStrings( ...@@ -1206,7 +1212,7 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() { bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
return !extension_dispatcher_->is_extension_process(); return !IsStandaloneExtensionProcess();
#else #else
return true; return true;
#endif #endif
...@@ -1321,7 +1327,7 @@ bool ChromeContentRendererClient::ShouldFork(WebFrame* frame, ...@@ -1321,7 +1327,7 @@ bool ChromeContentRendererClient::ShouldFork(WebFrame* frame,
// in a normal process, or if it's a process for an extension that has been // in a normal process, or if it's a process for an extension that has been
// uninstalled. // uninstalled.
if (frame->top()->document().url() == url) { if (frame->top()->document().url() == url) {
if (is_extension_url != extension_dispatcher_->is_extension_process()) if (is_extension_url != IsStandaloneExtensionProcess())
return true; return true;
} }
#endif // defined(ENABLE_EXTENSIONS) #endif // defined(ENABLE_EXTENSIONS)
...@@ -1445,7 +1451,7 @@ bool ChromeContentRendererClient::CrossesExtensionExtents( ...@@ -1445,7 +1451,7 @@ bool ChromeContentRendererClient::CrossesExtensionExtents(
opener_document.url()) != NULL; opener_document.url()) != NULL;
if (!is_extension_url && if (!is_extension_url &&
!opener_is_extension_url && !opener_is_extension_url &&
extension_dispatcher_->is_extension_process() && IsStandaloneExtensionProcess() &&
opener.canRequest(WebURL(new_url))) opener.canRequest(WebURL(new_url)))
return false; return false;
......
...@@ -194,11 +194,11 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate) ...@@ -194,11 +194,11 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
webrequest_used_(false) { webrequest_used_(false) {
const base::CommandLine& command_line = const base::CommandLine& command_line =
*(base::CommandLine::ForCurrentProcess()); *(base::CommandLine::ForCurrentProcess());
is_extension_process_ = set_idle_notifications_ =
command_line.HasSwitch(switches::kExtensionProcess) || command_line.HasSwitch(switches::kExtensionProcess) ||
command_line.HasSwitch(::switches::kSingleProcess); command_line.HasSwitch(::switches::kSingleProcess);
if (is_extension_process_) { if (set_idle_notifications_) {
RenderThread::Get()->SetIdleNotificationDelayInMs( RenderThread::Get()->SetIdleNotificationDelayInMs(
kInitialExtensionIdleHandlerDelayMs); kInitialExtensionIdleHandlerDelayMs);
} }
...@@ -528,7 +528,7 @@ void Dispatcher::InvokeModuleSystemMethod(content::RenderView* render_view, ...@@ -528,7 +528,7 @@ void Dispatcher::InvokeModuleSystemMethod(content::RenderView* render_view,
// Reset the idle handler each time there's any activity like event or message // Reset the idle handler each time there's any activity like event or message
// dispatch, for which Invoke is the chokepoint. // dispatch, for which Invoke is the chokepoint.
if (is_extension_process_) { if (set_idle_notifications_) {
RenderThread::Get()->ScheduleIdleHandler( RenderThread::Get()->ScheduleIdleHandler(
kInitialExtensionIdleHandlerDelayMs); kInitialExtensionIdleHandlerDelayMs);
} }
...@@ -830,7 +830,7 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) { ...@@ -830,7 +830,7 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
void Dispatcher::WebKitInitialized() { void Dispatcher::WebKitInitialized() {
// For extensions, we want to ensure we call the IdleHandler every so often, // For extensions, we want to ensure we call the IdleHandler every so often,
// even if the extension keeps up activity. // even if the extension keeps up activity.
if (is_extension_process_) { if (set_idle_notifications_) {
forced_idle_timer_.reset(new base::RepeatingTimer<content::RenderThread>); forced_idle_timer_.reset(new base::RepeatingTimer<content::RenderThread>);
forced_idle_timer_->Start( forced_idle_timer_->Start(
FROM_HERE, FROM_HERE,
...@@ -856,7 +856,7 @@ void Dispatcher::WebKitInitialized() { ...@@ -856,7 +856,7 @@ void Dispatcher::WebKitInitialized() {
} }
void Dispatcher::IdleNotification() { void Dispatcher::IdleNotification() {
if (is_extension_process_ && forced_idle_timer_) { if (set_idle_notifications_ && forced_idle_timer_) {
// Dampen the forced delay as well if the extension stays idle for long // Dampen the forced delay as well if the extension stays idle for long
// periods of time. (forced_idle_timer_ can be NULL after // periods of time. (forced_idle_timer_ can be NULL after
// OnRenderProcessShutdown has been called.) // OnRenderProcessShutdown has been called.)
......
...@@ -72,8 +72,6 @@ class Dispatcher : public content::RenderProcessObserver, ...@@ -72,8 +72,6 @@ class Dispatcher : public content::RenderProcessObserver,
return function_names_; return function_names_;
} }
bool is_extension_process() const { return is_extension_process_; }
const ExtensionSet* extensions() const { return &extensions_; } const ExtensionSet* extensions() const { return &extensions_; }
const ScriptContextSet& script_context_set() const { const ScriptContextSet& script_context_set() const {
...@@ -267,8 +265,8 @@ class Dispatcher : public content::RenderProcessObserver, ...@@ -267,8 +265,8 @@ class Dispatcher : public content::RenderProcessObserver,
// Dispatcher's own lifetime. // Dispatcher's own lifetime.
DispatcherDelegate* delegate_; DispatcherDelegate* delegate_;
// True if this renderer is running extensions. // True if the IdleNotification timer should be set.
bool is_extension_process_; bool set_idle_notifications_;
// Contains all loaded extensions. This is essentially the renderer // Contains all loaded extensions. This is essentially the renderer
// counterpart to ExtensionService in the browser. It contains information // counterpart to ExtensionService in the browser. It contains information
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment