summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 08:46:25 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-01 08:46:25 +0000
commit811bfe371c3518e58664fb5191a6962314f8f05f (patch)
tree6dc3cb4264f9d87c93a2313fa856c1ea7e6e23e8 /chrome/browser/renderer_host
parent20fdbc31d0e998ba81d8337259b43e57e2ff02b7 (diff)
downloadchromium_src-811bfe371c3518e58664fb5191a6962314f8f05f.zip
chromium_src-811bfe371c3518e58664fb5191a6962314f8f05f.tar.gz
chromium_src-811bfe371c3518e58664fb5191a6962314f8f05f.tar.bz2
In this episode, we implement the DOMUI interface for extension views that are rendered in the main tab contents area. This gets us loaded and unloaded at the right place and removes many special cases for extensions from the RenderViewHost and RenderViewHostDelegate hierarchy.
BUG=13936 Review URL: http://codereview.chromium.org/126137 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19717 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc44
-rw-r--r--chrome/browser/renderer_host/render_view_host.h31
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h16
-rw-r--r--chrome/browser/renderer_host/render_view_host_manager.cc9
4 files changed, 28 insertions, 72 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index d313178..8072eb2 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -42,7 +42,6 @@
#endif
using base::TimeDelta;
-using webkit_glue::AutofillForm;
using webkit_glue::PasswordFormDomManager;
using WebKit::WebConsoleMessage;
using WebKit::WebFindOptions;
@@ -570,24 +569,9 @@ void RenderViewHost::DragSourceSystemDragEnded() {
Send(new ViewMsg_DragSourceSystemDragEnded(routing_id()));
}
-void RenderViewHost::AllowDomAutomationBindings() {
+void RenderViewHost::AllowBindings(int bindings_flags) {
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_);
- enabled_bindings_ |= BindingsPolicy::DOM_UI;
-}
-
-void RenderViewHost::AllowExtensionBindings() {
- DCHECK(!renderer_initialized_);
- enabled_bindings_ |= BindingsPolicy::EXTENSION;
+ enabled_bindings_ |= bindings_flags;
}
void RenderViewHost::SetDOMUIProperty(const std::string& name,
@@ -889,15 +873,6 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
FilterURL(policy, renderer_id, &validated_params.password_form.origin);
FilterURL(policy, renderer_id, &validated_params.password_form.action);
- if (PageTransition::IsMainFrame(validated_params.transition)) {
- ExtensionFunctionDispatcher* new_efd = NULL;
- if (validated_params.url.SchemeIs(chrome::kExtensionScheme)) {
- new_efd = delegate()->CreateExtensionFunctionDispatcher(this,
- validated_params.url.host());
- }
- extension_function_dispatcher_.reset(new_efd);
- }
-
delegate_->DidNavigate(this, validated_params);
UpdateBackForwardListCount();
@@ -1077,7 +1052,14 @@ void RenderViewHost::OnMsgDOMUISend(
NOTREACHED() << "Blocked unauthorized use of DOMUIBindings.";
return;
}
- delegate_->ProcessDOMUIMessage(message, content);
+
+ // DOMUI doesn't use these values yet.
+ // TODO(aa): When DOMUI is ported to ExtensionFunctionDispatcher, send real
+ // values here.
+ const int kRequestId = -1;
+ const bool kHasCallback = false;
+
+ delegate_->ProcessDOMUIMessage(message, content, kRequestId, kHasCallback);
}
void RenderViewHost::OnMsgForwardMessageToExternalHost(
@@ -1161,7 +1143,7 @@ void RenderViewHost::OnMsgPasswordFormsSeen(
}
void RenderViewHost::OnMsgAutofillFormSubmitted(
- const AutofillForm& form) {
+ const webkit_glue::AutofillForm& form) {
delegate_->AutofillFormSubmitted(form);
}
@@ -1386,9 +1368,7 @@ void RenderViewHost::OnExtensionRequest(const std::string& name,
return;
}
- DCHECK(extension_function_dispatcher_.get());
- extension_function_dispatcher_->HandleRequest(name, args, request_id,
- has_callback);
+ delegate_->ProcessDOMUIMessage(name, args, request_id, has_callback);
}
void RenderViewHost::SendExtensionResponse(int request_id, bool success,
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index a30dbc2..b932e1c 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -92,9 +92,6 @@ class RenderViewHost : public RenderWidgetHost {
SiteInstance* site_instance() const { return instance_; }
RenderViewHostDelegate* delegate() const { return delegate_; }
- ExtensionFunctionDispatcher* extension_function_dispatcher() const {
- return extension_function_dispatcher_.get();
- }
// Set up the RenderView child process. Virtual because it is overridden by
// TestRenderViewHost.
@@ -306,26 +303,9 @@ class RenderViewHost : public RenderWidgetHost {
// This allows the renderer to reset some state.
void DragSourceSystemDragEnded();
- // 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
- // can send JSON-encoded data back to the browser process.
- // This is used for HTML-based UI.
- // 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();
+ // Tell the render view to enable a set of javascript bindings. The argument
+ // should be a combination of values from BindingsPolicy.
+ void AllowBindings(int binding_flags);
// Sets a property with the given name and value on the DOM UI binding object.
// Must call AllowDOMUIBindings() on this renderer first.
@@ -609,11 +589,6 @@ class RenderViewHost : public RenderWidgetHost {
bool are_javascript_messages_suppressed_;
- // Handles processing IPC messages request extension functions be executed.
- // This changes during navigation and may be NULL if the current content is
- // not an extension.
- scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
-
// True if the render view can be shut down suddenly.
bool sudden_termination_allowed_;
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index fd52627..09b34bc 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -19,9 +19,7 @@
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/window_open_disposition.h"
-#include "chrome/browser/extensions/extension_function_dispatcher.h"
-
-class ExtensionFunctionDispatcher;
+class AutofillForm;
class NavigationEntry;
class Profile;
class RenderProcessHost;
@@ -161,14 +159,6 @@ class RenderViewHostDelegate {
// Gets the URL that is currently being displayed, if there is one.
virtual const GURL& GetURL() const = 0;
- // Create a new browser window to be sized, shown and contents managed
- // by the caller.
- virtual ExtensionFunctionDispatcher *CreateExtensionFunctionDispatcher(
- RenderViewHost* render_view_host,
- const std::string& extension_id) {
- return NULL;
- }
-
// Return this object cast to a TabContents, if it is one.
virtual TabContents* GetAsTabContents() { return NULL; }
@@ -278,7 +268,9 @@ class RenderViewHostDelegate {
// A message was sent from HTML-based UI.
// By default we ignore such messages.
virtual void ProcessDOMUIMessage(const std::string& message,
- const std::string& content) { }
+ const std::string& content,
+ int request_id,
+ bool has_callback) { }
// A message for external host. By default we ignore such messages.
// |receiver| can be a receiving script and |message| is any
diff --git a/chrome/browser/renderer_host/render_view_host_manager.cc b/chrome/browser/renderer_host/render_view_host_manager.cc
index c0be053..7c4d219 100644
--- a/chrome/browser/renderer_host/render_view_host_manager.cc
+++ b/chrome/browser/renderer_host/render_view_host_manager.cc
@@ -19,6 +19,7 @@
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/url_constants.h"
namespace base {
class WaitableEvent;
@@ -294,6 +295,14 @@ bool RenderViewHostManager::ShouldSwapProcessesForNavigation(
DOMUIFactory::HasDOMUIScheme(new_entry->url()))
return true;
+ // Also, we must switch if one is an extension and the other is not the exact
+ // same extension.
+ if (cur_entry->url().SchemeIs(chrome::kExtensionScheme) ||
+ new_entry->url().SchemeIs(chrome::kExtensionScheme))
+ if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin())
+ return true;
+
+
return false;
}