Chromium Code Reviews| 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..1e738ecd76c9ec4a569375bd2e50445aa459ee7b 100644 |
| --- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
| +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm |
| @@ -137,8 +137,11 @@ const CGFloat kBrowserActionBubbleYOffset = 3.0; |
| toIndex:(NSUInteger)index |
| animate:(BOOL)animate; |
| -// Handles when the given BrowserActionButton object is clicked. |
| -- (void)browserActionClicked:(BrowserActionButton*)button; |
| +// Handles when the given BrowserActionButton object is clicked and whether it |
| +// it should grant tab permissions. API-simulated clicks should not grant. |
|
Alexei Svitkine (slow)
2013/10/17 20:56:40
Nit: Remove extra 'it'
justinlin
2013/10/17 21:33:59
Done.
|
| +- (bool)browserActionClicked:(BrowserActionButton*)button |
| + shouldGrant:(BOOL)shouldGrant; |
| +- (bool)browserActionClicked:(BrowserActionButton*)button; |
| // Returns whether the given extension should be displayed. Only displays |
| // incognito-enabled extensions in incognito mode. Otherwise returns YES. |
| @@ -238,6 +241,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 |
| + shouldGrant:false]; |
|
Alexei Svitkine (slow)
2013/10/17 20:56:40
Nit: This is an Obj-C call, so change false -> NO
justinlin
2013/10/17 21:33:59
Done.
|
| + } |
| + |
| private: |
| // The object we need to inform when we get a notification. Weak. Owns us. |
| BrowserActionsController* owner_; |
| @@ -739,10 +753,12 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver, |
| } |
| } |
| -- (void)browserActionClicked:(BrowserActionButton*)button { |
| +- (bool)browserActionClicked:(BrowserActionButton*)button |
|
Alexei Svitkine (slow)
2013/10/17 20:56:40
Nit: Change return value to BOOL and return YES/NO
justinlin
2013/10/17 21:33:59
Done.
|
| + shouldGrant:(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 +768,14 @@ 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]; |
| } |
| - (BOOL)shouldDisplayBrowserAction:(const Extension*)extension { |