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..2682c5201f251384b94888ca8bef2f6558965ace 100644 |
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
@@ -138,7 +138,9 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; |
animate:(BOOL)animate; |
// Handles when the given BrowserActionButton object is clicked. |
-- (void)browserActionClicked:(BrowserActionButton*)button; |
+- (bool)browserActionClicked:(BrowserActionButton*)button; |
+- (bool)browserActionClicked:(BrowserActionButton*)button |
Alexei Svitkine (slow)
2013/10/17 20:39:55
Can you add a comment here and explain |shouldGran
justinlin
2013/10/17 20:49:47
Done.
Finnur
2013/10/18 10:31:01
I think these should be consolidated into one func
justinlin
2013/10/19 06:01:48
Yea, so the problem is this function is used with
|
+ 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,17 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
[owner_ resizeContainerAndAnimate:NO]; |
} |
+ virtual bool 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 false; |
+ |
+ BrowserActionButton* button = [owner_ buttonForExtension:extension]; |
+ return 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 +752,12 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
} |
} |
-- (void)browserActionClicked:(BrowserActionButton*)button { |
+- (bool)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: { |
@@ -752,9 +767,15 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
anchoredAt:arrowPoint |
arrowLocation:info_bubble::kTopRight |
devMode:NO]; |
- break; |
+ return true; |
} |
} |
+ return false; |
+} |
+ |
+- (bool)browserActionClicked:(BrowserActionButton*)button { |
+ return [self browserActionClicked:button |
+ andGrant:true]; |
} |
- (BOOL)shouldDisplayBrowserAction:(const Extension*)extension { |