Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 434046: Support for chrome.experimental.popup API in ExternalTabContainer views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_host.cc
===================================================================
--- chrome/browser/extensions/extension_host.cc (revision 34039)
+++ chrome/browser/extensions/extension_host.cc (working copy)
@@ -539,7 +539,7 @@
#endif
}
-Browser* ExtensionHost::GetBrowser() {
+Browser* ExtensionHost::GetBrowser() const {
if (view_.get())
return view_->browser();
@@ -594,16 +594,19 @@
}
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;

Powered by Google App Engine
This is Rietveld 408576698