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

Side by Side Diff: chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.mm

Issue 2028823003: Mac: Make ScopedTypeRef require explicit constructors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/toolbar/toolbar_button_cocoa.h" 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_button_cocoa.h"
6 6
7 #include "base/mac/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "base/mac/sdk_forward_declarations.h" 8 #include "base/mac/sdk_forward_declarations.h"
9 #import "chrome/browser/ui/cocoa/image_button_cell.h" 9 #import "chrome/browser/ui/cocoa/image_button_cell.h"
10 #import "chrome/browser/ui/cocoa/view_id_util.h" 10 #import "chrome/browser/ui/cocoa/view_id_util.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 return gfx::VectorIconId::VECTOR_ICON_NONE; 224 return gfx::VectorIconId::VECTOR_ICON_NONE;
225 } 225 }
226 226
227 - (SkColor)vectorIconColor:(BOOL)themeIsDark { 227 - (SkColor)vectorIconColor:(BOOL)themeIsDark {
228 return themeIsDark ? SK_ColorWHITE : SkColorSetRGB(0x5A, 0x5A, 0x5A); 228 return themeIsDark ? SK_ColorWHITE : SkColorSetRGB(0x5A, 0x5A, 0x5A);
229 } 229 }
230 230
231 - (NSImage*)browserToolsIconForFillColor:(SkColor)fillColor { 231 - (NSImage*)browserToolsIconForFillColor:(SkColor)fillColor {
232 // Create a |BrowserToolsImageRep| to draw the browser tools icon using 232 // Create a |BrowserToolsImageRep| to draw the browser tools icon using
233 // the provided fill color. 233 // the provided fill color.
234 base::scoped_nsobject<BrowserToolsImageRep> imageRep = 234 base::scoped_nsobject<BrowserToolsImageRep> imageRep(
235 [[BrowserToolsImageRep alloc] 235 [[BrowserToolsImageRep alloc]
236 initWithDrawSelector:@selector(drawBrowserToolsIcon:) 236 initWithDrawSelector:@selector(drawBrowserToolsIcon:)
237 delegate:[BrowserToolsImageRep class]]; 237 delegate:[BrowserToolsImageRep class]]);
238 [imageRep setFillColor:skia::SkColorToCalibratedNSColor(fillColor)]; 238 [imageRep setFillColor:skia::SkColorToCalibratedNSColor(fillColor)];
239 239
240 // Create the image from the image rep. 240 // Create the image from the image rep.
241 NSImage* browserToolsIcon = 241 NSImage* browserToolsIcon =
242 [[[NSImage alloc] initWithSize:kMDButtonIconSize] autorelease]; 242 [[[NSImage alloc] initWithSize:kMDButtonIconSize] autorelease];
243 [browserToolsIcon setCacheMode:NSImageCacheAlways]; 243 [browserToolsIcon setCacheMode:NSImageCacheAlways];
244 [browserToolsIcon addRepresentation:imageRep]; 244 [browserToolsIcon addRepresentation:imageRep];
245 245
246 return browserToolsIcon; 246 return browserToolsIcon;
247 } 247 }
248 248
249 - (NSImage*)imageForIcon:(NSImage*)iconImage 249 - (NSImage*)imageForIcon:(NSImage*)iconImage
250 withBackgroundStyle:(ToolbarButtonImageBackgroundStyle)style { 250 withBackgroundStyle:(ToolbarButtonImageBackgroundStyle)style {
251 // Create a |ToolbarButtonImageRep| to draw the button image using 251 // Create a |ToolbarButtonImageRep| to draw the button image using
252 // the provided icon and background style. 252 // the provided icon and background style.
253 base::scoped_nsobject<ToolbarButtonImageRep> imageRep = 253 base::scoped_nsobject<ToolbarButtonImageRep> imageRep(
254 [[ToolbarButtonImageRep alloc] 254 [[ToolbarButtonImageRep alloc]
255 initWithDrawSelector:@selector(drawImage:) 255 initWithDrawSelector:@selector(drawImage:)
256 delegate:[ToolbarButtonImageRep class]]; 256 delegate:[ToolbarButtonImageRep class]]);
257 [imageRep setIcon:iconImage]; 257 [imageRep setIcon:iconImage];
258 [imageRep setStyle:style]; 258 [imageRep setStyle:style];
259 259
260 // Create the image from the image rep. 260 // Create the image from the image rep.
261 NSImage* image = 261 NSImage* image =
262 [[[NSImage alloc] initWithSize:kMDButtonBounds.size] autorelease]; 262 [[[NSImage alloc] initWithSize:kMDButtonBounds.size] autorelease];
263 [image setCacheMode:NSImageCacheAlways]; 263 [image setCacheMode:NSImageCacheAlways];
264 [image addRepresentation:imageRep]; 264 [image addRepresentation:imageRep];
265 265
266 return image; 266 return image;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Update the hover and pressed image backgrounds to match the current theme. 390 // Update the hover and pressed image backgrounds to match the current theme.
391 if (ui::MaterialDesignController::IsModeMaterial()) { 391 if (ui::MaterialDesignController::IsModeMaterial()) {
392 [self resetButtonStateImages]; 392 [self resetButtonStateImages];
393 } 393 }
394 } 394 }
395 395
396 - (void)windowDidChangeActive { 396 - (void)windowDidChangeActive {
397 } 397 }
398 398
399 @end 399 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698