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

Side by Side Diff: chrome/browser/ui/cocoa/browser/avatar_button_controller.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 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 | Annotate | Revision Log
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/browser/avatar_button_controller.h" 5 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h"
6 6
7 #include "base/strings/sys_string_conversions.h" 7 #include "base/strings/sys_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/command_updater.h" 10 #include "chrome/browser/command_updater.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } // namespace 91 } // namespace
92 92
93 //////////////////////////////////////////////////////////////////////////////// 93 ////////////////////////////////////////////////////////////////////////////////
94 94
95 @implementation AvatarButtonController 95 @implementation AvatarButtonController
96 96
97 - (id)initWithBrowser:(Browser*)browser { 97 - (id)initWithBrowser:(Browser*)browser {
98 if ((self = [super init])) { 98 if ((self = [super init])) {
99 browser_ = browser; 99 browser_ = browser;
100 100
101 scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:NSMakeRect( 101 base::scoped_nsobject<NSView> container(
102 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); 102 [[NSView alloc] initWithFrame:NSMakeRect(
103 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]);
103 [self setView:container]; 104 [self setView:container];
104 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect( 105 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect(
105 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]); 106 0, 0, profiles::kAvatarIconWidth, profiles::kAvatarIconHeight)]);
106 NSButtonCell* cell = [button_ cell]; 107 NSButtonCell* cell = [button_ cell];
107 [button_ setButtonType:NSMomentaryLightButton]; 108 [button_ setButtonType:NSMomentaryLightButton];
108 109
109 [button_ setImagePosition:NSImageOnly]; 110 [button_ setImagePosition:NSImageOnly];
110 [cell setImageScaling:NSImageScaleProportionallyDown]; 111 [cell setImageScaling:NSImageScaleProportionallyDown];
111 [cell setImagePosition:NSImageBelow]; 112 [cell setImagePosition:NSImageBelow];
112 113
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 [static_cast<BrowserWindowController*>(wc) 252 [static_cast<BrowserWindowController*>(wc)
252 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO]; 253 releaseBarVisibilityForOwner:self withAnimation:YES delay:NO];
253 } 254 }
254 menuController_ = nil; 255 menuController_ = nil;
255 } 256 }
256 257
257 // This will take in an original image and redraw it with a shadow. 258 // This will take in an original image and redraw it with a shadow.
258 - (NSImage*)compositeImageWithShadow:(NSImage*)image { 259 - (NSImage*)compositeImageWithShadow:(NSImage*)image {
259 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 260 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
260 261
261 scoped_nsobject<NSImage> destination( 262 base::scoped_nsobject<NSImage> destination(
262 [[NSImage alloc] initWithSize:[image size]]); 263 [[NSImage alloc] initWithSize:[image size]]);
263 264
264 NSRect destRect = NSZeroRect; 265 NSRect destRect = NSZeroRect;
265 destRect.size = [destination size]; 266 destRect.size = [destination size];
266 267
267 [destination lockFocus]; 268 [destination lockFocus];
268 269
269 scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); 270 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]);
270 [shadow.get() setShadowColor:[NSColor colorWithCalibratedWhite:0.0 271 [shadow.get() setShadowColor:[NSColor colorWithCalibratedWhite:0.0
271 alpha:0.75]]; 272 alpha:0.75]];
272 [shadow.get() setShadowOffset:NSMakeSize(0, 0)]; 273 [shadow.get() setShadowOffset:NSMakeSize(0, 0)];
273 [shadow.get() setShadowBlurRadius:3.0]; 274 [shadow.get() setShadowBlurRadius:3.0];
274 [shadow.get() set]; 275 [shadow.get() set];
275 276
276 [image drawInRect:destRect 277 [image drawInRect:destRect
277 fromRect:NSZeroRect 278 fromRect:NSZeroRect
278 operation:NSCompositeSourceOver 279 operation:NSCompositeSourceOver
279 fraction:1.0 280 fraction:1.0
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 [themeFrame _tileTitlebarAndRedisplay:YES]; 336 [themeFrame _tileTitlebarAndRedisplay:YES];
336 } 337 }
337 338
338 // Testing ///////////////////////////////////////////////////////////////////// 339 // Testing /////////////////////////////////////////////////////////////////////
339 340
340 - (AvatarMenuBubbleController*)menuController { 341 - (AvatarMenuBubbleController*)menuController {
341 return menuController_; 342 return menuController_;
342 } 343 }
343 344
344 @end 345 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698