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

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: Remove dependency 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 if (!ui::MaterialDesignController::IsModeMaterial()) { 238 if (!ui::MaterialDesignController::IsModeMaterial()) {
239 [imageRep setFillColor:skia::SkColorToCalibratedNSColor(fillColor)]; 239 [imageRep setFillColor:skia::SkColorToCalibratedNSColor(fillColor)];
240 } else { 240 } else {
241 [imageRep setFillColor:skia::SkColorToSRGBNSColor(fillColor)]; 241 [imageRep setFillColor:skia::SkColorToSRGBNSColor(fillColor)];
242 } 242 }
243 243
244 // Create the image from the image rep. 244 // Create the image from the image rep.
245 NSImage* browserToolsIcon = 245 NSImage* browserToolsIcon =
246 [[[NSImage alloc] initWithSize:kMDButtonIconSize] autorelease]; 246 [[[NSImage alloc] initWithSize:kMDButtonIconSize] autorelease];
247 [browserToolsIcon setCacheMode:NSImageCacheAlways]; 247 [browserToolsIcon setCacheMode:NSImageCacheAlways];
248 [browserToolsIcon addRepresentation:imageRep]; 248 [browserToolsIcon addRepresentation:imageRep];
249 249
250 return browserToolsIcon; 250 return browserToolsIcon;
251 } 251 }
252 252
253 - (NSImage*)imageForIcon:(NSImage*)iconImage 253 - (NSImage*)imageForIcon:(NSImage*)iconImage
254 withBackgroundStyle:(ToolbarButtonImageBackgroundStyle)style { 254 withBackgroundStyle:(ToolbarButtonImageBackgroundStyle)style {
255 // Create a |ToolbarButtonImageRep| to draw the button image using 255 // Create a |ToolbarButtonImageRep| to draw the button image using
256 // the provided icon and background style. 256 // the provided icon and background style.
257 base::scoped_nsobject<ToolbarButtonImageRep> imageRep = 257 base::scoped_nsobject<ToolbarButtonImageRep> imageRep(
258 [[ToolbarButtonImageRep alloc] 258 [[ToolbarButtonImageRep alloc]
259 initWithDrawSelector:@selector(drawImage:) 259 initWithDrawSelector:@selector(drawImage:)
260 delegate:[ToolbarButtonImageRep class]]; 260 delegate:[ToolbarButtonImageRep class]]);
261 [imageRep setIcon:iconImage]; 261 [imageRep setIcon:iconImage];
262 [imageRep setStyle:style]; 262 [imageRep setStyle:style];
263 263
264 // Create the image from the image rep. 264 // Create the image from the image rep.
265 NSImage* image = 265 NSImage* image =
266 [[[NSImage alloc] initWithSize:kMDButtonBounds.size] autorelease]; 266 [[[NSImage alloc] initWithSize:kMDButtonBounds.size] autorelease];
267 [image setCacheMode:NSImageCacheAlways]; 267 [image setCacheMode:NSImageCacheAlways];
268 [image addRepresentation:imageRep]; 268 [image addRepresentation:imageRep];
269 269
270 return image; 270 return image;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // Update the hover and pressed image backgrounds to match the current theme. 394 // Update the hover and pressed image backgrounds to match the current theme.
395 if (ui::MaterialDesignController::IsModeMaterial()) { 395 if (ui::MaterialDesignController::IsModeMaterial()) {
396 [self resetButtonStateImages]; 396 [self resetButtonStateImages];
397 } 397 }
398 } 398 }
399 399
400 - (void)windowDidChangeActive { 400 - (void)windowDidChangeActive {
401 } 401 }
402 402
403 @end 403 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_view.mm ('k') | components/bookmarks/browser/bookmark_pasteboard_helper_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698