diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 20:03:35 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-29 20:03:35 +0000 |
commit | 743de20e45734ce593a229801849e25b231785a8 (patch) | |
tree | eea14320bda943ef2de698ea0adae67a6661c67a | |
parent | 6624b46283f1974b8ea3d3b149763b3dd612359d (diff) | |
download | chromium_src-743de20e45734ce593a229801849e25b231785a8.zip chromium_src-743de20e45734ce593a229801849e25b231785a8.tar.gz chromium_src-743de20e45734ce593a229801849e25b231785a8.tar.bz2 |
[Mac] If the user clicks a Browser Action button when its popup is visible, the popup should close.
BUG=32161
TEST=none
Review URL: http://codereview.chromium.org/1571001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42982 0039d316-1c4b-4281-b951-d872f2087c98
3 files changed, 19 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index 49bb871..f9e796a 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -16,6 +16,7 @@ #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" #import "chrome/browser/cocoa/menu_button.h" #include "chrome/browser/extensions/extension_browser_event_router.h" +#include "chrome/browser/extensions/extension_host.h" #include "chrome/browser/extensions/extension_toolbar_model.h" #include "chrome/browser/extensions/extensions_service.h" #include "chrome/browser/profile.h" @@ -678,8 +679,18 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, ExtensionAction* action = [button extension]->browser_action(); if (action->HasPopup(tabId)) { + GURL popupUrl = action->GetPopupUrl(tabId); + // If a popup is already showing, check if the popup URL is the same. If so, + // then close the popup. + ExtensionPopupController* popup = [ExtensionPopupController popup]; + if (popup && + [[popup window] isVisible] && + [popup extensionHost]->GetURL() == popupUrl) { + [popup close]; + return; + } NSPoint arrowPoint = [self popupPointForBrowserAction:[button extension]]; - [ExtensionPopupController showURL:action->GetPopupUrl(tabId) + [ExtensionPopupController showURL:popupUrl inBrowser:browser_ anchoredAt:arrowPoint arrowLocation:kTopRight]; diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.h b/chrome/browser/cocoa/extensions/extension_popup_controller.h index e761470..61d020a 100644 --- a/chrome/browser/cocoa/extensions/extension_popup_controller.h +++ b/chrome/browser/cocoa/extensions/extension_popup_controller.h @@ -44,6 +44,9 @@ class ExtensionHost; scoped_ptr<ExtensionHost> host_; } +// Returns the ExtensionHost object associated with this popup. +- (ExtensionHost*)extensionHost; + // Starts the process of showing the given popup URL. Instantiates an // ExtensionPopupController with the parent window retrieved from |browser|, a // host for the popup created by the extension process manager specific to the diff --git a/chrome/browser/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/cocoa/extensions/extension_popup_controller.mm index a4e868c..592f6e9 100644 --- a/chrome/browser/cocoa/extensions/extension_popup_controller.mm +++ b/chrome/browser/cocoa/extensions/extension_popup_controller.mm @@ -124,6 +124,10 @@ CGFloat Clamp(CGFloat value, CGFloat min, CGFloat max) { return [static_cast<InfoBubbleWindow*>([self window]) isClosing]; } +- (ExtensionHost*)extensionHost { + return host_.get(); +} + + (ExtensionPopupController*)showURL:(GURL)url inBrowser:(Browser*)browser anchoredAt:(NSPoint)anchoredAt |