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,
}
#endif
#if defined(ENABLE_EXTENSIONS)
bool IsStandaloneExtensionProcess() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
extensions::switches::kExtensionProcess);
}
#endif
} // namespace
ChromeContentRendererClient::ChromeContentRendererClient() {
......@@ -1206,7 +1212,7 @@ void ChromeContentRendererClient::GetNavigationErrorStrings(
bool ChromeContentRendererClient::RunIdleHandlerWhenWidgetsHidden() {
#if defined(ENABLE_EXTENSIONS)
return !extension_dispatcher_->is_extension_process();
return !IsStandaloneExtensionProcess();
#else
return true;
#endif
......@@ -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
// uninstalled.
if (frame->top()->document().url() == url) {
if (is_extension_url != extension_dispatcher_->is_extension_process())
if (is_extension_url != IsStandaloneExtensionProcess())
return true;
}
#endif // defined(ENABLE_EXTENSIONS)
......@@ -1445,7 +1451,7 @@ bool ChromeContentRendererClient::CrossesExtensionExtents(
opener_document.url()) != NULL;
if (!is_extension_url &&
!opener_is_extension_url &&
extension_dispatcher_->is_extension_process() &&
IsStandaloneExtensionProcess() &&
opener.canRequest(WebURL(new_url)))
return false;
......
......@@ -194,11 +194,11 @@ Dispatcher::Dispatcher(DispatcherDelegate* delegate)
webrequest_used_(false) {
const base::CommandLine& command_line =
*(base::CommandLine::ForCurrentProcess());
is_extension_process_ =
set_idle_notifications_ =
command_line.HasSwitch(switches::kExtensionProcess) ||
command_line.HasSwitch(::switches::kSingleProcess);
if (is_extension_process_) {
if (set_idle_notifications_) {
RenderThread::Get()->SetIdleNotificationDelayInMs(
kInitialExtensionIdleHandlerDelayMs);
}
......@@ -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
// dispatch, for which Invoke is the chokepoint.
if (is_extension_process_) {
if (set_idle_notifications_) {
RenderThread::Get()->ScheduleIdleHandler(
kInitialExtensionIdleHandlerDelayMs);
}
......@@ -830,7 +830,7 @@ bool Dispatcher::OnControlMessageReceived(const IPC::Message& message) {
void Dispatcher::WebKitInitialized() {
// For extensions, we want to ensure we call the IdleHandler every so often,
// 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_->Start(
FROM_HERE,
......@@ -856,7 +856,7 @@ void Dispatcher::WebKitInitialized() {
}
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
// periods of time. (forced_idle_timer_ can be NULL after
// OnRenderProcessShutdown has been called.)
......
......@@ -72,8 +72,6 @@ class Dispatcher : public content::RenderProcessObserver,
return function_names_;
}
bool is_extension_process() const { return is_extension_process_; }
const ExtensionSet* extensions() const { return &extensions_; }
const ScriptContextSet& script_context_set() const {
......@@ -267,8 +265,8 @@ class Dispatcher : public content::RenderProcessObserver,
// Dispatcher's own lifetime.
DispatcherDelegate* delegate_;
// True if this renderer is running extensions.
bool is_extension_process_;
// True if the IdleNotification timer should be set.
bool set_idle_notifications_;
// Contains all loaded extensions. This is essentially the renderer
// 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