summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 01:06:19 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 01:06:19 +0000
commit16095bf0140c955960f2a4a99cc344d2b519b064 (patch)
tree2f78023b02e97174b4d05895c6256212e160ed57 /content
parentf0b739902f5235c47637c3ef3a0554189c7e7fbc (diff)
downloadchromium_src-16095bf0140c955960f2a4a99cc344d2b519b064.zip
chromium_src-16095bf0140c955960f2a4a99cc344d2b519b064.tar.gz
chromium_src-16095bf0140c955960f2a4a99cc344d2b519b064.tar.bz2
Revert "Re-land r84928: Move ExtensionFunctionDispatcher to"
Breaks installation on webstore. This reverts commit 73ad030f2c57a444b81351b2a1cd8546a6dbddc8. TBR=mpcomplete@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/content_browser_client.cc5
-rw-r--r--content/browser/content_browser_client.h7
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc29
-rw-r--r--content/browser/renderer_host/browser_render_process_host.h8
-rw-r--r--content/browser/renderer_host/mock_render_process_host.cc5
-rw-r--r--content/browser/renderer_host/mock_render_process_host.h2
-rw-r--r--content/browser/renderer_host/render_process_host.cc1
-rw-r--r--content/browser/renderer_host/render_process_host.h10
-rw-r--r--content/browser/renderer_host/render_view_host.cc12
-rw-r--r--content/browser/renderer_host/render_view_host.h10
-rw-r--r--content/browser/tab_contents/render_view_host_manager.cc5
-rw-r--r--content/common/notification_type.h16
12 files changed, 68 insertions, 42 deletions
diff --git a/content/browser/content_browser_client.cc b/content/browser/content_browser_client.cc
index 901097e..84603af 100644
--- a/content/browser/content_browser_client.cc
+++ b/content/browser/content_browser_client.cc
@@ -14,6 +14,11 @@ void ContentBrowserClient::RenderViewHostCreated(
RenderViewHost* render_view_host) {
}
+void ContentBrowserClient::PreCreateRenderView(RenderViewHost* render_view_host,
+ Profile* profile,
+ const GURL& url) {
+}
+
void ContentBrowserClient::BrowserRenderProcessHostCreated(
BrowserRenderProcessHost* host) {
}
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h
index 82c5d2c..2de7751 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -34,7 +34,12 @@ class ContentBrowserClient {
// Notifies that a new RenderHostView has been created.
virtual void RenderViewHostCreated(RenderViewHost* render_view_host);
- // Notifies that a BrowserRenderProcessHost has been created. This is called
+ // Initialize a RenderViewHost before its CreateRenderView method is called.
+ virtual void PreCreateRenderView(RenderViewHost* render_view_host,
+ Profile* profile,
+ const GURL& url);
+
+ // Notifies that a BrowserRenderProcessHost has been created. This is called
// before the content layer adds its own BrowserMessageFilters, so that the
// embedder's IPC filters have priority.
virtual void BrowserRenderProcessHostCreated(BrowserRenderProcessHost* host);
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index 4868e89..aa5808f 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -192,7 +192,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)),
accessibility_enabled_(false),
- is_initialized_(false) {
+ extension_process_(false) {
widget_helper_ = new RenderWidgetHelper();
WebCacheManager::GetInstance()->Add(id());
@@ -239,7 +239,8 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
ClearTransportDIBCache();
}
-bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) {
+bool BrowserRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
// calling Init() more than once does nothing, this makes it more convenient
// for the view host which may not be sure in some cases
if (channel_.get())
@@ -247,6 +248,10 @@ bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) {
accessibility_enabled_ = is_accessibility_enabled;
+ // It is possible for an extension process to be reused for non-extension
+ // content, e.g. if an extension calls window.open.
+ extension_process_ = extension_process_ || is_extensions_process;
+
CommandLine::StringType renderer_prefix;
#if defined(OS_POSIX)
// A command prefix is something prepended to the command line of the spawned
@@ -327,7 +332,6 @@ bool BrowserRenderProcessHost::Init(bool is_accessibility_enabled) {
fast_shutdown_started_ = false;
}
- is_initialized_ = true;
return true;
}
@@ -466,8 +470,8 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
// Extensions use a special pseudo-process type to make them distinguishable,
// even though they're just renderers.
command_line->AppendSwitchASCII(switches::kProcessType,
- is_extension_process_ ? switches::kExtensionProcess :
- switches::kRendererProcess);
+ extension_process_ ? switches::kExtensionProcess :
+ switches::kRendererProcess);
if (logging::DialogsAreSuppressed())
command_line->AppendSwitch(switches::kNoErrorDialogs);
@@ -758,13 +762,8 @@ void BrowserRenderProcessHost::ClearTransportDIBCache() {
bool BrowserRenderProcessHost::Send(IPC::Message* msg) {
if (!channel_.get()) {
- if (!is_initialized_) {
- queued_messages_.push(msg);
- return true;
- } else {
- delete msg;
- return false;
- }
+ delete msg;
+ return false;
}
if (child_process_launcher_.get() && child_process_launcher_->IsStarting()) {
@@ -853,15 +852,15 @@ void BrowserRenderProcessHost::OnChannelError() {
if (status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes",
- is_extension_process_ ? 2 : 1);
+ extension_process_ ? 2 : 1);
}
if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills",
- is_extension_process_ ? 2 : 1);
+ extension_process_ ? 2 : 1);
}
- RendererClosedDetails details(status, exit_code, is_extension_process_);
+ RendererClosedDetails details(status, exit_code, extension_process_);
NotificationService::current()->Notify(
NotificationType::RENDERER_PROCESS_CLOSED,
Source<RenderProcessHost>(this),
diff --git a/content/browser/renderer_host/browser_render_process_host.h b/content/browser/renderer_host/browser_render_process_host.h
index fb46c82..3f7a23c 100644
--- a/content/browser/renderer_host/browser_render_process_host.h
+++ b/content/browser/renderer_host/browser_render_process_host.h
@@ -47,7 +47,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
~BrowserRenderProcessHost();
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_accessibility_enabled);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
@@ -131,9 +131,9 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// True if this prcoess should have accessibility enabled;
bool accessibility_enabled_;
- // True after Init() has been called. We can't just check channel_ because we
- // also reset that in the case of process termination.
- bool is_initialized_;
+ // True iff this process is being used as an extension process. Not valid
+ // when running in single-process mode.
+ bool extension_process_;
// Used to launch and terminate the process without blocking the UI thread.
scoped_ptr<ChildProcessLauncher> child_process_launcher_;
diff --git a/content/browser/renderer_host/mock_render_process_host.cc b/content/browser/renderer_host/mock_render_process_host.cc
index dec107a..104395f 100644
--- a/content/browser/renderer_host/mock_render_process_host.cc
+++ b/content/browser/renderer_host/mock_render_process_host.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -23,7 +23,8 @@ MockRenderProcessHost::~MockRenderProcessHost() {
factory_->Remove(this);
}
-bool MockRenderProcessHost::Init(bool is_accessibility_enabled) {
+bool MockRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
return true;
}
diff --git a/content/browser/renderer_host/mock_render_process_host.h b/content/browser/renderer_host/mock_render_process_host.h
index a6804a1..0e7656c 100644
--- a/content/browser/renderer_host/mock_render_process_host.h
+++ b/content/browser/renderer_host/mock_render_process_host.h
@@ -36,7 +36,7 @@ class MockRenderProcessHost : public RenderProcessHost {
int bad_msg_count() const { return bad_msg_count_; }
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_accessibility_enabled);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
diff --git a/content/browser/renderer_host/render_process_host.cc b/content/browser/renderer_host/render_process_host.cc
index 5466004..379ce99 100644
--- a/content/browser/renderer_host/render_process_host.cc
+++ b/content/browser/renderer_host/render_process_host.cc
@@ -94,7 +94,6 @@ RenderProcessHost::RenderProcessHost(Profile* profile)
: max_page_id_(-1),
fast_shutdown_started_(false),
deleting_soon_(false),
- is_extension_process_(false),
pending_views_(0),
id_(ChildProcessInfo::GenerateChildProcessUniqueId()),
profile_(profile),
diff --git a/content/browser/renderer_host/render_process_host.h b/content/browser/renderer_host/render_process_host.h
index 9d3b8fc..b43fbe2 100644
--- a/content/browser/renderer_host/render_process_host.h
+++ b/content/browser/renderer_host/render_process_host.h
@@ -88,9 +88,6 @@ class RenderProcessHost : public IPC::Channel::Sender,
sudden_termination_allowed_ = enabled;
}
- bool is_extension_process() const { return is_extension_process_; }
- void mark_is_extension_process() { is_extension_process_ = true; }
-
// Used for refcounting, each holder of this object must Attach and Release
// just like it would for a COM object. This object should be allocated on
// the heap; when no listeners own it any more, it will delete itself.
@@ -166,7 +163,8 @@ class RenderProcessHost : public IPC::Channel::Sender,
// be called once before the object can be used, but can be called after
// that with no effect. Therefore, if the caller isn't sure about whether
// the process has been created, it should just call Init().
- virtual bool Init(bool is_accessibility_enabled) = 0;
+ virtual bool Init(
+ bool is_accessibility_enabled, bool is_extensions_process) = 0;
// Gets the next available routing id.
virtual int GetNextRoutingID() = 0;
@@ -284,10 +282,6 @@ class RenderProcessHost : public IPC::Channel::Sender,
// True if we've posted a DeleteTask and will be deleted soon.
bool deleting_soon_;
- // True iff this process is being used as an extension process. Not valid
- // when running in single-process mode.
- bool is_extension_process_;
-
// The count of currently swapped out but pending RenderViews. We have
// started to swap these in, so the renderer process should not exit if
// this count is non-zero.
diff --git a/content/browser/renderer_host/render_view_host.cc b/content/browser/renderer_host/render_view_host.cc
index c74ac5e..47e5457 100644
--- a/content/browser/renderer_host/render_view_host.cc
+++ b/content/browser/renderer_host/render_view_host.cc
@@ -102,6 +102,7 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
are_javascript_messages_suppressed_(false),
sudden_termination_allowed_(false),
session_storage_namespace_(session_storage),
+ is_extension_process_(false),
save_accessibility_tree_for_testing_(false),
render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING) {
if (!session_storage_namespace_) {
@@ -113,11 +114,6 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
DCHECK(delegate_);
content::GetContentClient()->browser()->RenderViewHostCreated(this);
-
- NotificationService::current()->Notify(
- NotificationType::RENDER_VIEW_HOST_CREATED,
- Source<RenderViewHost>(this),
- NotificationService::NoDetails());
}
RenderViewHost::~RenderViewHost() {
@@ -143,7 +139,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) {
// initialized it) or may not (we have our own process or the old process
// crashed) have been initialized. Calling Init multiple times will be
// ignored, so this is safe.
- if (!process()->Init(renderer_accessible()))
+ if (!process()->Init(renderer_accessible(), is_extension_process_))
return false;
DCHECK(process()->HasConnection());
DCHECK(process()->profile());
@@ -156,6 +152,10 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) {
if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings(
process()->id());
+
+ // Extensions may have permission to access chrome:// URLs.
+ ChildProcessSecurityPolicy::GetInstance()->GrantScheme(
+ process()->id(), chrome::kChromeUIScheme);
}
renderer_initialized_ = true;
diff --git a/content/browser/renderer_host/render_view_host.h b/content/browser/renderer_host/render_view_host.h
index b29f2ed..bfd7bf85 100644
--- a/content/browser/renderer_host/render_view_host.h
+++ b/content/browser/renderer_host/render_view_host.h
@@ -314,6 +314,12 @@ class RenderViewHost : public RenderWidgetHost {
// RenderView. See BindingsPolicy for details.
int enabled_bindings() const { return enabled_bindings_; }
+ // See variable comment.
+ bool is_extension_process() const { return is_extension_process_; }
+ void set_is_extension_process(bool is_extension_process) {
+ is_extension_process_ = is_extension_process;
+ }
+
// Sets a property with the given name and value on the Web UI binding object.
// Must call AllowWebUIBindings() on this renderer first.
void SetWebUIProperty(const std::string& name, const std::string& value);
@@ -593,6 +599,10 @@ class RenderViewHost : public RenderWidgetHost {
// The session storage namespace to be used by the associated render view.
scoped_refptr<SessionStorageNamespace> session_storage_namespace_;
+ // Whether this render view will get extension api bindings. This controls
+ // what process type we use.
+ bool is_extension_process_;
+
// Whether the accessibility tree should be saved, for unit testing.
bool save_accessibility_tree_for_testing_;
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index 442e91c8..22ae236 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -506,6 +506,11 @@ bool RenderViewHostManager::InitRenderView(RenderViewHost* render_view_host,
if (pending_web_ui_.get())
render_view_host->AllowBindings(pending_web_ui_->bindings());
+ // Give the embedder a chance to initialize the render view.
+ Profile* profile = delegate_->GetControllerForRenderManager().profile();
+ content::GetContentClient()->browser()->PreCreateRenderView(
+ render_view_host, profile, entry.url());
+
return delegate_->CreateRenderViewForRenderManager(render_view_host);
}
diff --git a/content/common/notification_type.h b/content/common/notification_type.h
index c7e4d6a..850b887 100644
--- a/content/common/notification_type.h
+++ b/content/common/notification_type.h
@@ -459,10 +459,6 @@ class NotificationType {
// Used only in testing.
RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK,
- // Sent from RenderViewHost constructor. The source is the RenderViewHost,
- // the details unused.
- RENDER_VIEW_HOST_CREATED,
-
// Sent from ~RenderViewHost. The source is the RenderViewHost, the details
// unused.
RENDER_VIEW_HOST_DELETED,
@@ -869,6 +865,18 @@ class NotificationType {
// Extension, and the source is a Profile.
EXTENSION_USER_SCRIPTS_UPDATED,
+ // Sent after a new ExtensionFunctionDispatcher is created. The details are
+ // an ExtensionFunctionDispatcher* and the source is a Profile*. This is
+ // similar in timing to EXTENSION_HOST_CREATED, but also fires when an
+ // extension view which is hosted in TabContents* is created.
+ EXTENSION_FUNCTION_DISPATCHER_CREATED,
+
+ // Sent before an ExtensionHost is destroyed. The details are
+ // an ExtensionFunctionDispatcher* and the source is a Profile*. This is
+ // similar in timing to EXTENSION_HOST_DESTROYED, but also fires when an
+ // extension view which is hosted in TabContents* is destroyed.
+ EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
+
// Sent after a new ExtensionHost is created. The details are
// an ExtensionHost* and the source is an ExtensionProcessManager*.
EXTENSION_HOST_CREATED,