Chromium Code Reviews| 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 be27ff4129a8d8307dd18447ef5059bf43eba5b0..139c4abb9163b9ff5339a356b451dba6ccaa0fc7 100644 |
| --- a/chrome/browser/ui/cocoa/extensions/browser_action_button.mm |
| +++ b/chrome/browser/ui/cocoa/extensions/browser_action_button.mm |
| @@ -35,7 +35,6 @@ NSString* const kBrowserActionButtonDraggingNotification = |
| NSString* const kBrowserActionButtonDragEndNotification = |
| @"BrowserActionButtonDragEndNotification"; |
| -static const CGFloat kBrowserActionBadgeOriginYOffset = 5; |
| static const CGFloat kAnimationDuration = 0.2; |
| static const CGFloat kMinimumDragDistance = 5; |
| @@ -171,11 +170,6 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| DCHECK(![controller_ toolbarActionsBar]->popped_out_action()); |
| } |
| -@interface BrowserActionCell (Internals) |
| -- (void)drawBadgeWithinFrame:(NSRect)frame |
| - forWebContents:(content::WebContents*)webContents; |
| -@end |
| - |
| @implementation BrowserActionButton |
| @synthesize isBeingDragged = isBeingDragged_; |
| @@ -202,7 +196,6 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| new ToolbarActionViewDelegateBridge(self, controller, viewController)); |
| [cell setBrowserActionsController:controller]; |
| - [cell setViewController:viewController_]; |
| [cell |
| accessibilitySetOverrideValue:base::SysUTF16ToNSString( |
| viewController_->GetAccessibleName([controller currentWebContents])) |
| @@ -407,7 +400,10 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| base::string16 tooltip = viewController_->GetTooltip(webContents); |
| [self setToolTip:(tooltip.empty() ? nil : base::SysUTF16ToNSString(tooltip))]; |
| - gfx::Image image = viewController_->GetIcon(webContents); |
| + NSRect frame = [self frame]; |
| + gfx::Image image = |
| + viewController_->GetIcon(webContents, |
| + gfx::Size(NSWidth(frame), NSHeight(frame))); |
|
Avi (use Gerrit)
2015/07/02 00:33:23
CGSizeFromNSSize(frame.size) should do it.
Devlin
2015/07/06 19:16:07
Dang, I was looking for that method, but couldn't
|
| if (!image.IsEmpty()) |
| [self setImage:image.ToNSImage()]; |
| @@ -467,11 +463,6 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| respectFlipped:YES |
| hints:nil]; |
| - bounds.origin.y += kBrowserActionBadgeOriginYOffset; |
| - [[self cell] drawBadgeWithinFrame:bounds |
| - forWebContents: |
| - [browserActionsController_ currentWebContents]]; |
| - |
| [image unlockFocus]; |
| return image; |
| } |
| @@ -528,22 +519,11 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| @implementation BrowserActionCell |
| @synthesize browserActionsController = browserActionsController_; |
| -@synthesize viewController = viewController_; |
| - |
| -- (void)drawBadgeWithinFrame:(NSRect)frame |
| - forWebContents:(content::WebContents*)webContents { |
| - gfx::CanvasSkiaPaint canvas(frame, false); |
| - canvas.set_composite_alpha(true); |
| - gfx::Rect boundingRect(NSRectToCGRect(frame)); |
| - viewController_->PaintExtra(&canvas, boundingRect, webContents); |
| -} |
| - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { |
| gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
| [super drawWithFrame:cellFrame inView:controlView]; |
| - DCHECK(viewController_); |
| - content::WebContents* webContents = |
| - [browserActionsController_ currentWebContents]; |
| + |
| const NSSize imageSize = self.image.size; |
| const NSRect imageRect = |
| NSMakeRect(std::floor((NSWidth(cellFrame) - imageSize.width) / 2.0), |
| @@ -555,10 +535,6 @@ void ToolbarActionViewDelegateBridge::DoShowContextMenu() { |
| fraction:1.0 |
| respectFlipped:YES |
| hints:nil]; |
| - |
| - cellFrame.origin.y += kBrowserActionBadgeOriginYOffset; |
| - [self drawBadgeWithinFrame:cellFrame |
| - forWebContents:webContents]; |
| } |
| - (ui::ThemeProvider*)themeProviderForWindow:(NSWindow*)window { |