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

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm

Issue 25305002: Implement initial chrome.browserAction.openPopup API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to interactive_ui_test Created 7 years, 2 months 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/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 749da3acef1a2fb8ede573640a8210c9717a5226..92daa8e13349e8291a9e7df97915349e53b403b5 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm
@@ -138,8 +138,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 should grant tab permissions. API-simulated clicks should not grant.
+- (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.
@@ -239,6 +242,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:NO];
+ }
+
private:
// The object we need to inform when we get a notification. Weak. Owns us.
BrowserActionsController* owner_;
@@ -740,10 +754,12 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver,
}
}
-- (void)browserActionClicked:(BrowserActionButton*)button {
+- (BOOL)browserActionClicked:(BrowserActionButton*)button
+ 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: {
@@ -753,9 +769,15 @@ class ExtensionServiceObserverBridge : public content::NotificationObserver,
anchoredAt:arrowPoint
arrowLocation:info_bubble::kTopRight
devMode:NO];
- break;
+ return YES;
}
}
+ return NO;
+}
+
+- (BOOL)browserActionClicked:(BrowserActionButton*)button {
+ return [self browserActionClicked:button
+ shouldGrant:YES];
}
- (BOOL)shouldDisplayBrowserAction:(const Extension*)extension {

Powered by Google App Engine
This is Rietveld 408576698