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

Unified Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 1216053013: [Extension Toolbar Redesign] Wants to act treatment, redux - left click (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 | « no previous file | chrome/browser/ui/extensions/extension_action_view_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/extensions/browser_action_button.mm
diff --git a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
index 53d5601a386d07abaeb6a7a5906ff4788ab1990c..c14a6e4f9ffadda1d287a04309bd74c543c10ae5 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm
@@ -325,9 +325,23 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
// mouse-up).
NSPoint location = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
+ // Only perform the click if we didn't drag the button.
if (NSPointInRect(location, [self bounds]) && !isBeingDragged_) {
- // Only perform the click if we didn't drag the button.
- [self performClick:self];
+ // There's also a chance that the action is disabled, and the left click
+ // should show the context menu.
+ if (!viewController_->IsEnabled(
+ [browserActionsController_ currentWebContents]) &&
+ viewController_->DisabledClickOpensMenu()) {
+ // No menus-in-menus; see comment in -rightMouseDown:.
+ if ([browserActionsController_ isOverflow]) {
+ [browserActionsController_ mainButtonForId:viewController_->GetId()]->
+ viewControllerDelegate_->ShowContextMenu();
+ } else {
+ [NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self];
+ }
+ } else {
+ [self performClick:self];
+ }
} else {
// Make sure an ESC to end a drag doesn't trigger 2 endDrags.
if (isBeingDragged_) {
@@ -406,7 +420,9 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
if (!image.IsEmpty())
[self setImage:image.ToNSImage()];
- [self setEnabled:viewController_->IsEnabled(webContents)];
+ BOOL enabled = viewController_->IsEnabled(webContents) ||
+ viewController_->DisabledClickOpensMenu();
+ [self setEnabled:enabled];
[self setNeedsDisplay:YES];
}
« no previous file with comments | « no previous file | chrome/browser/ui/extensions/extension_action_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698