summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authortwiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 01:23:54 +0000
committertwiz@chromium.org <twiz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 01:23:54 +0000
commitfd571bbf7f82fa08182fec4e18b8186b016d5de2 (patch)
treef4c693a0ae93f9cdf8c3405c905efa0ee474dc27 /chrome/browser/extensions
parentff88f4e0af4dcd145aea4a74c6fbec4aeaeffa68 (diff)
downloadchromium_src-fd571bbf7f82fa08182fec4e18b8186b016d5de2.zip
chromium_src-fd571bbf7f82fa08182fec4e18b8186b016d5de2.tar.gz
chromium_src-fd571bbf7f82fa08182fec4e18b8186b016d5de2.tar.bz2
Modification of ExtensionPopup views to allow for pop-up views to share the same network stack as their hosting views.
A new RenderViewHostDelegate interface has been added, AutomationRequestRouting, which can be implemented on RenderViewHost objects to return the data-structures used to pass network requests through Chrome-Frame host networking, or the native Chrome network stack. BUG=None TEST=None Review URL: http://codereview.chromium.org/906003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_popup_api.cc58
1 files changed, 48 insertions, 10 deletions
diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc
index d8d7262..c475751 100644
--- a/chrome/browser/extensions/extension_popup_api.cc
+++ b/chrome/browser/extensions/extension_popup_api.cc
@@ -6,22 +6,23 @@
#include "base/json/json_writer.h"
#include "base/string_util.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/notification_details.h"
-#include "chrome/common/notification_service.h"
-#include "chrome/common/notification_source.h"
-#include "chrome/common/notification_type.h"
-#include "chrome/common/url_constants.h"
#include "chrome/browser/extensions/extension_dom_ui.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_service.h"
+#include "chrome/common/notification_source.h"
+#include "chrome/common/notification_type.h"
+#include "chrome/common/url_constants.h"
#include "gfx/point.h"
#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/renderer_host/render_view_host_delegate.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/views/extensions/extension_popup.h"
#include "views/view.h"
@@ -93,11 +94,26 @@ class ExtensionPopupHost : public ExtensionPopup::Observer,
&ExtensionPopupHost::DispatchPopupClosedEvent));
}
- virtual void DispatchPopupClosedEvent() {
- RenderViewHost* render_view_host = dispatcher_->GetExtensionHost() ?
- dispatcher_->GetExtensionHost()->render_view_host() :
- dispatcher_->GetExtensionDOMUI()->GetRenderViewHost();
+ virtual void ExtensionHostCreated(ExtensionHost* host) {
+ // Pop-up views should share the same automation routing configuration as
+ // their hosting views, so register the RenderViewHost of the pop-up with
+ // the AutomationResourceRoutingDelegate interface of the dispatcher.
+ AutomationResourceRoutingDelegate* router =
+ GetRoutingFromDispatcher(dispatcher_);
+ if (router)
+ router->RegisterRenderViewHost(host->render_view_host());
+ }
+ virtual void DispatchPopupClosedEvent() {
+ // Unregister the automation resource routing registered upon host
+ // creation.
+ AutomationResourceRoutingDelegate* router =
+ GetRoutingFromDispatcher(dispatcher_);
+ if (router)
+ router->UnregisterRenderViewHost(popup_->host()->render_view_host());
+
+ RenderViewHost* render_view_host =
+ GetRenderViewHostFromDispatcher(dispatcher_);
PopupEventRouter::OnPopupClosed(dispatcher_->profile(),
render_view_host->routing_id());
dispatcher_ = NULL;
@@ -143,6 +159,28 @@ class ExtensionPopupHost : public ExtensionPopup::Observer,
}
private:
+ // Returns the AutomationResourceRoutingDelegate interface for |dispatcher|.
+ static AutomationResourceRoutingDelegate*
+ GetRoutingFromDispatcher(ExtensionFunctionDispatcher* dispatcher) {
+ if (!dispatcher)
+ return NULL;
+
+ RenderViewHost* render_view_host =
+ GetRenderViewHostFromDispatcher(dispatcher);
+ RenderViewHostDelegate* delegate =
+ render_view_host ? render_view_host->delegate() : NULL;
+
+ return delegate ? delegate->GetAutomationResourceRoutingDelegate() : NULL;
+ }
+
+ // Returns the RenderViewHost associated with |dispatcher|.
+ static RenderViewHost* GetRenderViewHostFromDispatcher(
+ ExtensionFunctionDispatcher* dispatcher) {
+ return dispatcher->GetExtensionHost() ?
+ dispatcher->GetExtensionHost()->render_view_host() :
+ dispatcher->GetExtensionDOMUI()->GetRenderViewHost();
+ }
+
// A pointer to the dispatcher that handled the request that opened this
// popup view.
ExtensionFunctionDispatcher* dispatcher_;