diff options
author | twiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 01:59:11 +0000 |
---|---|---|
committer | twiz@google.com <twiz@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 01:59:11 +0000 |
commit | a95631cb9427e4d20c243dcd0f36da3fd3e7cb55 (patch) | |
tree | 09da2c4493a7303671961051b32718830c451ad7 /chrome/browser/extensions/extension_host.cc | |
parent | 2007ad49132097b2a2eb10d0025361d1bf7a9340 (diff) | |
download | chromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.zip chromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.tar.gz chromium_src-a95631cb9427e4d20c243dcd0f36da3fd3e7cb55.tar.bz2 |
A collection of fixes allowing the chrome.experimental.popup.* set of APIs to function in circumstances where there is no Browser instance present. This is a symptom of a tab-contents view hosted in an ExternalTabContainer.The major change here is the removal of the explicit dependency on a Browser instance across all of the delegates involved when showing a pop-up API. I modified the following delegates:- ExtensionPopupHost::Delegate- TabContentsDelegate- ExtensionFunctionDispatcher::DelegateBecause the pop-up requires a Profile, and a gfx::NativeWindow, I added methods to the above interfaces to provide them.BUG=noneTEST=ExtensionApiTest.FLAKY_Popup
Review URL: http://codereview.chromium.org/434046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34219 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_host.cc')
-rw-r--r-- | chrome/browser/extensions/extension_host.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc index 0ad3a9e..77bee6c 100644 --- a/chrome/browser/extensions/extension_host.cc +++ b/chrome/browser/extensions/extension_host.cc @@ -549,7 +549,7 @@ void ExtensionHost::HandleMouseLeave() { #endif } -Browser* ExtensionHost::GetBrowser() { +Browser* ExtensionHost::GetBrowser() const { if (view_.get()) return view_->browser(); @@ -604,16 +604,19 @@ void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { } int ExtensionHost::GetBrowserWindowID() const { + // Hosts not attached to any browser window have an id of -1. This includes + // those mentioned below, and background pages. int window_id = -1; if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP || extension_host_type_ == ViewType::EXTENSION_MOLE || extension_host_type_ == ViewType::EXTENSION_POPUP) { - window_id = ExtensionTabUtil::GetWindowId( - const_cast<ExtensionHost* >(this)->GetBrowser()); - } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) { - // Background page is not attached to any browser window, so pass -1. - window_id = -1; - } else { + // If the host is bound to a browser, then extract its window id. + // Extensions hosted in ExternalTabContainer objects may not have + // an associated browser. + Browser* browser = GetBrowser(); + if (browser) + window_id = ExtensionTabUtil::GetWindowId(browser); + } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { NOTREACHED(); } return window_id; |