Index: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
index a17f3d8cde36d18dbab3e47d97209012f9400896..1aea825692132d8cf179400267495aae3bfaea00 100644 |
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
@@ -139,6 +139,8 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; |
// Handles when the given BrowserActionButton object is clicked. |
- (void)browserActionClicked:(BrowserActionButton*)button; |
+- (void)browserActionClicked:(BrowserActionButton*)button |
+ andGrant:(BOOL)shouldGrant; |
// Returns whether the given extension should be displayed. Only displays |
// incognito-enabled extensions in incognito mode. Otherwise returns YES. |
@@ -238,6 +240,19 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
[owner_ resizeContainerAndAnimate:NO]; |
} |
+ virtual void BrowserActionShowPopup(const Extension* extension) OVERRIDE { |
+ // Do not override other popups and only show in active window. |
+ ExtensionPopupController* popup = [ExtensionPopupController popup]; |
+ if (popup || !browser_->window()->IsActive()) |
+ return; |
+ |
+ BrowserActionButton* button = [owner_ buttonForExtension:extension]; |
+ if (button) { |
+ [owner_ browserActionClicked:button |
+ andGrant:false]; |
+ } |
+ } |
+ |
private: |
// The object we need to inform when we get a notification. Weak. Owns us. |
BrowserActionsController* owner_; |
@@ -739,10 +754,12 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
} |
} |
-- (void)browserActionClicked:(BrowserActionButton*)button { |
+- (void)browserActionClicked:(BrowserActionButton*)button |
+ andGrant:(BOOL)shouldGrant { |
const Extension* extension = [button extension]; |
GURL popupUrl; |
- switch (toolbarModel_->ExecuteBrowserAction(extension, browser_, &popupUrl)) { |
+ switch (toolbarModel_->ExecuteBrowserAction(extension, browser_, &popupUrl, |
+ shouldGrant)) { |
case ExtensionToolbarModel::ACTION_NONE: |
break; |
case ExtensionToolbarModel::ACTION_SHOW_POPUP: { |
@@ -757,6 +774,11 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
} |
} |
+- (void)browserActionClicked:(BrowserActionButton*)button { |
+ [self browserActionClicked:button |
+ andGrant:true]; |
+} |
+ |
- (BOOL)shouldDisplayBrowserAction:(const Extension*)extension { |
// Only display incognito-enabled extensions while in incognito mode. |
return |