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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_action_button.mm

Issue 1888133002: [Extensions UI Mac] Fix a bug with popped out actions' highlighted state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 5 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 [owner_ updateHighlightedState]; 162 [owner_ updateHighlightedState];
163 } 163 }
164 164
165 void ToolbarActionViewDelegateBridge::DoShowContextMenu() { 165 void ToolbarActionViewDelegateBridge::DoShowContextMenu() {
166 // The point the menu shows matches that of the normal app menu - that is, the 166 // The point the menu shows matches that of the normal app menu - that is, the
167 // right-left most corner of the menu is left-aligned with the app button, 167 // right-left most corner of the menu is left-aligned with the app button,
168 // and the menu is displayed "a little bit" lower. It would be nice to be able 168 // and the menu is displayed "a little bit" lower. It would be nice to be able
169 // to avoid the magic '5' here, but since it's built into Cocoa, it's not too 169 // to avoid the magic '5' here, but since it's built into Cocoa, it's not too
170 // hopeful. 170 // hopeful.
171 NSPoint menuPoint = NSMakePoint(0, NSHeight([owner_ bounds]) + 5); 171 NSPoint menuPoint = NSMakePoint(0, NSHeight([owner_ bounds]) + 5);
172 base::WeakPtr<ToolbarActionViewDelegateBridge> weak_this; 172 base::WeakPtr<ToolbarActionViewDelegateBridge> weakThis =
173 weakFactory_.GetWeakPtr();
Devlin 2016/04/14 18:54:35 D'oh. :(
Avi (use Gerrit) 2016/04/14 19:08:31 hahasob
173 [[owner_ cell] setHighlighted:YES]; 174 [[owner_ cell] setHighlighted:YES];
174 [[owner_ menu] popUpMenuPositioningItem:nil 175 [[owner_ menu] popUpMenuPositioningItem:nil
175 atLocation:menuPoint 176 atLocation:menuPoint
176 inView:owner_]; 177 inView:owner_];
177 // Since menus run in a blocking way, it's possible that the extension was 178 // Since menus run in a blocking way, it's possible that the extension was
178 // unloaded since this point. 179 // unloaded since this point.
179 if (!weak_this) 180 if (!weakThis)
180 return; 181 return;
181 [[owner_ cell] setHighlighted:NO]; 182 [[owner_ cell] setHighlighted:NO];
182 contextMenuRunning_ = false; 183 contextMenuRunning_ = false;
183 } 184 }
184 185
185 @implementation BrowserActionButton 186 @implementation BrowserActionButton
186 187
187 @synthesize isBeingDragged = isBeingDragged_; 188 @synthesize isBeingDragged = isBeingDragged_;
188 189
189 + (Class)cellClass { 190 + (Class)cellClass {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 534
534 - (void)setTestContextMenu:(NSMenu*)testContextMenu { 535 - (void)setTestContextMenu:(NSMenu*)testContextMenu {
535 testContextMenu_ = testContextMenu; 536 testContextMenu_ = testContextMenu;
536 } 537 }
537 538
538 - (BOOL)wantsToRunForTesting { 539 - (BOOL)wantsToRunForTesting {
539 return viewController_->WantsToRun( 540 return viewController_->WantsToRun(
540 [browserActionsController_ currentWebContents]); 541 [browserActionsController_ currentWebContents]);
541 } 542 }
542 543
544 - (BOOL)isHighlighted {
545 return [[self cell] isHighlighted];
546 }
547
543 @end 548 @end
544 549
545 @implementation BrowserActionCell 550 @implementation BrowserActionCell
546 551
547 @synthesize browserActionsController = browserActionsController_; 552 @synthesize browserActionsController = browserActionsController_;
548 553
549 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { 554 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
550 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 555 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
551 [super drawWithFrame:cellFrame inView:controlView]; 556 [super drawWithFrame:cellFrame inView:controlView];
552 557
(...skipping 21 matching lines...) Expand all
574 - (const ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { 579 - (const ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window {
575 const ui::ThemeProvider* themeProvider = [window themeProvider]; 580 const ui::ThemeProvider* themeProvider = [window themeProvider];
576 if (!themeProvider) 581 if (!themeProvider)
577 themeProvider = 582 themeProvider =
578 [[browserActionsController_ browser]->window()->GetNativeWindow() 583 [[browserActionsController_ browser]->window()->GetNativeWindow()
579 themeProvider]; 584 themeProvider];
580 return themeProvider; 585 return themeProvider;
581 } 586 }
582 587
583 @end 588 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698