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

Unified Diff: chrome/browser/ui/views/browser_actions_container.cc

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/views/browser_actions_container.cc
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index 850189762babaf027940beb6b62b50d63e4e86c2..6427ed4c2ec66b661703d68a64b4731cbdaca197 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -686,6 +686,23 @@ void BrowserActionsContainer::BrowserActionMoved(const Extension* extension,
SchedulePaint();
}
+void BrowserActionsContainer::BrowserActionShowPopup(
+ const extensions::Extension* extension) {
+ // Do not override other popups and only show in active window.
+ if (popup_ || !browser_->window()->IsActive())
+ return;
+
+ BrowserActionButton* button = NULL;
sky 2013/10/16 22:26:07 Did you try this? I think you want to nuke button,
justinlin 2013/10/17 04:14:52 err, right. Was *just* about to compile it and tes
Finnur 2013/10/17 14:58:34 Wait? A window is created for extension's backgrou
justinlin 2013/10/17 18:32:53 I mean when opening the console view of the backgr
+ for (BrowserActionViews::iterator it = browser_action_views_.begin();
+ it != browser_action_views_.end(); ++it) {
+ if ((*it)->button()->extension() == extension) {
+ if (button != NULL)
+ ShowPopup(button, ExtensionPopup::SHOW, false);
+ return;
+ }
+ }
+}
+
void BrowserActionsContainer::ModelLoaded() {
SetContainerWidth();
}
@@ -815,9 +832,17 @@ bool BrowserActionsContainer::ShouldDisplayBrowserAction(
void BrowserActionsContainer::ShowPopup(
BrowserActionButton* button,
ExtensionPopup::ShowAction show_action) {
+ ShowPopup(button, show_action, true);
+}
+
+void BrowserActionsContainer::ShowPopup(
+ BrowserActionButton* button,
+ ExtensionPopup::ShowAction show_action,
+ bool should_grant) {
const Extension* extension = button->extension();
GURL popup_url;
- if (model_->ExecuteBrowserAction(extension, browser_, &popup_url) !=
+ if (model_->ExecuteBrowserAction(
+ extension, browser_, &popup_url, should_grant) !=
ExtensionToolbarModel::ACTION_SHOW_POPUP) {
return;
}
@@ -845,5 +870,8 @@ void BrowserActionsContainer::ShowPopup(
show_action);
popup_->GetWidget()->AddObserver(this);
popup_button_ = button;
- popup_button_->SetButtonPushed();
+
+ // Only set button as pushed if it was triggered by a user click.
+ if (should_grant)
+ popup_button_->SetButtonPushed();
}
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | chrome/common/extensions/api/_api_features.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698