OLD | NEW |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 const CGFloat kVerticalSpacing = 16.0; | 79 const CGFloat kVerticalSpacing = 16.0; |
80 const CGFloat kSmallVerticalSpacing = 10.0; | 80 const CGFloat kSmallVerticalSpacing = 10.0; |
81 const CGFloat kHorizontalSpacing = 16.0; | 81 const CGFloat kHorizontalSpacing = 16.0; |
82 const CGFloat kTitleFontSize = 15.0; | 82 const CGFloat kTitleFontSize = 15.0; |
83 const CGFloat kTextFontSize = 12.0; | 83 const CGFloat kTextFontSize = 12.0; |
84 const CGFloat kProfileButtonHeight = 30; | 84 const CGFloat kProfileButtonHeight = 30; |
85 const int kBezelThickness = 3; // Width of the bezel on an NSButton. | 85 const int kBezelThickness = 3; // Width of the bezel on an NSButton. |
86 const int kImageTitleSpacing = 10; | 86 const int kImageTitleSpacing = 10; |
87 const int kBlueButtonHeight = 30; | 87 const int kBlueButtonHeight = 30; |
| 88 const CGFloat kFocusRingLineWidth = 2; |
88 | 89 |
89 // Fixed size for embedded sign in pages as defined in Gaia. | 90 // Fixed size for embedded sign in pages as defined in Gaia. |
90 const CGFloat kFixedGaiaViewWidth = 360; | 91 const CGFloat kFixedGaiaViewWidth = 360; |
91 const CGFloat kFixedGaiaViewHeight = 440; | 92 const CGFloat kFixedGaiaViewHeight = 440; |
92 | 93 |
93 // Fixed size for the account removal view. | 94 // Fixed size for the account removal view. |
94 const CGFloat kFixedAccountRemovalViewWidth = 280; | 95 const CGFloat kFixedAccountRemovalViewWidth = 280; |
95 | 96 |
96 // Fixed size for the switch user view. | 97 // Fixed size for the switch user view. |
97 const int kFixedSwitchUserViewWidth = 280; | 98 const int kFixedSwitchUserViewWidth = 280; |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 404 } |
404 | 405 |
405 - (NSSize)cellSize { | 406 - (NSSize)cellSize { |
406 NSSize buttonSize = [super cellSize]; | 407 NSSize buttonSize = [super cellSize]; |
407 buttonSize.width += leftMarginSpacing_; | 408 buttonSize.width += leftMarginSpacing_; |
408 if ([self imagePosition] == NSImageLeft) | 409 if ([self imagePosition] == NSImageLeft) |
409 buttonSize.width += imageTitleSpacing_; | 410 buttonSize.width += imageTitleSpacing_; |
410 return buttonSize; | 411 return buttonSize; |
411 } | 412 } |
412 | 413 |
| 414 - (NSFocusRingType)focusRingType { |
| 415 // This is taken care of by the custom drawing code. |
| 416 return NSFocusRingTypeNone; |
| 417 } |
| 418 |
| 419 - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView { |
| 420 [super drawInteriorWithFrame:frame inView:controlView]; |
| 421 |
| 422 // Focus ring. |
| 423 if ([self showsFirstResponder]) { |
| 424 NSRect focusRingRect = |
| 425 NSInsetRect(frame, kFocusRingLineWidth, kFocusRingLineWidth); |
| 426 // TODO(noms): When we are targetting 10.7, we should change this to use |
| 427 // -drawFocusRingMaskWithFrame instead. |
| 428 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set]; |
| 429 NSBezierPath* path = [NSBezierPath bezierPathWithRect:focusRingRect]; |
| 430 [path setLineWidth:kFocusRingLineWidth]; |
| 431 [path stroke]; |
| 432 } |
| 433 } |
| 434 |
413 @end | 435 @end |
414 | 436 |
415 // A custom button that has a transparent backround. | 437 // A custom image view that has a transparent backround. |
416 @interface TransparentBackgroundButton : NSButton | 438 @interface TransparentBackgroundImageView : NSImageView |
417 @end | 439 @end |
418 | 440 |
419 @implementation TransparentBackgroundButton | 441 @implementation TransparentBackgroundImageView |
420 - (id)initWithFrame:(NSRect)frameRect { | |
421 if ((self = [super initWithFrame:frameRect])) { | |
422 [self setBordered:NO]; | |
423 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; | |
424 [self setButtonType:NSMomentaryChangeButton]; | |
425 } | |
426 return self; | |
427 } | |
428 | |
429 - (void)drawRect:(NSRect)dirtyRect { | 442 - (void)drawRect:(NSRect)dirtyRect { |
430 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; | 443 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; |
431 [backgroundColor setFill]; | 444 [backgroundColor setFill]; |
432 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); | 445 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); |
433 [super drawRect:dirtyRect]; | 446 [super drawRect:dirtyRect]; |
434 } | 447 } |
435 @end | 448 @end |
436 | 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 |
437 // 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. |
438 @interface EditableProfilePhoto : NSImageView { | 471 @interface EditableProfilePhoto : HoverImageButton { |
439 @private | 472 @private |
440 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. | 473 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. |
441 base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_; | 474 base::scoped_nsobject<TransparentBackgroundImageView> changePhotoImage_; |
442 // Used to display the "Change" button on hover. | |
443 ui::ScopedCrTrackingArea trackingArea_; | |
444 ProfileChooserController* controller_; | 475 ProfileChooserController* controller_; |
445 } | 476 } |
446 | 477 |
447 - (id)initWithFrame:(NSRect)frameRect | 478 - (id)initWithFrame:(NSRect)frameRect |
448 avatarMenu:(AvatarMenu*)avatarMenu | 479 avatarMenu:(AvatarMenu*)avatarMenu |
449 profileIcon:(const gfx::Image&)profileIcon | 480 profileIcon:(const gfx::Image&)profileIcon |
450 editingAllowed:(BOOL)editingAllowed | 481 editingAllowed:(BOOL)editingAllowed |
451 withController:(ProfileChooserController*)controller; | 482 withController:(ProfileChooserController*)controller; |
452 | 483 |
453 // Called when the "Change" button is clicked. | 484 // Called when the "Change" button is clicked. |
454 - (void)editPhoto:(id)sender; | 485 - (void)editPhoto:(id)sender; |
455 | 486 |
456 // When hovering over the profile photo, show the "Change" button. | |
457 - (void)mouseEntered:(NSEvent*)event; | |
458 | |
459 // When hovering away from the profile photo, hide the "Change" button. | |
460 - (void)mouseExited:(NSEvent*)event; | |
461 @end | |
462 | |
463 @interface EditableProfilePhoto (Private) | |
464 // Create the "Change" avatar photo button. | |
465 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect; | |
466 @end | 487 @end |
467 | 488 |
468 @implementation EditableProfilePhoto | 489 @implementation EditableProfilePhoto |
469 - (id)initWithFrame:(NSRect)frameRect | 490 - (id)initWithFrame:(NSRect)frameRect |
470 avatarMenu:(AvatarMenu*)avatarMenu | 491 avatarMenu:(AvatarMenu*)avatarMenu |
471 profileIcon:(const gfx::Image&)profileIcon | 492 profileIcon:(const gfx::Image&)profileIcon |
472 editingAllowed:(BOOL)editingAllowed | 493 editingAllowed:(BOOL)editingAllowed |
473 withController:(ProfileChooserController*)controller { | 494 withController:(ProfileChooserController*)controller { |
474 if ((self = [super initWithFrame:frameRect])) { | 495 if ((self = [super initWithFrame:frameRect])) { |
475 avatarMenu_ = avatarMenu; | 496 avatarMenu_ = avatarMenu; |
476 controller_ = controller; | 497 controller_ = controller; |
477 [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( |
478 profileIcon, kLargeImageSide).ToNSImage()]; | 506 profileIcon, kLargeImageSide).ToNSImage()]; |
479 | 507 [self setImagePosition:NSImageOnly]; |
480 // Add a tracking area so that we can show/hide the button when hovering. | |
481 trackingArea_.reset([[CrTrackingArea alloc] | |
482 initWithRect:[self bounds] | |
483 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | |
484 owner:self | |
485 userInfo:nil]); | |
486 [self addTrackingArea:trackingArea_.get()]; | |
487 | 508 |
488 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); | 509 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); |
489 if (editingAllowed) { | 510 if (editingAllowed) { |
490 changePhotoButton_.reset([self changePhotoButtonWithRect:bounds]); | 511 [self setTarget:self]; |
491 [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_]; |
492 | 518 |
493 // Hide the button until the image is hovered over. | 519 // Hide the image until the button is hovered over. |
494 [changePhotoButton_ setHidden:YES]; | 520 [changePhotoImage_ setHidden:YES]; |
495 } | 521 } |
496 | 522 |
497 // 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 |
498 // button's strings. | 524 // button's strings. |
499 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString( | 525 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString( |
500 editingAllowed ? | 526 editingAllowed ? |
501 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME : | 527 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME : |
502 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME) | 528 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME) |
503 forAttribute:NSAccessibilityTitleAttribute]; | 529 forAttribute:NSAccessibilityTitleAttribute]; |
504 [[self cell] accessibilitySetOverrideValue: | 530 [[self cell] accessibilitySetOverrideValue: |
(...skipping 11 matching lines...) Expand all Loading... |
516 forAttribute:NSAccessibilityTitleAttribute]; | 542 forAttribute:NSAccessibilityTitleAttribute]; |
517 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole | 543 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole |
518 forAttribute:NSAccessibilityRoleAttribute]; | 544 forAttribute:NSAccessibilityRoleAttribute]; |
519 [self accessibilitySetOverrideValue: | 545 [self accessibilitySetOverrideValue: |
520 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil) | 546 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil) |
521 forAttribute:NSAccessibilityRoleDescriptionAttribute]; | 547 forAttribute:NSAccessibilityRoleDescriptionAttribute]; |
522 } | 548 } |
523 return self; | 549 return self; |
524 } | 550 } |
525 | 551 |
526 - (void)drawRect:(NSRect)dirtyRect { | |
527 NSRect bounds = [self bounds]; | |
528 | |
529 // Display the profile picture as a circle. | |
530 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:bounds]; | |
531 [path addClip]; | |
532 [self.image drawAtPoint:bounds.origin | |
533 fromRect:bounds | |
534 operation:NSCompositeSourceOver | |
535 fraction:1.0]; | |
536 | |
537 } | |
538 | |
539 - (void)editPhoto:(id)sender { | 552 - (void)editPhoto:(id)sender { |
540 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 553 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
541 [controller_ | 554 [controller_ |
542 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; | 555 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; |
543 } | 556 } |
544 | 557 |
545 - (void)mouseEntered:(NSEvent*)event { | 558 - (void)setHoverState:(HoverState)state { |
546 [changePhotoButton_ setHidden:NO]; | 559 [super setHoverState:state]; |
547 } | 560 [changePhotoImage_ setHidden:([self hoverState] == kHoverStateNone)]; |
548 | |
549 - (void)mouseExited:(NSEvent*)event { | |
550 [changePhotoButton_ setHidden:YES]; | |
551 } | |
552 | |
553 // Make sure the element is focusable for accessibility. | |
554 - (BOOL)canBecomeKeyView { | |
555 return YES; | |
556 } | 561 } |
557 | 562 |
558 - (BOOL)accessibilityIsIgnored { | 563 - (BOOL)accessibilityIsIgnored { |
559 return NO; | 564 return NO; |
560 } | 565 } |
561 | 566 |
562 - (NSArray*)accessibilityActionNames { | 567 - (NSArray*)accessibilityActionNames { |
563 NSArray* parentActions = [super accessibilityActionNames]; | 568 NSArray* parentActions = [super accessibilityActionNames]; |
564 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; | 569 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; |
565 } | 570 } |
566 | 571 |
567 - (void)accessibilityPerformAction:(NSString*)action { | 572 - (void)accessibilityPerformAction:(NSString*)action { |
568 if ([action isEqualToString:NSAccessibilityPressAction]) { | 573 if ([action isEqualToString:NSAccessibilityPressAction]) { |
569 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 574 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
570 } | 575 } |
571 | 576 |
572 [super accessibilityPerformAction:action]; | 577 [super accessibilityPerformAction:action]; |
573 } | 578 } |
574 | 579 |
575 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect { | |
576 TransparentBackgroundButton* button = | |
577 [[TransparentBackgroundButton alloc] initWithFrame:rect]; | |
578 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | |
579 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()]; | |
580 [button setImagePosition:NSImageOnly]; | |
581 [button setTarget:self]; | |
582 [button setAction:@selector(editPhoto:)]; | |
583 return button; | |
584 } | |
585 @end | 580 @end |
586 | 581 |
587 // 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. |
588 @interface EditableProfileNameButton : HoverImageButton { | 583 @interface EditableProfileNameButton : HoverImageButton { |
589 @private | 584 @private |
590 base::scoped_nsobject<NSTextField> profileNameTextField_; | 585 base::scoped_nsobject<NSTextField> profileNameTextField_; |
591 Profile* profile_; // Weak. | 586 Profile* profile_; // Weak. |
592 ProfileChooserController* controller_; | 587 ProfileChooserController* controller_; |
593 } | 588 } |
594 | 589 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 return self; | 761 return self; |
767 } | 762 } |
768 | 763 |
769 - (void)drawRect:(NSRect)dirtyRect { | 764 - (void)drawRect:(NSRect)dirtyRect { |
770 [backgroundColor_ setFill]; | 765 [backgroundColor_ setFill]; |
771 NSRectFill(dirtyRect); | 766 NSRectFill(dirtyRect); |
772 [super drawRect:dirtyRect]; | 767 [super drawRect:dirtyRect]; |
773 } | 768 } |
774 @end | 769 @end |
775 | 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 |
| 781 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 782 return @[]; |
| 783 } |
| 784 |
| 785 - (BOOL)canBecomeKeyView { |
| 786 return false; |
| 787 } |
| 788 |
| 789 @end |
| 790 |
776 @interface ProfileChooserController () | 791 @interface ProfileChooserController () |
777 // Builds the profile chooser view. | 792 // Builds the profile chooser view. |
778 - (NSView*)buildProfileChooserView; | 793 - (NSView*)buildProfileChooserView; |
779 | 794 |
780 // Builds a tutorial card with a title label using |titleMessage|, a content | 795 // Builds a tutorial card with a title label using |titleMessage|, a content |
781 // label using |contentMessage|, a link using |linkMessage|, and a button using | 796 // label using |contentMessage|, a link using |linkMessage|, and a button using |
782 // |buttonMessage|. If |stackButton| is YES, places the button above the link. | 797 // |buttonMessage|. If |stackButton| is YES, places the button above the link. |
783 // Otherwise places both on the same row with the link left aligned and button | 798 // Otherwise places both on the same row with the link left aligned and button |
784 // right aligned. On click, the link would execute |linkAction|, and the button | 799 // right aligned. On click, the link would execute |linkAction|, and the button |
785 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. | 800 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1135 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
1121 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1136 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
1122 subView = [self buildProfileChooserView]; | 1137 subView = [self buildProfileChooserView]; |
1123 break; | 1138 break; |
1124 } | 1139 } |
1125 | 1140 |
1126 // Clears tutorial mode for all non-profile-chooser views. | 1141 // Clears tutorial mode for all non-profile-chooser views. |
1127 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1142 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
1128 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1143 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1129 | 1144 |
| 1145 // Add a dummy, empty element so that we don't initially display any |
| 1146 // focus rings. |
| 1147 NSButton* dummyFocusButton = |
| 1148 [[[DummyWindowFocusButton alloc] initWithFrame:NSZeroRect] autorelease]; |
| 1149 [dummyFocusButton setNextKeyView:subView]; |
| 1150 [[self window] makeFirstResponder:dummyFocusButton]; |
| 1151 |
1130 [contentView addSubview:subView]; | 1152 [contentView addSubview:subView]; |
| 1153 [contentView addSubview:dummyFocusButton]; |
1131 SetWindowSize([self window], | 1154 SetWindowSize([self window], |
1132 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); | 1155 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); |
1133 } | 1156 } |
1134 | 1157 |
1135 - (NSView*)buildProfileChooserView { | 1158 - (NSView*)buildProfileChooserView { |
1136 base::scoped_nsobject<NSView> container( | 1159 base::scoped_nsobject<NSView> container( |
1137 [[NSView alloc] initWithFrame:NSZeroRect]); | 1160 [[NSView alloc] initWithFrame:NSZeroRect]); |
1138 | 1161 |
1139 NSView* tutorialView = nil; | 1162 NSView* tutorialView = nil; |
1140 NSView* currentProfileView = nil; | 1163 NSView* currentProfileView = nil; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1664 guestItem.active = true; | 1687 guestItem.active = true; |
1665 guestItem.name = base::SysNSStringToUTF16( | 1688 guestItem.name = base::SysNSStringToUTF16( |
1666 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME)); | 1689 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME)); |
1667 | 1690 |
1668 return [self createCurrentProfileView:guestItem]; | 1691 return [self createCurrentProfileView:guestItem]; |
1669 } | 1692 } |
1670 | 1693 |
1671 - (NSButton*)createOtherProfileView:(int)itemIndex { | 1694 - (NSButton*)createOtherProfileView:(int)itemIndex { |
1672 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex); | 1695 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex); |
1673 | 1696 |
1674 NSRect rect = NSMakeRect(0, 0, kFixedMenuWidth, kBlueButtonHeight); | 1697 NSRect rect = NSMakeRect( |
| 1698 0, 0, kFixedMenuWidth, kBlueButtonHeight + kSmallVerticalSpacing); |
1675 base::scoped_nsobject<BackgroundColorHoverButton> profileButton( | 1699 base::scoped_nsobject<BackgroundColorHoverButton> profileButton( |
1676 [[BackgroundColorHoverButton alloc] | 1700 [[BackgroundColorHoverButton alloc] |
1677 initWithFrame:rect | 1701 initWithFrame:rect |
1678 imageTitleSpacing:kImageTitleSpacing | 1702 imageTitleSpacing:kImageTitleSpacing |
1679 backgroundColor:GetDialogBackgroundColor()]); | 1703 backgroundColor:GetDialogBackgroundColor()]); |
1680 [profileButton setTitle:base::SysUTF16ToNSString(item.name)]; | 1704 [profileButton setTitle:base::SysUTF16ToNSString(item.name)]; |
1681 [profileButton setDefaultImage:CreateProfileImage( | 1705 [profileButton setDefaultImage:CreateProfileImage( |
1682 item.icon, kSmallImageSide).ToNSImage()]; | 1706 item.icon, kSmallImageSide).ToNSImage()]; |
1683 [profileButton setImagePosition:NSImageLeft]; | 1707 [profileButton setImagePosition:NSImageLeft]; |
1684 [profileButton setAlignment:NSLeftTextAlignment]; | 1708 [profileButton setAlignment:NSLeftTextAlignment]; |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 } | 2185 } |
2162 | 2186 |
2163 - (bool)shouldShowGoIncognito { | 2187 - (bool)shouldShowGoIncognito { |
2164 bool incognitoAvailable = | 2188 bool incognitoAvailable = |
2165 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2189 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2166 IncognitoModePrefs::DISABLED; | 2190 IncognitoModePrefs::DISABLED; |
2167 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2191 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2168 } | 2192 } |
2169 | 2193 |
2170 @end | 2194 @end |
OLD | NEW |