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

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: sync 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..7be8a0f2e2a7e8127ee47e16a8fb5d21fed2551d 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/browser_action_view.h"
@@ -686,6 +687,25 @@ void BrowserActionsContainer::BrowserActionMoved(const Extension* extension,
SchedulePaint();
}
+bool BrowserActionsContainer::BrowserActionShowPopup(
+ const extensions::Extension* extension) {
+ // Do not override other popups and only show in active window. The window
+ // must also have a toolbar, otherwise it should not be showing popups.
Finnur 2013/10/17 14:58:34 Document that you are checking for toolbar visibil
justinlin 2013/10/17 18:32:53 Done.
+ if (popup_ ||
+ !browser_->window()->IsActive() ||
+ !browser_->window()->IsToolbarVisible()) {
+ return false;
+ }
+
+ for (BrowserActionViews::iterator it = browser_action_views_.begin();
+ it != browser_action_views_.end(); ++it) {
+ BrowserActionButton* button = (*it)->button();
+ if (button && button->extension() == extension)
+ return ShowPopup(button, ExtensionPopup::SHOW, false);
+ }
+ return false;
+}
+
void BrowserActionsContainer::ModelLoaded() {
SetContainerWidth();
}
@@ -812,14 +832,22 @@ bool BrowserActionsContainer::ShouldDisplayBrowserAction(
IsIncognitoEnabled(extension->id()));
}
-void BrowserActionsContainer::ShowPopup(
+bool BrowserActionsContainer::ShowPopup(
BrowserActionButton* button,
ExtensionPopup::ShowAction show_action) {
+ return ShowPopup(button, show_action, true);
+}
+
+bool 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;
+ return false;
}
// If we're showing the same popup, just hide it and return.
@@ -830,7 +858,7 @@ void BrowserActionsContainer::ShowPopup(
HidePopup();
if (same_showing)
- return;
+ return false;
// We can get the execute event for browser actions that are not visible,
// since buttons can be activated from the overflow menu (chevron). In that
@@ -845,5 +873,9 @@ 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();
+ return true;
}

Powered by Google App Engine
This is Rietveld 408576698