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

Side by Side Diff: chrome/browser/ui/cocoa/browser/avatar_menu_bubble_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_menu_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 // Private ///////////////////////////////////////////////////////////////////// 105 // Private /////////////////////////////////////////////////////////////////////
106 106
107 - (id)initWithModel:(AvatarMenuModel*)model 107 - (id)initWithModel:(AvatarMenuModel*)model
108 parentWindow:(NSWindow*)parent 108 parentWindow:(NSWindow*)parent
109 anchoredAt:(NSPoint)point { 109 anchoredAt:(NSPoint)point {
110 // Use an arbitrary height because it will reflect the size of the content. 110 // Use an arbitrary height because it will reflect the size of the content.
111 NSRect contentRect = NSMakeRect(0, 0, kBubbleMinWidth, 150); 111 NSRect contentRect = NSMakeRect(0, 0, kBubbleMinWidth, 150);
112 // Create an empty window into which content is placed. 112 // Create an empty window into which content is placed.
113 scoped_nsobject<InfoBubbleWindow> window( 113 base::scoped_nsobject<InfoBubbleWindow> window(
114 [[InfoBubbleWindow alloc] initWithContentRect:contentRect 114 [[InfoBubbleWindow alloc] initWithContentRect:contentRect
115 styleMask:NSBorderlessWindowMask 115 styleMask:NSBorderlessWindowMask
116 backing:NSBackingStoreBuffered 116 backing:NSBackingStoreBuffered
117 defer:NO]); 117 defer:NO]);
118 if ((self = [super initWithWindow:window 118 if ((self = [super initWithWindow:window
119 parentWindow:parent 119 parentWindow:parent
120 anchoredAt:point])) { 120 anchoredAt:point])) {
121 model_.reset(model); 121 model_.reset(model);
122 122
123 [window accessibilitySetOverrideValue: 123 [window accessibilitySetOverrideValue:
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 items_.reset([[NSMutableArray alloc] init]); 295 items_.reset([[NSMutableArray alloc] init]);
296 [contentView setSubviews:[NSArray array]]; 296 [contentView setSubviews:[NSArray array]];
297 297
298 if (model_->GetManagedUserInformation().empty() || expanded_) 298 if (model_->GetManagedUserInformation().empty() || expanded_)
299 [self initMenuContents]; 299 [self initMenuContents];
300 else 300 else
301 [self initManagedUserContents]; 301 [self initManagedUserContents];
302 } 302 }
303 303
304 - (NSView*)configureManagedUserInformation:(CGFloat)width { 304 - (NSView*)configureManagedUserInformation:(CGFloat)width {
305 scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:NSZeroRect]); 305 base::scoped_nsobject<NSView> container(
306 [[NSView alloc] initWithFrame:NSZeroRect]);
306 307
307 // Add the limited user icon on the left side of the information TextView. 308 // Add the limited user icon on the left side of the information TextView.
308 scoped_nsobject<NSImageView> iconView( 309 base::scoped_nsobject<NSImageView> iconView(
309 [[NSImageView alloc] initWithFrame:NSMakeRect(5, 0, 16, 16)]); 310 [[NSImageView alloc] initWithFrame:NSMakeRect(5, 0, 16, 16)]);
310 [iconView setImage:model_->GetManagedUserIcon().ToNSImage()]; 311 [iconView setImage:model_->GetManagedUserIcon().ToNSImage()];
311 [container addSubview:iconView]; 312 [container addSubview:iconView];
312 313
313 NSString* info = 314 NSString* info =
314 base::SysUTF16ToNSString(model_->GetManagedUserInformation()); 315 base::SysUTF16ToNSString(model_->GetManagedUserInformation());
315 NSDictionary* attributes = 316 NSDictionary* attributes =
316 @{ NSFontAttributeName : [NSFont labelFontOfSize:12] }; 317 @{ NSFontAttributeName : [NSFont labelFontOfSize:12] };
317 scoped_nsobject<NSAttributedString> attrString( 318 base::scoped_nsobject<NSAttributedString> attrString(
318 [[NSAttributedString alloc] initWithString:info attributes:attributes]); 319 [[NSAttributedString alloc] initWithString:info attributes:attributes]);
319 scoped_nsobject<NSTextView> label( 320 base::scoped_nsobject<NSTextView> label(
320 [[NSTextView alloc] initWithFrame:NSMakeRect( 321 [[NSTextView alloc] initWithFrame:NSMakeRect(
321 kManagedUserSpacing, 0, width - kManagedUserSpacing - 5, 0)]); 322 kManagedUserSpacing, 0, width - kManagedUserSpacing - 5, 0)]);
322 [[label textStorage] setAttributedString:attrString]; 323 [[label textStorage] setAttributedString:attrString];
323 [label setHorizontallyResizable:NO]; 324 [label setHorizontallyResizable:NO];
324 [label setEditable:NO]; 325 [label setEditable:NO];
325 [label sizeToFit]; 326 [label sizeToFit];
326 [container addSubview:label]; 327 [container addSubview:label];
327 [container setFrameSize:NSMakeSize(width, NSHeight([label frame]))]; 328 [container setFrameSize:NSMakeSize(width, NSHeight([label frame]))];
328 329
329 // Reposition the limited user icon so that it is on top. 330 // Reposition the limited user icon so that it is on top.
330 [iconView setFrameOrigin:NSMakePoint(5, NSHeight([label frame]) - 16)]; 331 [iconView setFrameOrigin:NSMakePoint(5, NSHeight([label frame]) - 16)];
331 return container.autorelease(); 332 return container.autorelease();
332 } 333 }
333 334
334 - (NSButton*)configureNewUserButton:(CGFloat)yOffset 335 - (NSButton*)configureNewUserButton:(CGFloat)yOffset
335 updateWidthAdjust:(CGFloat*)widthAdjust { 336 updateWidthAdjust:(CGFloat*)widthAdjust {
336 scoped_nsobject<NSButton> newButton( 337 base::scoped_nsobject<NSButton> newButton([[NSButton alloc] initWithFrame:
337 [[NSButton alloc] initWithFrame:NSMakeRect( 338 NSMakeRect(kLabelInset, yOffset, kBubbleMinWidth - kLabelInset, 16)]);
338 kLabelInset, yOffset, kBubbleMinWidth - kLabelInset, 16)]); 339 base::scoped_nsobject<HyperlinkButtonCell> buttonCell(
339 scoped_nsobject<HyperlinkButtonCell> buttonCell(
340 [[HyperlinkButtonCell alloc] initTextCell: 340 [[HyperlinkButtonCell alloc] initTextCell:
341 l10n_util::GetNSString(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)]); 341 l10n_util::GetNSString(IDS_PROFILES_CREATE_NEW_PROFILE_LINK)]);
342 [newButton setCell:buttonCell.get()]; 342 [newButton setCell:buttonCell.get()];
343 [newButton setFont:[NSFont labelFontOfSize:12.0]]; 343 [newButton setFont:[NSFont labelFontOfSize:12.0]];
344 [newButton setBezelStyle:NSRegularSquareBezelStyle]; 344 [newButton setBezelStyle:NSRegularSquareBezelStyle];
345 [newButton setTarget:self]; 345 [newButton setTarget:self];
346 [newButton setAction:@selector(newProfile:)]; 346 [newButton setAction:@selector(newProfile:)];
347 NSSize delta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:newButton]; 347 NSSize delta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:newButton];
348 if (delta.width > 0) 348 if (delta.width > 0)
349 *widthAdjust = std::max(*widthAdjust, delta.width); 349 *widthAdjust = std::max(*widthAdjust, delta.width);
350 return newButton.autorelease(); 350 return newButton.autorelease();
351 } 351 }
352 352
353 - (NSButton*)configureSwitchUserButton:(CGFloat)yOffset 353 - (NSButton*)configureSwitchUserButton:(CGFloat)yOffset
354 updateWidthAdjust:(CGFloat*)widthAdjust { 354 updateWidthAdjust:(CGFloat*)widthAdjust {
355 scoped_nsobject<NSButton> newButton( 355 base::scoped_nsobject<NSButton> newButton(
356 [[NSButton alloc] initWithFrame:NSMakeRect( 356 [[NSButton alloc] initWithFrame:NSMakeRect(
357 kManagedUserSpacing, yOffset, kBubbleMinWidth - kLabelInset, 16)]); 357 kManagedUserSpacing, yOffset, kBubbleMinWidth - kLabelInset, 16)]);
358 scoped_nsobject<HyperlinkButtonCell> buttonCell( 358 base::scoped_nsobject<HyperlinkButtonCell> buttonCell(
359 [[HyperlinkButtonCell alloc] initTextCell: 359 [[HyperlinkButtonCell alloc] initTextCell:
360 l10n_util::GetNSString(IDS_PROFILES_SWITCH_PROFILE_LINK)]); 360 l10n_util::GetNSString(IDS_PROFILES_SWITCH_PROFILE_LINK)]);
361 [newButton setCell:buttonCell.get()]; 361 [newButton setCell:buttonCell.get()];
362 [newButton setFont:[NSFont labelFontOfSize:12.0]]; 362 [newButton setFont:[NSFont labelFontOfSize:12.0]];
363 [newButton setBezelStyle:NSRegularSquareBezelStyle]; 363 [newButton setBezelStyle:NSRegularSquareBezelStyle];
364 [newButton setTarget:self]; 364 [newButton setTarget:self];
365 [newButton setAction:@selector(switchProfile:)]; 365 [newButton setAction:@selector(switchProfile:)];
366 NSSize delta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:newButton]; 366 NSSize delta = [GTMUILocalizerAndLayoutTweaker sizeToFitView:newButton];
367 if (delta.width > 0) 367 if (delta.width > 0)
368 *widthAdjust = std::max(*widthAdjust, delta.width); 368 *widthAdjust = std::max(*widthAdjust, delta.width);
369 return newButton.autorelease(); 369 return newButton.autorelease();
370 } 370 }
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 - (BOOL)accessibilityIsIgnored { 690 - (BOOL)accessibilityIsIgnored {
691 return YES; 691 return YES;
692 } 692 }
693 @end 693 @end
694 694
695 @implementation AccessibilityIgnoredTextFieldCell 695 @implementation AccessibilityIgnoredTextFieldCell
696 - (BOOL)accessibilityIsIgnored { 696 - (BOOL)accessibilityIsIgnored {
697 return YES; 697 return YES;
698 } 698 }
699 @end 699 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698