diff options
author | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 19:35:09 +0000 |
---|---|---|
committer | mpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-27 19:35:09 +0000 |
commit | 81e6378c98d0e69339302527eb1de4735d1e2c3f (patch) | |
tree | d8020f1a2a842b0735c22a35e89a97ec7630bf17 /chrome/browser/renderer_host | |
parent | 4c8c60ee58cf2f22fcdc0cf3b30f1f5e8884f0ff (diff) | |
download | chromium_src-81e6378c98d0e69339302527eb1de4735d1e2c3f.zip chromium_src-81e6378c98d0e69339302527eb1de4735d1e2c3f.tar.gz chromium_src-81e6378c98d0e69339302527eb1de4735d1e2c3f.tar.bz2 |
Prototype extension process. This is a proof of concept, with a lot of
rough edges. Mostly this just fires up a renderer with an "extension" object
exposed, which right now only has a single method "getTestString".
I also did some misc cleanup along the way.
Review URL: http://codereview.chromium.org/27187
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10620 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.cc | 25 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_view_host.h | 16 |
2 files changed, 24 insertions, 17 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 894e02a..3da3fef 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -24,6 +24,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/tab_contents/web_contents.h" +#include "chrome/common/bindings_policy.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/notification_service.h" @@ -88,9 +89,8 @@ RenderViewHost::RenderViewHost(SiteInstance* instance, renderer_initialized_(false), waiting_for_drag_context_response_(false), debugger_attached_(false), - enable_dom_ui_bindings_(false), + enabled_bindings_(0), pending_request_id_(0), - enable_external_host_bindings_(false), modal_dialog_count_(0), navigations_suspended_(false), suspended_nav_message_(NULL), @@ -178,8 +178,7 @@ bool RenderViewHost::CreateRenderView() { // If it's enabled, tell the renderer to set up the Javascript bindings for // sending messages back to the browser. - Send(new ViewMsg_AllowBindings( - routing_id(), enable_dom_ui_bindings_, enable_external_host_bindings_)); + Send(new ViewMsg_AllowBindings(routing_id(), enabled_bindings_)); // Let our delegate know that we created a RenderView. delegate_->RenderViewCreated(this); @@ -574,24 +573,30 @@ void RenderViewHost::DragSourceSystemDragEnded() { } void RenderViewHost::AllowDomAutomationBindings() { - // Expose the binding that allows the DOM to send messages here. - Send(new ViewMsg_AllowDomAutomationBindings(routing_id(), true)); + DCHECK(!renderer_initialized_); + enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; +} + +void RenderViewHost::AllowExternalHostBindings() { + DCHECK(!renderer_initialized_); + enabled_bindings_ |= BindingsPolicy::EXTERNAL_HOST; } void RenderViewHost::AllowDOMUIBindings() { DCHECK(!renderer_initialized_); - enable_dom_ui_bindings_ = true; + enabled_bindings_ |= BindingsPolicy::DOM_UI; RendererSecurityPolicy::GetInstance()->GrantDOMUIBindings( process()->host_id()); } -void RenderViewHost::AllowExternalHostBindings() { - enable_external_host_bindings_ = true; +void RenderViewHost::AllowExtensionBindings() { + DCHECK(!renderer_initialized_); + enabled_bindings_ |= BindingsPolicy::EXTENSION; } void RenderViewHost::SetDOMUIProperty(const std::string& name, const std::string& value) { - DCHECK(enable_dom_ui_bindings_); + DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)); Send(new ViewMsg_SetDOMUIProperty(routing_id(), name, value)); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 7a0a8148..79c9ca6 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -308,10 +308,12 @@ class RenderViewHost : public RenderWidgetHost { // Tell the render view to expose DOM automation bindings so that the js // content can send JSON-encoded data back to automation in the parent // process. + // Must be called before CreateRenderView(). void AllowDomAutomationBindings(); // Tell the render view to allow the javascript access to // the external host via automation. + // Must be called before CreateRenderView(). void AllowExternalHostBindings(); // Tell the render view to expose DOM bindings so that the JS content @@ -320,6 +322,10 @@ class RenderViewHost : public RenderWidgetHost { // Must be called before CreateRenderView(). void AllowDOMUIBindings(); + // Tell the render view to expose privileged bindings for use by extensions. + // Must be called before CreateRenderView(). + void AllowExtensionBindings(); + // Tells the renderer which render view should be inspected by developer // tools loaded in it. This method should be called before renderer is // created. @@ -574,9 +580,9 @@ class RenderViewHost : public RenderWidgetHost { // is the debugger attached to us or not bool debugger_attached_; - // True if we've been told to set up the the Javascript bindings for - // sending messages back to the browser. - bool enable_dom_ui_bindings_; + // A bitwise OR of bindings types that have been enabled for this RenderView. + // See BindingsPolicy for details. + int enabled_bindings_; // The request_id for the pending cross-site request. Set to -1 if // there is a pending request, but we have not yet started the unload @@ -585,10 +591,6 @@ class RenderViewHost : public RenderWidgetHost { // and thus started the unload process. int pending_request_id_; - // True if javascript access to the external host (through - // automation) is allowed. - bool enable_external_host_bindings_; - // Handle to an event that's set when the page is showing a modal dialog box // (or equivalent constrained window). The renderer and plugin processes // check this to know if they should pump messages/tasks then. |