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

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: mpcomplete@ 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 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

Powered by Google App Engine
This is Rietveld 408576698