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

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

Issue 501136: Merge 34812 - Add the rightclick context menu for Browser actions and Page... (Closed) Base URL: svn://chrome-svn/chrome/branches/249/src/
Patch Set: Created 11 years 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/views/browser_actions_container.cc
===================================================================
--- chrome/browser/views/browser_actions_container.cc (revision 35008)
+++ chrome/browser/views/browser_actions_container.cc (working copy)
@@ -54,10 +54,11 @@
browser_action_(extension->browser_action()),
extension_(extension),
tracker_(NULL),
+ showing_context_menu_(false),
panel_(panel) {
set_alignment(TextButton::ALIGN_CENTER);
- // No UpdateState() here because View heirarchy not setup yet. Our parent
+ // No UpdateState() here because View hierarchy not setup yet. Our parent
// should call UpdateState() after creation.
registrar_.Add(this, NotificationType::EXTENSION_BROWSER_ACTION_UPDATED,
@@ -153,14 +154,32 @@
}
bool BrowserActionButton::OnMousePressed(const views::MouseEvent& e) {
- if (IsPopup())
+ showing_context_menu_ = e.IsRightMouseButton();
+ if (showing_context_menu_) {
+ SetButtonPushed();
+
+ // Get the top left point of this button in screen coordinates.
+ gfx::Point point = gfx::Point(0, 0);
+ ConvertPointToScreen(this, &point);
+
+ // Make the menu appear below the button.
+ point.Offset(0, height());
+
+ if (!context_menu_.get())
+ context_menu_.reset(new ExtensionActionContextMenu());
+ context_menu_->Run(extension(), point);
+
+ SetButtonNotPushed();
+ return false;
+ } else if (IsPopup()) {
return MenuButton::OnMousePressed(e);
+ }
return TextButton::OnMousePressed(e);
}
void BrowserActionButton::OnMouseReleased(const views::MouseEvent& e,
bool canceled) {
- if (IsPopup()) {
+ if (IsPopup() || showing_context_menu_) {
// TODO(erikkay) this never actually gets called (probably because of the
// loss of focus).
MenuButton::OnMouseReleased(e, canceled);
@@ -176,18 +195,18 @@
}
void BrowserActionButton::OnMouseExited(const views::MouseEvent& e) {
- if (IsPopup())
+ if (IsPopup() || showing_context_menu_)
MenuButton::OnMouseExited(e);
else
TextButton::OnMouseExited(e);
}
-void BrowserActionButton::PopupDidShow() {
+void BrowserActionButton::SetButtonPushed() {
SetState(views::CustomButton::BS_PUSHED);
menu_visible_ = true;
}
-void BrowserActionButton::PopupDidHide() {
+void BrowserActionButton::SetButtonNotPushed() {
SetState(views::CustomButton::BS_NORMAL);
menu_visible_ = false;
}
@@ -348,7 +367,7 @@
closing_popup->DetachFromBrowser();
delete closing_popup;
- closing_button->PopupDidHide();
+ closing_button->SetButtonNotPushed();
return;
}
}
@@ -386,7 +405,7 @@
BubbleBorder::TOP_RIGHT);
popup_->set_delegate(this);
popup_button_ = button;
- popup_button_->PopupDidShow();
+ popup_button_->SetButtonPushed();
return;
}
« no previous file with comments | « chrome/browser/views/browser_actions_container.h ('k') | chrome/browser/views/extensions/extension_action_context_menu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698