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

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

Issue 10412052: Pull browser action click logic into ToolbarModelController, so that when I (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 7 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
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1df8c7943be0959833dc8ec1ba298afda22cd154..2938fbc6a0aa511d9e37f320bafc9d884d16c887 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -527,36 +527,15 @@ size_t BrowserActionsContainer::VisibleBrowserActions() const {
void BrowserActionsContainer::OnBrowserActionExecuted(
BrowserActionButton* button) {
- ExtensionAction* browser_action = button->browser_action();
-
- // Popups just display. No notification to the extension.
- // TODO(erikkay): should there be?
- if (!button->IsPopup()) {
- model_->ExecuteBrowserAction(browser_action->extension_id(), browser_);
- return;
+ const Extension* extension = button->extension();
+ GURL popup_url;
+ switch (model_->ExecuteBrowserAction(extension, browser_, &popup_url)) {
+ case ExtensionToolbarModel::ACTION_NONE:
+ break;
+ case ExtensionToolbarModel::ACTION_SHOW_POPUP:
+ ShowPopup(button, popup_url);
+ break;
}
-
- // If we're showing the same popup, just hide it and return.
- bool same_showing = popup_ && button == popup_button_;
-
- // Always hide the current popup, even if it's not the same.
- // Only one popup should be visible at a time.
- HidePopup();
-
- if (same_showing)
- return;
-
- // 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
- // case we show the popup as originating from the chevron.
- View* reference_view = button->parent()->visible() ? button : chevron_;
- views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
- views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
- popup_ = ExtensionPopup::ShowPopup(button->GetPopupUrl(), browser_,
- reference_view, arrow_location);
- popup_->GetWidget()->AddObserver(this);
- popup_button_ = button;
- popup_button_->SetButtonPushed();
}
gfx::Size BrowserActionsContainer::GetPreferredSize() {
@@ -1149,3 +1128,30 @@ bool BrowserActionsContainer::ShouldDisplayBrowserAction(
(!profile_->IsOffTheRecord() ||
profile_->GetExtensionService()->IsIncognitoEnabled(extension->id()));
}
+
+void BrowserActionsContainer::ShowPopup(BrowserActionButton* button,
+ const GURL& popup_url) {
+ // If we're showing the same popup, just hide it and return.
+ bool same_showing = popup_ && button == popup_button_;
+
+ // Always hide the current popup, even if it's not the same.
+ // Only one popup should be visible at a time.
+ HidePopup();
+
+ if (same_showing)
+ return;
+
+ // 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
+ // case we show the popup as originating from the chevron.
+ View* reference_view = button->parent()->visible() ? button : chevron_;
+ views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
+ views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
+ popup_ = ExtensionPopup::ShowPopup(popup_url,
+ browser_,
+ reference_view,
+ arrow_location);
+ popup_->GetWidget()->AddObserver(this);
+ popup_button_ = button;
+ popup_button_->SetButtonPushed();
+}
« no previous file with comments | « chrome/browser/ui/views/browser_actions_container.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698