diff options
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/extension_dom_ui.h | 4 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_function_dispatcher.h | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 34 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_host.h | 7 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_popup_api.cc | 9 |
5 files changed, 47 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_dom_ui.h b/chrome/browser/extensions/extension_dom_ui.h index faa7836..a6c598f 100644 --- a/chrome/browser/extensions/extension_dom_ui.h +++ b/chrome/browser/extensions/extension_dom_ui.h @@ -48,7 +48,9 @@ class ExtensionDOMUI virtual Browser* GetBrowser() const; virtual gfx::NativeView GetNativeViewOfHost(); virtual gfx::NativeWindow GetCustomFrameNativeWindow(); - virtual TabContents* associated_tab_contents() { return tab_contents(); } + virtual TabContents* associated_tab_contents() const { + return tab_contents(); + } virtual Profile* GetProfile(); virtual ExtensionBookmarkManagerEventRouter* diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h index 2e8251f..99328f7 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.h +++ b/chrome/browser/extensions/extension_function_dispatcher.h @@ -51,7 +51,7 @@ class ExtensionFunctionDispatcher { // context. For example, the TabContents in which an infobar or // chrome-extension://<id> URL are being shown. Callers must check for a // NULL return value (as in the case of a background page). - virtual TabContents* associated_tab_contents() = 0; + virtual TabContents* associated_tab_contents() const = 0; protected: virtual ~Delegate() {} diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 13619ff..334c28e 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -457,6 +457,13 @@ void ExtensionHost::Close(RenderViewHost* render_view_host) { RendererPreferences ExtensionHost::GetRendererPrefs(Profile* profile) const { RendererPreferences preferences; + + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents) + preferences = + static_cast<RenderViewHostDelegate*>(associated_contents)-> + GetRendererPrefs(profile); + renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile); return preferences; } @@ -501,7 +508,7 @@ void ExtensionHost::CreateNewWindow( const string16& frame_name) { // TODO(aa): Use the browser's profile if the extension is split mode // incognito. - delegate_view_helper_.CreateNewWindow( + TabContents* new_contents = delegate_view_helper_.CreateNewWindow( route_id, render_view_host()->process()->profile(), site_instance(), @@ -510,6 +517,10 @@ void ExtensionHost::CreateNewWindow( this, window_container_type, frame_name); + + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents && associated_contents->delegate()) + associated_contents->delegate()->TabContentsCreated(new_contents); } void ExtensionHost::CreateNewWidget(int route_id, @@ -542,11 +553,26 @@ void ExtensionHost::ShowCreatedWindow(int route_id, Browser::TYPE_NORMAL, false); // Match incognito exactly. if (!browser) { - browser = Browser::Create(contents->profile()); - browser->window()->Show(); + // If no browser is associated with the created TabContents, then the + // created TabContents may be an intermediate structure used during topmost + // url navigation from within an experimental extension popup view. + // + // If the ExtensionHost has an associated TabContents, then register the + // new contents with this contents. This will allow top-level link + // navigation within the new contents to function just as navigation + // within the current host. + TabContents* associated_contents = associated_tab_contents(); + if (associated_contents) { + associated_contents->AddNewContents(contents, disposition, initial_pos, + user_gesture); + } else { + browser = Browser::Create(contents->profile()); + browser->window()->Show(); + } } - browser->AddTabContents(contents, disposition, initial_pos, user_gesture); + if (browser) + browser->AddTabContents(contents, disposition, initial_pos, user_gesture); } void ExtensionHost::ShowCreatedWidget(int route_id, diff --git a/chrome/browser/extensions/extension_host.h b/chrome/browser/extensions/extension_host.h index 80dbf14..d5746cc 100644 --- a/chrome/browser/extensions/extension_host.h +++ b/chrome/browser/extensions/extension_host.h @@ -86,7 +86,7 @@ class ExtensionHost : public RenderViewHostDelegate, ViewType::Type extension_host_type() const { return extension_host_type_; } // ExtensionFunctionDispatcher::Delegate - virtual TabContents* associated_tab_contents() { + virtual TabContents* associated_tab_contents() const { return associated_tab_contents_; } void set_associated_tab_contents(TabContents* associated_tab_contents) { @@ -111,8 +111,7 @@ class ExtensionHost : public RenderViewHostDelegate, // |size_limit| in both width and height. void DisableScrollbarsForSmallWindows(const gfx::Size& size_limit); - // RenderViewHostDelegate implementation. - virtual RenderViewHostDelegate::View* GetViewDelegate(); + // RenderViewHostDelegate::View implementation. virtual const GURL& GetURL() const { return url_; } virtual void RenderViewCreated(RenderViewHost* render_view_host); virtual ViewType::Type GetRenderViewType() const; @@ -126,6 +125,8 @@ class ExtensionHost : public RenderViewHostDelegate, virtual void DocumentOnLoadCompletedInMainFrame( RenderViewHost* render_view_host); + // RenderViewHostDelegate implementation. + virtual RenderViewHostDelegate::View* GetViewDelegate(); virtual WebPreferences GetWebkitPrefs(); virtual void ProcessDOMUIMessage(const ViewHostMsg_DomMessage_Params& params); virtual void RunJavaScriptMessage(const std::wstring& message, diff --git a/chrome/browser/extensions/extension_popup_api.cc b/chrome/browser/extensions/extension_popup_api.cc index 3e4f22a..4b3bbd9 100644 --- a/chrome/browser/extensions/extension_popup_api.cc +++ b/chrome/browser/extensions/extension_popup_api.cc @@ -165,6 +165,15 @@ class ExtensionPopupHost : public ExtensionPopup::Observer, GetRoutingFromDispatcher(dispatcher_); if (router) router->RegisterRenderViewHost(host->render_view_host()); + + // Extension hosts created for popup contents exist in the same tab + // contents as the ExtensionFunctionDispatcher that requested the popup. + // For example, '_blank' link navigation should be routed through the tab + // contents that requested the popup. + if (dispatcher_ && dispatcher_->delegate()) { + host->set_associated_tab_contents( + dispatcher_->delegate()->associated_tab_contents()); + } } virtual void ExtensionPopupResized(ExtensionPopup* popup) { |