summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_resource_routing_delegate.h31
-rw-r--r--chrome/browser/extensions/extension_popup_api.cc58
-rw-r--r--chrome/browser/external_tab_container.cc62
-rw-r--r--chrome/browser/external_tab_container.h9
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.cc5
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h7
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc5
-rw-r--r--chrome/browser/tab_contents/tab_contents.h5
-rw-r--r--chrome/browser/tab_contents/tab_contents_delegate.h3
-rw-r--r--chrome/browser/views/extensions/extension_popup.cc3
-rw-r--r--chrome/browser/views/extensions/extension_popup.h8
11 files changed, 163 insertions, 33 deletions
diff --git a/chrome/browser/automation/automation_resource_routing_delegate.h b/chrome/browser/automation/automation_resource_routing_delegate.h
new file mode 100644
index 0000000..63c95de
--- /dev/null
+++ b/chrome/browser/automation/automation_resource_routing_delegate.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2010 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.
+
+#ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_ROUTING_DELEGATE_H_
+#define CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_ROUTING_DELEGATE_H_
+
+#include "base/basictypes.h"
+
+class RenderViewHost;
+
+// Interface for registering RenderViewHost instances for resource routing
+// automation.
+class AutomationResourceRoutingDelegate {
+ public:
+ // Call to register |render_view_host| for resource routing automation
+ // by the delegate.
+ virtual void RegisterRenderViewHost(RenderViewHost* render_view_host) {}
+
+ // Call to unregister |render_view_host| from resource routing automation.
+ virtual void UnregisterRenderViewHost(RenderViewHost* render_view_host) {}
+
+ protected:
+ AutomationResourceRoutingDelegate() {}
+ virtual ~AutomationResourceRoutingDelegate() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(AutomationResourceRoutingDelegate);
+};
+
+#endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_RESOURCE_ROUTING_DELEGATE_H_
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_;
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 08c9fe7..70ac7fc 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -167,8 +167,7 @@ void ExternalTabContainer::Uninitialize() {
if (DevToolsManager::GetInstance())
DevToolsManager::GetInstance()->UnregisterDevToolsClientHostFor(rvh);
- AutomationResourceMessageFilter::UnRegisterRenderView(
- rvh->process()->id(), rvh->routing_id());
+ UnregisterRenderViewHost(rvh);
}
NotificationService::current()->Notify(
@@ -373,15 +372,11 @@ void ExternalTabContainer::AddNewContents(TabContents* source,
void ExternalTabContainer::TabContentsCreated(TabContents* new_contents) {
RenderViewHost* rvh = new_contents->render_view_host();
DCHECK(rvh != NULL);
- if (rvh) {
- // Register this render view as a pending render view, i.e. any network
- // requests initiated by this render view would be serviced when the
- // external host connects to the new external tab instance.
- AutomationResourceMessageFilter::RegisterRenderView(
- rvh->process()->id(), rvh->routing_id(),
- tab_handle_, automation_resource_message_filter_,
- true);
- }
+
+ // Register this render view as a pending render view, i.e. any network
+ // requests initiated by this render view would be serviced when the
+ // external host connects to the new external tab instance.
+ RegisterRenderViewHostForAutomation(rvh, true);
}
void ExternalTabContainer::ActivateContents(TabContents* contents) {
@@ -486,6 +481,40 @@ void ExternalTabContainer::ShowPageInfo(Profile* profile,
browser::ShowPageInfo(GetNativeView(), profile, url, ssl, show_history);
}
+void ExternalTabContainer::RegisterRenderViewHostForAutomation(
+ RenderViewHost* render_view_host, bool pending_view) {
+ if (render_view_host) {
+ AutomationResourceMessageFilter::RegisterRenderView(
+ render_view_host->process()->id(),
+ render_view_host->routing_id(),
+ tab_handle(),
+ automation_resource_message_filter_,
+ pending_view);
+ }
+}
+
+
+void ExternalTabContainer::RegisterRenderViewHost(
+ RenderViewHost* render_view_host) {
+ // RenderViewHost instances that are to be associated with this
+ // ExternalTabContainer should share the same resource request automation
+ // settings.
+ RegisterRenderViewHostForAutomation(
+ render_view_host,
+ false); // Network requests should not be handled later.
+}
+
+void ExternalTabContainer::UnregisterRenderViewHost(
+ RenderViewHost* render_view_host) {
+ // Undo the resource automation registration performed in
+ // ExternalTabContainer::RegisterRenderViewHost.
+ if (render_view_host) {
+ AutomationResourceMessageFilter::UnRegisterRenderView(
+ render_view_host->process()->id(),
+ render_view_host->routing_id());
+ }
+}
+
bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) {
if (!automation_) {
NOTREACHED();
@@ -623,21 +652,14 @@ void ExternalTabContainer::Observe(NotificationType type,
case NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB: {
if (load_requests_via_automation_) {
RenderViewHost* rvh = Details<RenderViewHost>(details).ptr();
- if (rvh) {
- AutomationResourceMessageFilter::RegisterRenderView(
- rvh->process()->id(), rvh->routing_id(),
- tab_handle_, automation_resource_message_filter_, false);
- }
+ RegisterRenderViewHostForAutomation(rvh, false);
}
break;
}
case NotificationType::RENDER_VIEW_HOST_DELETED: {
if (load_requests_via_automation_) {
RenderViewHost* rvh = Details<RenderViewHost>(details).ptr();
- if (rvh) {
- AutomationResourceMessageFilter::UnRegisterRenderView(
- rvh->process()->id(), rvh->routing_id());
- }
+ UnregisterRenderViewHost(rvh);
}
break;
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 4122b62..123d13c 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -148,6 +148,10 @@ class ExternalTabContainer : public TabContentsDelegate,
virtual Browser* GetBrowser() { return browser_.get(); }
+ // Overriden from TabContentsDelegate::AutomationResourceRoutingDelegate
+ virtual void RegisterRenderViewHost(RenderViewHost* render_view_host);
+ virtual void UnregisterRenderViewHost(RenderViewHost* render_view_host);
+
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
const NotificationSource& source,
@@ -217,6 +221,11 @@ class ExternalTabContainer : public TabContentsDelegate,
~ExternalTabContainer();
+ // Helper resource automation registration method, allowing registration of
+ // pending RenderViewHosts.
+ void RegisterRenderViewHostForAutomation(RenderViewHost* render_view_host,
+ bool pending_view);
+
// Top level navigations received for a tab while it is waiting for an ack
// from the external host go here. Scenario is a window.open executes on a
// page in ChromeFrame. A new TabContents is created and the current
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.cc b/chrome/browser/renderer_host/render_view_host_delegate.cc
index d744931..f6a1c66 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.cc
+++ b/chrome/browser/renderer_host/render_view_host_delegate.cc
@@ -62,6 +62,11 @@ RenderViewHostDelegate::GetBookmarkDragDelegate() {
return NULL;
}
+AutomationResourceRoutingDelegate*
+RenderViewHostDelegate::GetAutomationResourceRoutingDelegate() {
+ return NULL;
+}
+
const GURL& RenderViewHostDelegate::GetURL() const {
return GURL::EmptyGURL();
}
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index d9fbb01..45934d2 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -16,6 +16,8 @@
#include "third_party/WebKit/WebKit/chromium/public/WebDragOperation.h"
#include "webkit/glue/window_open_disposition.h"
+
+class AutomationResourceRoutingDelegate;
struct BookmarkDragData;
class BookmarkNode;
struct ContextMenuParams;
@@ -441,6 +443,11 @@ class RenderViewHostDelegate {
virtual AutoFill* GetAutoFillDelegate();
virtual BookmarkDrag* GetBookmarkDragDelegate();
+ // Return the delegate for registering RenderViewHosts for automation resource
+ // routing.
+ virtual AutomationResourceRoutingDelegate*
+ GetAutomationResourceRoutingDelegate();
+
// Gets the URL that is currently being displayed, if there is one.
virtual const GURL& GetURL() const;
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index aa2bc97..5f1feac 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2068,6 +2068,11 @@ RenderViewHostDelegate::AutoFill* TabContents::GetAutoFillDelegate() {
return autofill_manager_.get();
}
+AutomationResourceRoutingDelegate*
+TabContents::GetAutomationResourceRoutingDelegate() {
+ return delegate();
+}
+
RenderViewHostDelegate::BookmarkDrag* TabContents::GetBookmarkDragDelegate() {
return bookmark_drag_;
}
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index b113dd5..403c3ea 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -636,9 +636,8 @@ class TabContents : public PageNavigator,
void set_request_context(URLRequestContextGetter* context) {
request_context_ = context;
}
-
URLRequestContextGetter* request_context() const {
- return request_context_;
+ return request_context_.get();
}
LanguageState& language_state() {
@@ -856,6 +855,8 @@ class TabContents : public PageNavigator,
virtual RenderViewHostDelegate::FavIcon* GetFavIconDelegate();
virtual RenderViewHostDelegate::Autocomplete* GetAutocompleteDelegate();
virtual RenderViewHostDelegate::AutoFill* GetAutoFillDelegate();
+ virtual AutomationResourceRoutingDelegate*
+ GetAutomationResourceRoutingDelegate();
virtual TabContents* GetAsTabContents();
virtual ViewType::Type GetRenderViewType() const;
virtual int GetBrowserWindowID() const;
diff --git a/chrome/browser/tab_contents/tab_contents_delegate.h b/chrome/browser/tab_contents/tab_contents_delegate.h
index 53acce0..25653f4 100644
--- a/chrome/browser/tab_contents/tab_contents_delegate.h
+++ b/chrome/browser/tab_contents/tab_contents_delegate.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "chrome/browser/automation/automation_resource_routing_delegate.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/common/content_settings_types.h"
#include "chrome/common/native_web_keyboard_event.h"
@@ -33,7 +34,7 @@ struct WebApplicationInfo;
// Objects implement this interface to get notified about changes in the
// TabContents and to provide necessary functionality.
-class TabContentsDelegate {
+class TabContentsDelegate : public AutomationResourceRoutingDelegate {
public:
// Opens a new URL inside the passed in TabContents (if source is 0 open
// in the current front-most tab), unless |disposition| indicates the url
diff --git a/chrome/browser/views/extensions/extension_popup.cc b/chrome/browser/views/extensions/extension_popup.cc
index 6755c0d..28a2603 100644
--- a/chrome/browser/views/extensions/extension_popup.cc
+++ b/chrome/browser/views/extensions/extension_popup.cc
@@ -336,6 +336,9 @@ ExtensionPopup* ExtensionPopup::Show(
return NULL;
ExtensionHost* host = manager->CreatePopup(url, browser);
+ if (observer)
+ observer->ExtensionHostCreated(host);
+
ExtensionPopup* popup = new ExtensionPopup(host, frame_widget, relative_to,
arrow_location, activate_on_show,
inspect_with_devtools, chrome,
diff --git a/chrome/browser/views/extensions/extension_popup.h b/chrome/browser/views/extensions/extension_popup.h
index f44ace3..5c62b5d 100644
--- a/chrome/browser/views/extensions/extension_popup.h
+++ b/chrome/browser/views/extensions/extension_popup.h
@@ -14,6 +14,7 @@
#include "gfx/native_widget_types.h"
#include "googleurl/src/gurl.h"
+
class Browser;
class ExtensionHost;
class Profile;
@@ -35,6 +36,13 @@ class ExtensionPopup : public BrowserBubble,
// is ref-counted, and thus will be released shortly after
// making this delegate call.
virtual void ExtensionPopupClosed(ExtensionPopup* popup) {}
+
+ // Called when the ExtensionHost is first created for the pop-up view.
+ // Note that this is invoked BEFORE the ExtensionPopup is created, and can
+ // be used to provide extra configuration of the host before it is pushed
+ // into the popup. An example use is for automation resource routing in
+ // Chrome-Frame. See extension_popup_api.cc.
+ virtual void ExtensionHostCreated(ExtensionHost* host) {}
};
enum PopupChrome {