Index: chrome/browser/extensions/extension_toolbar_model.cc |
diff --git a/chrome/browser/extensions/extension_toolbar_model.cc b/chrome/browser/extensions/extension_toolbar_model.cc |
index a61dc42effaa821ca545cffbe4d8fd7f927a655e..a3a61e6d0fef3feef5e5d46e91118a0a39bb26dc 100644 |
--- a/chrome/browser/extensions/extension_toolbar_model.cc |
+++ b/chrome/browser/extensions/extension_toolbar_model.cc |
@@ -4,6 +4,8 @@ |
#include "chrome/browser/extensions/extension_toolbar_model.h" |
+#include <string> |
+ |
#include "base/prefs/pref_service.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
@@ -42,6 +44,11 @@ bool IsInExtensionList(const Extension* extension, |
} // namespace |
+bool ExtensionToolbarModel::Observer::BrowserActionShowPopup( |
+ const extensions::Extension* extension) { |
+ return false; |
+} |
+ |
ExtensionToolbarModel::ExtensionToolbarModel(ExtensionService* service) |
: service_(service), |
prefs_(service->profile()->GetPrefs()), |
@@ -129,7 +136,8 @@ void ExtensionToolbarModel::MoveBrowserAction(const Extension* extension, |
ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction( |
const Extension* extension, |
Browser* browser, |
- GURL* popup_url_out) { |
+ GURL* popup_url_out, |
+ bool should_grant) { |
content::WebContents* web_contents = NULL; |
int tab_id = 0; |
if (!ExtensionTabUtil::GetDefaultTab(browser, &web_contents, &tab_id)) |
@@ -143,8 +151,10 @@ ExtensionToolbarModel::Action ExtensionToolbarModel::ExecuteBrowserAction( |
if (!browser_action->GetIsVisible(tab_id)) |
return ACTION_NONE; |
- extensions::TabHelper::FromWebContents(web_contents)-> |
- active_tab_permission_granter()->GrantIfRequested(extension); |
+ if (should_grant) { |
+ extensions::TabHelper::FromWebContents(web_contents)-> |
+ active_tab_permission_granter()->GrantIfRequested(extension); |
+ } |
if (browser_action->HasPopup(tab_id)) { |
if (popup_url_out) |
@@ -455,3 +465,15 @@ void ExtensionToolbarModel::OnExtensionToolbarPrefChange() { |
weak_ptr_factory_.GetWeakPtr())); |
} |
} |
+ |
+bool ExtensionToolbarModel::ShowBrowserActionPopup( |
+ const extensions::Extension* extension) { |
+ ObserverListBase<Observer>::Iterator it(observers_); |
+ Observer* obs = NULL; |
+ while ((obs = it.GetNext()) != NULL) { |
+ // Stop after first popup since it should only show in the active window. |
+ if (obs->BrowserActionShowPopup(extension)) |
+ return true; |
+ } |
+ return false; |
+} |