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

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 489143002: [Mac] Add tab and keyboard navigation to the new avatar bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 const CGFloat kVerticalSpacing = 16.0; 78 const CGFloat kVerticalSpacing = 16.0;
79 const CGFloat kSmallVerticalSpacing = 10.0; 79 const CGFloat kSmallVerticalSpacing = 10.0;
80 const CGFloat kHorizontalSpacing = 16.0; 80 const CGFloat kHorizontalSpacing = 16.0;
81 const CGFloat kTitleFontSize = 15.0; 81 const CGFloat kTitleFontSize = 15.0;
82 const CGFloat kTextFontSize = 12.0; 82 const CGFloat kTextFontSize = 12.0;
83 const CGFloat kProfileButtonHeight = 30; 83 const CGFloat kProfileButtonHeight = 30;
84 const int kBezelThickness = 3; // Width of the bezel on an NSButton. 84 const int kBezelThickness = 3; // Width of the bezel on an NSButton.
85 const int kImageTitleSpacing = 10; 85 const int kImageTitleSpacing = 10;
86 const int kBlueButtonHeight = 30; 86 const int kBlueButtonHeight = 30;
87 const CGFloat kFocusRingLineWidth = 2;
87 88
88 // Fixed size for embedded sign in pages as defined in Gaia. 89 // Fixed size for embedded sign in pages as defined in Gaia.
89 const CGFloat kFixedGaiaViewWidth = 360; 90 const CGFloat kFixedGaiaViewWidth = 360;
90 const CGFloat kFixedGaiaViewHeight = 440; 91 const CGFloat kFixedGaiaViewHeight = 440;
91 92
92 // Fixed size for the account removal view. 93 // Fixed size for the account removal view.
93 const CGFloat kFixedAccountRemovalViewWidth = 280; 94 const CGFloat kFixedAccountRemovalViewWidth = 280;
94 95
95 // Fixed size for the switch user view. 96 // Fixed size for the switch user view.
96 const int kFixedSwitchUserViewWidth = 280; 97 const int kFixedSwitchUserViewWidth = 280;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 } 406 }
406 407
407 - (NSSize)cellSize { 408 - (NSSize)cellSize {
408 NSSize buttonSize = [super cellSize]; 409 NSSize buttonSize = [super cellSize];
409 buttonSize.width += leftMarginSpacing_; 410 buttonSize.width += leftMarginSpacing_;
410 if ([self imagePosition] == NSImageLeft) 411 if ([self imagePosition] == NSImageLeft)
411 buttonSize.width += imageTitleSpacing_; 412 buttonSize.width += imageTitleSpacing_;
412 return buttonSize; 413 return buttonSize;
413 } 414 }
414 415
416 - (NSFocusRingType)focusRingType {
417 // This is taken care of by the custom drawing code in the cell.
groby-ooo-7-16 2014/08/21 05:06:02 Isn't "in the cell" implicit?
noms (inactive) 2014/08/25 14:54:43 Done.
418 return NSFocusRingTypeNone;
419 }
420
421 - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView {
groby-ooo-7-16 2014/08/21 05:06:02 I'm still not entirely clear why the normal focus
noms (inactive) 2014/08/21 14:32:05 In the case of this control, the default focus rin
groby-ooo-7-16 2014/08/21 17:59:09 That's exceedingly odd. If I whip up a quick demo
noms (inactive) 2014/08/21 18:23:28 I think this is a HoverImageButton deal. From the
groby-ooo-7-16 2014/08/21 19:07:30 It's a CustomPaddingButtonCell deal :( -drawTitle:
noms (inactive) 2014/08/22 15:48:21 So doing this draws the image fine, but then there
422 [super drawInteriorWithFrame:frame inView:controlView];
423
424 // Focus ring.
425 if ([self showsFirstResponder]) {
groby-ooo-7-16 2014/08/21 05:06:02 You might want to leave a TODO to fix this with 10
noms (inactive) 2014/08/25 14:54:43 Done.
426 NSRect focusRingRect = NSInsetRect(frame,
427 kFocusRingLineWidth, kFocusRingLineWidth);
428 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set];
429 NSBezierPath* path = [NSBezierPath bezierPathWithRect:focusRingRect];
430 [path setLineWidth:kFocusRingLineWidth];
431 [path stroke];
432 }
433 }
434
415 @end 435 @end
416 436
417 // A custom button that has a transparent backround. 437 // A custom image view that has a transparent backround.
418 @interface TransparentBackgroundButton : NSButton 438 @interface TransparentBackgroundImageView : NSImageView
groby-ooo-7-16 2014/08/21 05:06:02 It's technically translucent, not transparent :)
noms (inactive) 2014/08/21 14:32:05 Still needed: the image is the size of the view, b
groby-ooo-7-16 2014/08/21 17:59:09 So the image has alpha, then? (Because otherwise,
noms (inactive) 2014/08/21 18:23:28 Yup, the image is just the center icon, and is tra
419 @end 439 @end
420 440
421 @implementation TransparentBackgroundButton 441 @implementation TransparentBackgroundImageView
422 - (id)initWithFrame:(NSRect)frameRect {
423 if ((self = [super initWithFrame:frameRect])) {
424 [self setBordered:NO];
425 [self setFont:[NSFont labelFontOfSize:kTextFontSize]];
426 [self setButtonType:NSMomentaryChangeButton];
427 }
428 return self;
429 }
430
431 - (void)drawRect:(NSRect)dirtyRect { 442 - (void)drawRect:(NSRect)dirtyRect {
432 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; 443 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f];
433 [backgroundColor setFill]; 444 [backgroundColor setFill];
434 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); 445 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop);
435 [super drawRect:dirtyRect]; 446 [super drawRect:dirtyRect];
436 } 447 }
437 @end 448 @end
438 449
450 @interface CustomCircleImageCell : NSButtonCell
451 @end
452
453 @implementation CustomCircleImageCell
454 - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView {
455 // Display everything as a circle that spans the entire control.
456 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:frame];
457 [path addClip];
458
459 [super drawImage:[self image] withFrame:frame inView:controlView];
460
461 // Focus ring.
462 if ([self showsFirstResponder]) {
463 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set];
464 [path setLineWidth:kFocusRingLineWidth];
465 [path stroke];
466 }
467 }
468 @end
469
439 // A custom image control that shows a "Change" button when moused over. 470 // A custom image control that shows a "Change" button when moused over.
440 @interface EditableProfilePhoto : NSImageView { 471 @interface EditableProfilePhoto : HoverImageButton {
441 @private 472 @private
442 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. 473 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController.
443 base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_; 474 base::scoped_nsobject<TransparentBackgroundImageView> changePhotoImage_;
444 // Used to display the "Change" button on hover.
445 ui::ScopedCrTrackingArea trackingArea_;
446 ProfileChooserController* controller_; 475 ProfileChooserController* controller_;
447 } 476 }
448 477
449 - (id)initWithFrame:(NSRect)frameRect 478 - (id)initWithFrame:(NSRect)frameRect
450 avatarMenu:(AvatarMenu*)avatarMenu 479 avatarMenu:(AvatarMenu*)avatarMenu
451 profileIcon:(const gfx::Image&)profileIcon 480 profileIcon:(const gfx::Image&)profileIcon
452 editingAllowed:(BOOL)editingAllowed 481 editingAllowed:(BOOL)editingAllowed
453 withController:(ProfileChooserController*)controller; 482 withController:(ProfileChooserController*)controller;
454 483
455 // Called when the "Change" button is clicked. 484 // Called when the "Change" button is clicked.
456 - (void)editPhoto:(id)sender; 485 - (void)editPhoto:(id)sender;
457 486
458 // When hovering over the profile photo, show the "Change" button.
459 - (void)mouseEntered:(NSEvent*)event;
460
461 // When hovering away from the profile photo, hide the "Change" button.
462 - (void)mouseExited:(NSEvent*)event;
463 @end
464
465 @interface EditableProfilePhoto (Private)
466 // Create the "Change" avatar photo button.
467 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect;
468 @end 487 @end
469 488
470 @implementation EditableProfilePhoto 489 @implementation EditableProfilePhoto
471 - (id)initWithFrame:(NSRect)frameRect 490 - (id)initWithFrame:(NSRect)frameRect
472 avatarMenu:(AvatarMenu*)avatarMenu 491 avatarMenu:(AvatarMenu*)avatarMenu
473 profileIcon:(const gfx::Image&)profileIcon 492 profileIcon:(const gfx::Image&)profileIcon
474 editingAllowed:(BOOL)editingAllowed 493 editingAllowed:(BOOL)editingAllowed
475 withController:(ProfileChooserController*)controller { 494 withController:(ProfileChooserController*)controller {
476 if ((self = [super initWithFrame:frameRect])) { 495 if ((self = [super initWithFrame:frameRect])) {
477 avatarMenu_ = avatarMenu; 496 avatarMenu_ = avatarMenu;
478 controller_ = controller; 497 controller_ = controller;
479 [self setImage:CreateProfileImage( 498
499 [self setBordered:NO];
500
501 base::scoped_nsobject<CustomCircleImageCell> cell(
502 [[CustomCircleImageCell alloc] init]);
503 [self setCell:cell.get()];
504
505 [self setDefaultImage:CreateProfileImage(
480 profileIcon, kLargeImageSide).ToNSImage()]; 506 profileIcon, kLargeImageSide).ToNSImage()];
481 507 [self setImagePosition:NSImageOnly];
482 // Add a tracking area so that we can show/hide the button when hovering.
483 trackingArea_.reset([[CrTrackingArea alloc]
484 initWithRect:[self bounds]
485 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
486 owner:self
487 userInfo:nil]);
488 [self addTrackingArea:trackingArea_.get()];
489 508
490 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); 509 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide);
491 if (editingAllowed) { 510 if (editingAllowed) {
492 changePhotoButton_.reset([self changePhotoButtonWithRect:bounds]); 511 [self setTarget:self];
493 [self addSubview:changePhotoButton_]; 512 [self setAction:@selector(editPhoto:)];
513 changePhotoImage_.reset([[TransparentBackgroundImageView alloc]
514 initWithFrame:bounds]);
515 [changePhotoImage_ setImage:ui::ResourceBundle::GetSharedInstance().
516 GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()];
517 [self addSubview:changePhotoImage_];
494 518
495 // Hide the button until the image is hovered over. 519 // Hide the image until the button is hovered over.
496 [changePhotoButton_ setHidden:YES]; 520 [changePhotoImage_ setHidden:YES];
497 } 521 }
498 522
499 // Set the image cell's accessibility strings to be the same as the 523 // Set the image cell's accessibility strings to be the same as the
500 // button's strings. 524 // button's strings.
501 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString( 525 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString(
502 editingAllowed ? 526 editingAllowed ?
503 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME : 527 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME :
504 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME) 528 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME)
505 forAttribute:NSAccessibilityTitleAttribute]; 529 forAttribute:NSAccessibilityTitleAttribute];
506 [[self cell] accessibilitySetOverrideValue: 530 [[self cell] accessibilitySetOverrideValue:
(...skipping 11 matching lines...) Expand all
518 forAttribute:NSAccessibilityTitleAttribute]; 542 forAttribute:NSAccessibilityTitleAttribute];
519 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole 543 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole
520 forAttribute:NSAccessibilityRoleAttribute]; 544 forAttribute:NSAccessibilityRoleAttribute];
521 [self accessibilitySetOverrideValue: 545 [self accessibilitySetOverrideValue:
522 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil) 546 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil)
523 forAttribute:NSAccessibilityRoleDescriptionAttribute]; 547 forAttribute:NSAccessibilityRoleDescriptionAttribute];
524 } 548 }
525 return self; 549 return self;
526 } 550 }
527 551
528 - (void)drawRect:(NSRect)dirtyRect {
529 NSRect bounds = [self bounds];
530
531 // Display the profile picture as a circle.
532 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:bounds];
533 [path addClip];
534 [self.image drawAtPoint:bounds.origin
535 fromRect:bounds
536 operation:NSCompositeSourceOver
537 fraction:1.0];
538
539 }
540
541 - (void)editPhoto:(id)sender { 552 - (void)editPhoto:(id)sender {
542 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); 553 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
543 [controller_ 554 [controller_
544 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; 555 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE];
545 } 556 }
546 557
547 - (void)mouseEntered:(NSEvent*)event { 558 - (void)setHoverState:(HoverState)state {
548 [changePhotoButton_ setHidden:NO]; 559 [super setHoverState:state];
549 } 560 [changePhotoImage_ setHidden:([self hoverState] == kHoverStateNone)];
550
551 - (void)mouseExited:(NSEvent*)event {
552 [changePhotoButton_ setHidden:YES];
553 }
554
555 // Make sure the element is focusable for accessibility.
556 - (BOOL)canBecomeKeyView {
557 return YES;
558 } 561 }
559 562
560 - (BOOL)accessibilityIsIgnored { 563 - (BOOL)accessibilityIsIgnored {
561 return NO; 564 return NO;
562 } 565 }
563 566
564 - (NSArray*)accessibilityActionNames { 567 - (NSArray*)accessibilityActionNames {
565 NSArray* parentActions = [super accessibilityActionNames]; 568 NSArray* parentActions = [super accessibilityActionNames];
566 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; 569 return [parentActions arrayByAddingObject:NSAccessibilityPressAction];
567 } 570 }
568 571
569 - (void)accessibilityPerformAction:(NSString*)action { 572 - (void)accessibilityPerformAction:(NSString*)action {
570 if ([action isEqualToString:NSAccessibilityPressAction]) { 573 if ([action isEqualToString:NSAccessibilityPressAction]) {
571 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); 574 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex());
572 } 575 }
573 576
574 [super accessibilityPerformAction:action]; 577 [super accessibilityPerformAction:action];
575 } 578 }
576 579
577 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect {
578 TransparentBackgroundButton* button =
579 [[TransparentBackgroundButton alloc] initWithFrame:rect];
580 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
581 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()];
582 [button setImagePosition:NSImageOnly];
583 [button setTarget:self];
584 [button setAction:@selector(editPhoto:)];
585 return button;
586 }
587 @end 580 @end
588 581
589 // A custom text control that turns into a textfield for editing when clicked. 582 // A custom text control that turns into a textfield for editing when clicked.
590 @interface EditableProfileNameButton : HoverImageButton { 583 @interface EditableProfileNameButton : HoverImageButton {
591 @private 584 @private
592 base::scoped_nsobject<NSTextField> profileNameTextField_; 585 base::scoped_nsobject<NSTextField> profileNameTextField_;
593 Profile* profile_; // Weak. 586 Profile* profile_; // Weak.
594 ProfileChooserController* controller_; 587 ProfileChooserController* controller_;
595 } 588 }
596 589
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 return self; 761 return self;
769 } 762 }
770 763
771 - (void)drawRect:(NSRect)dirtyRect { 764 - (void)drawRect:(NSRect)dirtyRect {
772 [backgroundColor_ setFill]; 765 [backgroundColor_ setFill];
773 NSRectFill(dirtyRect); 766 NSRectFill(dirtyRect);
774 [super drawRect:dirtyRect]; 767 [super drawRect:dirtyRect];
775 } 768 }
776 @end 769 @end
777 770
771 // A custom dummy button that is used to clear focus from the bubble's controls.
772 @interface DummyWindowFocusButton : NSButton
773 @end
774
775 @implementation DummyWindowFocusButton
776 // Ignore accessibility, as this is a placeholder button.
777 - (BOOL)accessibilityIsIgnored {
778 return YES;
779 }
780 - (id)accessibilityAttributeValue:(NSString*)attribute {
781 return @[];
782 }
783
784 @end
785
778 @interface ProfileChooserController () 786 @interface ProfileChooserController ()
779 // Builds the profile chooser view. 787 // Builds the profile chooser view.
780 - (NSView*)buildProfileChooserView; 788 - (NSView*)buildProfileChooserView;
781 789
782 // Builds a tutorial card with a title label using |titleMessage|, a content 790 // Builds a tutorial card with a title label using |titleMessage|, a content
783 // label using |contentMessage|, a link using |linkMessage|, and a button using 791 // label using |contentMessage|, a link using |linkMessage|, and a button using
784 // |buttonMessage|. If |stackButton| is YES, places the button above the link. 792 // |buttonMessage|. If |stackButton| is YES, places the button above the link.
785 // Otherwise places both on the same row with the link left aligned and button 793 // Otherwise places both on the same row with the link left aligned and button
786 // right aligned. On click, the link would execute |linkAction|, and the button 794 // right aligned. On click, the link would execute |linkAction|, and the button
787 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. 795 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|.
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: 1123 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
1116 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: 1124 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
1117 subView = [self buildProfileChooserView]; 1125 subView = [self buildProfileChooserView];
1118 break; 1126 break;
1119 } 1127 }
1120 1128
1121 // Clears tutorial mode for all non-profile-chooser views. 1129 // Clears tutorial mode for all non-profile-chooser views.
1122 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) 1130 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
1123 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 1131 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
1124 1132
1133 // Add a dummy, empty element so that we don't initially display any
1134 // focus rings.
1135 NSButton* dummyFocusButton =
noms (inactive) 2014/08/20 17:17:38 This is a giant hack. I don't know how to get arou
groby-ooo-7-16 2014/08/21 05:06:02 That's a really bad idea. If there is no focus at
noms (inactive) 2014/08/21 14:32:05 I don't have mocks for tabbing, but always showing
groby-ooo-7-16 2014/08/21 17:59:09 Isn't that pretty bad in terms of a11y? You have n
noms (inactive) 2014/08/21 18:23:28 Oh, no no no, it's not that bad. So when the bubbl
groby-ooo-7-16 2014/08/21 19:07:30 I'd assume the blue circle is an issue for everybo
noms (inactive) 2014/08/21 19:53:39 The blue circle is because the control is round. I
groby-ooo-7-16 2014/08/21 20:53:34 OK. So, [[self window] makeFirstResponder:nil];?
noms (inactive) 2014/08/21 21:25:25 That was my first try, but that still focuses the
1136 [[[DummyWindowFocusButton alloc] initWithFrame:NSZeroRect] autorelease];
1137 [subView addSubview:dummyFocusButton];
1138 [dummyFocusButton setNextKeyView:subView];
1139 [[self window] makeFirstResponder:dummyFocusButton];
1140
1125 [contentView addSubview:subView]; 1141 [contentView addSubview:subView];
1126 SetWindowSize([self window], 1142 SetWindowSize([self window],
1127 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); 1143 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame])));
1128 } 1144 }
1129 1145
1130 - (NSView*)buildProfileChooserView { 1146 - (NSView*)buildProfileChooserView {
1131 base::scoped_nsobject<NSView> container( 1147 base::scoped_nsobject<NSView> container(
1132 [[NSView alloc] initWithFrame:NSZeroRect]); 1148 [[NSView alloc] initWithFrame:NSZeroRect]);
1133 1149
1134 NSView* tutorialView = nil; 1150 NSView* tutorialView = nil;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 guestItem.active = true; 1646 guestItem.active = true;
1631 guestItem.name = base::SysNSStringToUTF16( 1647 guestItem.name = base::SysNSStringToUTF16(
1632 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME)); 1648 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME));
1633 1649
1634 return [self createCurrentProfileView:guestItem]; 1650 return [self createCurrentProfileView:guestItem];
1635 } 1651 }
1636 1652
1637 - (NSButton*)createOtherProfileView:(int)itemIndex { 1653 - (NSButton*)createOtherProfileView:(int)itemIndex {
1638 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex); 1654 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex);
1639 1655
1640 NSRect rect = NSMakeRect(0, 0, kFixedMenuWidth, kBlueButtonHeight); 1656 NSRect rect = NSMakeRect(
1657 0, 0, kFixedMenuWidth, kBlueButtonHeight + kSmallVerticalSpacing);
1641 base::scoped_nsobject<BackgroundColorHoverButton> profileButton( 1658 base::scoped_nsobject<BackgroundColorHoverButton> profileButton(
1642 [[BackgroundColorHoverButton alloc] 1659 [[BackgroundColorHoverButton alloc]
1643 initWithFrame:rect 1660 initWithFrame:rect
1644 imageTitleSpacing:kImageTitleSpacing 1661 imageTitleSpacing:kImageTitleSpacing
1645 backgroundColor:GetDialogBackgroundColor()]); 1662 backgroundColor:GetDialogBackgroundColor()]);
1646 [profileButton setTitle:base::SysUTF16ToNSString(item.name)]; 1663 [profileButton setTitle:base::SysUTF16ToNSString(item.name)];
1647 [profileButton setDefaultImage:CreateProfileImage( 1664 [profileButton setDefaultImage:CreateProfileImage(
1648 item.icon, kSmallImageSide).ToNSImage()]; 1665 item.icon, kSmallImageSide).ToNSImage()];
1649 [profileButton setImagePosition:NSImageLeft]; 1666 [profileButton setImagePosition:NSImageLeft];
1650 [profileButton setAlignment:NSLeftTextAlignment]; 1667 [profileButton setAlignment:NSLeftTextAlignment];
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 } 2136 }
2120 2137
2121 - (bool)shouldShowGoIncognito { 2138 - (bool)shouldShowGoIncognito {
2122 bool incognitoAvailable = 2139 bool incognitoAvailable =
2123 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2140 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2124 IncognitoModePrefs::DISABLED; 2141 IncognitoModePrefs::DISABLED;
2125 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2142 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2126 } 2143 }
2127 2144
2128 @end 2145 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698