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 = 320; | 98 const int kFixedSwitchUserViewWidth = 320; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 } | 397 } |
397 | 398 |
398 - (NSSize)cellSize { | 399 - (NSSize)cellSize { |
399 NSSize buttonSize = [super cellSize]; | 400 NSSize buttonSize = [super cellSize]; |
400 buttonSize.width += leftMarginSpacing_; | 401 buttonSize.width += leftMarginSpacing_; |
401 if ([self imagePosition] == NSImageLeft) | 402 if ([self imagePosition] == NSImageLeft) |
402 buttonSize.width += imageTitleSpacing_; | 403 buttonSize.width += imageTitleSpacing_; |
403 return buttonSize; | 404 return buttonSize; |
404 } | 405 } |
405 | 406 |
| 407 - (NSFocusRingType)focusRingType { |
| 408 // This is taken care of by the custom drawing code. |
| 409 return NSFocusRingTypeNone; |
| 410 } |
| 411 |
| 412 - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView { |
| 413 [super drawInteriorWithFrame:frame inView:controlView]; |
| 414 |
| 415 // Focus ring. |
| 416 if ([self showsFirstResponder]) { |
| 417 NSRect focusRingRect = |
| 418 NSInsetRect(frame, kFocusRingLineWidth, kFocusRingLineWidth); |
| 419 // TODO(noms): When we are targetting 10.7, we should change this to use |
| 420 // -drawFocusRingMaskWithFrame instead. |
| 421 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set]; |
| 422 NSBezierPath* path = [NSBezierPath bezierPathWithRect:focusRingRect]; |
| 423 [path setLineWidth:kFocusRingLineWidth]; |
| 424 [path stroke]; |
| 425 } |
| 426 } |
| 427 |
406 @end | 428 @end |
407 | 429 |
408 // A custom button that has a transparent backround. | 430 // A custom image view that has a transparent backround. |
409 @interface TransparentBackgroundButton : NSButton | 431 @interface TransparentBackgroundImageView : NSImageView |
410 @end | 432 @end |
411 | 433 |
412 @implementation TransparentBackgroundButton | 434 @implementation TransparentBackgroundImageView |
413 - (id)initWithFrame:(NSRect)frameRect { | |
414 if ((self = [super initWithFrame:frameRect])) { | |
415 [self setBordered:NO]; | |
416 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; | |
417 [self setButtonType:NSMomentaryChangeButton]; | |
418 } | |
419 return self; | |
420 } | |
421 | |
422 - (void)drawRect:(NSRect)dirtyRect { | 435 - (void)drawRect:(NSRect)dirtyRect { |
423 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; | 436 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; |
424 [backgroundColor setFill]; | 437 [backgroundColor setFill]; |
425 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); | 438 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); |
426 [super drawRect:dirtyRect]; | 439 [super drawRect:dirtyRect]; |
427 } | 440 } |
428 @end | 441 @end |
429 | 442 |
| 443 @interface CustomCircleImageCell : NSButtonCell |
| 444 @end |
| 445 |
| 446 @implementation CustomCircleImageCell |
| 447 - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView { |
| 448 // Display everything as a circle that spans the entire control. |
| 449 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:frame]; |
| 450 [path addClip]; |
| 451 |
| 452 [super drawImage:[self image] withFrame:frame inView:controlView]; |
| 453 |
| 454 // Focus ring. |
| 455 if ([self showsFirstResponder]) { |
| 456 [[[NSColor keyboardFocusIndicatorColor] colorWithAlphaComponent:1] set]; |
| 457 [path setLineWidth:kFocusRingLineWidth]; |
| 458 [path stroke]; |
| 459 } |
| 460 } |
| 461 @end |
| 462 |
430 // A custom image control that shows a "Change" button when moused over. | 463 // A custom image control that shows a "Change" button when moused over. |
431 @interface EditableProfilePhoto : NSImageView { | 464 @interface EditableProfilePhoto : HoverImageButton { |
432 @private | 465 @private |
433 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. | 466 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. |
434 base::scoped_nsobject<TransparentBackgroundButton> changePhotoButton_; | 467 base::scoped_nsobject<TransparentBackgroundImageView> changePhotoImage_; |
435 // Used to display the "Change" button on hover. | |
436 ui::ScopedCrTrackingArea trackingArea_; | |
437 ProfileChooserController* controller_; | 468 ProfileChooserController* controller_; |
438 } | 469 } |
439 | 470 |
440 - (id)initWithFrame:(NSRect)frameRect | 471 - (id)initWithFrame:(NSRect)frameRect |
441 avatarMenu:(AvatarMenu*)avatarMenu | 472 avatarMenu:(AvatarMenu*)avatarMenu |
442 profileIcon:(const gfx::Image&)profileIcon | 473 profileIcon:(const gfx::Image&)profileIcon |
443 editingAllowed:(BOOL)editingAllowed | 474 editingAllowed:(BOOL)editingAllowed |
444 withController:(ProfileChooserController*)controller; | 475 withController:(ProfileChooserController*)controller; |
445 | 476 |
446 // Called when the "Change" button is clicked. | 477 // Called when the "Change" button is clicked. |
447 - (void)editPhoto:(id)sender; | 478 - (void)editPhoto:(id)sender; |
448 | 479 |
449 // When hovering over the profile photo, show the "Change" button. | |
450 - (void)mouseEntered:(NSEvent*)event; | |
451 | |
452 // When hovering away from the profile photo, hide the "Change" button. | |
453 - (void)mouseExited:(NSEvent*)event; | |
454 @end | |
455 | |
456 @interface EditableProfilePhoto (Private) | |
457 // Create the "Change" avatar photo button. | |
458 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect; | |
459 @end | 480 @end |
460 | 481 |
461 @implementation EditableProfilePhoto | 482 @implementation EditableProfilePhoto |
462 - (id)initWithFrame:(NSRect)frameRect | 483 - (id)initWithFrame:(NSRect)frameRect |
463 avatarMenu:(AvatarMenu*)avatarMenu | 484 avatarMenu:(AvatarMenu*)avatarMenu |
464 profileIcon:(const gfx::Image&)profileIcon | 485 profileIcon:(const gfx::Image&)profileIcon |
465 editingAllowed:(BOOL)editingAllowed | 486 editingAllowed:(BOOL)editingAllowed |
466 withController:(ProfileChooserController*)controller { | 487 withController:(ProfileChooserController*)controller { |
467 if ((self = [super initWithFrame:frameRect])) { | 488 if ((self = [super initWithFrame:frameRect])) { |
468 avatarMenu_ = avatarMenu; | 489 avatarMenu_ = avatarMenu; |
469 controller_ = controller; | 490 controller_ = controller; |
470 [self setImage:CreateProfileImage( | 491 |
| 492 [self setBordered:NO]; |
| 493 |
| 494 base::scoped_nsobject<CustomCircleImageCell> cell( |
| 495 [[CustomCircleImageCell alloc] init]); |
| 496 [self setCell:cell.get()]; |
| 497 |
| 498 [self setDefaultImage:CreateProfileImage( |
471 profileIcon, kLargeImageSide).ToNSImage()]; | 499 profileIcon, kLargeImageSide).ToNSImage()]; |
472 | 500 [self setImagePosition:NSImageOnly]; |
473 // Add a tracking area so that we can show/hide the button when hovering. | |
474 trackingArea_.reset([[CrTrackingArea alloc] | |
475 initWithRect:[self bounds] | |
476 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways | |
477 owner:self | |
478 userInfo:nil]); | |
479 [self addTrackingArea:trackingArea_.get()]; | |
480 | 501 |
481 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); | 502 NSRect bounds = NSMakeRect(0, 0, kLargeImageSide, kLargeImageSide); |
482 if (editingAllowed) { | 503 if (editingAllowed) { |
483 changePhotoButton_.reset([self changePhotoButtonWithRect:bounds]); | 504 [self setTarget:self]; |
484 [self addSubview:changePhotoButton_]; | 505 [self setAction:@selector(editPhoto:)]; |
| 506 changePhotoImage_.reset([[TransparentBackgroundImageView alloc] |
| 507 initWithFrame:bounds]); |
| 508 [changePhotoImage_ setImage:ui::ResourceBundle::GetSharedInstance(). |
| 509 GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()]; |
| 510 [self addSubview:changePhotoImage_]; |
485 | 511 |
486 // Hide the button until the image is hovered over. | 512 // Hide the image until the button is hovered over. |
487 [changePhotoButton_ setHidden:YES]; | 513 [changePhotoImage_ setHidden:YES]; |
488 } | 514 } |
489 | 515 |
490 // Set the image cell's accessibility strings to be the same as the | 516 // Set the image cell's accessibility strings to be the same as the |
491 // button's strings. | 517 // button's strings. |
492 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString( | 518 [[self cell] accessibilitySetOverrideValue:l10n_util::GetNSString( |
493 editingAllowed ? | 519 editingAllowed ? |
494 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME : | 520 IDS_PROFILES_NEW_AVATAR_MENU_CHANGE_PHOTO_ACCESSIBLE_NAME : |
495 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME) | 521 IDS_PROFILES_NEW_AVATAR_MENU_PHOTO_ACCESSIBLE_NAME) |
496 forAttribute:NSAccessibilityTitleAttribute]; | 522 forAttribute:NSAccessibilityTitleAttribute]; |
497 [[self cell] accessibilitySetOverrideValue: | 523 [[self cell] accessibilitySetOverrideValue: |
(...skipping 11 matching lines...) Expand all Loading... |
509 forAttribute:NSAccessibilityTitleAttribute]; | 535 forAttribute:NSAccessibilityTitleAttribute]; |
510 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole | 536 [self accessibilitySetOverrideValue:NSAccessibilityButtonRole |
511 forAttribute:NSAccessibilityRoleAttribute]; | 537 forAttribute:NSAccessibilityRoleAttribute]; |
512 [self accessibilitySetOverrideValue: | 538 [self accessibilitySetOverrideValue: |
513 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil) | 539 NSAccessibilityRoleDescription(NSAccessibilityButtonRole, nil) |
514 forAttribute:NSAccessibilityRoleDescriptionAttribute]; | 540 forAttribute:NSAccessibilityRoleDescriptionAttribute]; |
515 } | 541 } |
516 return self; | 542 return self; |
517 } | 543 } |
518 | 544 |
519 - (void)drawRect:(NSRect)dirtyRect { | |
520 NSRect bounds = [self bounds]; | |
521 | |
522 // Display the profile picture as a circle. | |
523 NSBezierPath* path = [NSBezierPath bezierPathWithOvalInRect:bounds]; | |
524 [path addClip]; | |
525 [self.image drawAtPoint:bounds.origin | |
526 fromRect:bounds | |
527 operation:NSCompositeSourceOver | |
528 fraction:1.0]; | |
529 | |
530 } | |
531 | |
532 - (void)editPhoto:(id)sender { | 545 - (void)editPhoto:(id)sender { |
533 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 546 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
534 [controller_ | 547 [controller_ |
535 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; | 548 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE]; |
536 } | 549 } |
537 | 550 |
538 - (void)mouseEntered:(NSEvent*)event { | 551 - (void)setHoverState:(HoverState)state { |
539 [changePhotoButton_ setHidden:NO]; | 552 [super setHoverState:state]; |
540 } | 553 [changePhotoImage_ setHidden:([self hoverState] == kHoverStateNone)]; |
541 | |
542 - (void)mouseExited:(NSEvent*)event { | |
543 [changePhotoButton_ setHidden:YES]; | |
544 } | |
545 | |
546 // Make sure the element is focusable for accessibility. | |
547 - (BOOL)canBecomeKeyView { | |
548 return YES; | |
549 } | 554 } |
550 | 555 |
551 - (BOOL)accessibilityIsIgnored { | 556 - (BOOL)accessibilityIsIgnored { |
552 return NO; | 557 return NO; |
553 } | 558 } |
554 | 559 |
555 - (NSArray*)accessibilityActionNames { | 560 - (NSArray*)accessibilityActionNames { |
556 NSArray* parentActions = [super accessibilityActionNames]; | 561 NSArray* parentActions = [super accessibilityActionNames]; |
557 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; | 562 return [parentActions arrayByAddingObject:NSAccessibilityPressAction]; |
558 } | 563 } |
559 | 564 |
560 - (void)accessibilityPerformAction:(NSString*)action { | 565 - (void)accessibilityPerformAction:(NSString*)action { |
561 if ([action isEqualToString:NSAccessibilityPressAction]) { | 566 if ([action isEqualToString:NSAccessibilityPressAction]) { |
562 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); | 567 avatarMenu_->EditProfile(avatarMenu_->GetActiveProfileIndex()); |
563 } | 568 } |
564 | 569 |
565 [super accessibilityPerformAction:action]; | 570 [super accessibilityPerformAction:action]; |
566 } | 571 } |
567 | 572 |
568 - (TransparentBackgroundButton*)changePhotoButtonWithRect:(NSRect)rect { | |
569 TransparentBackgroundButton* button = | |
570 [[TransparentBackgroundButton alloc] initWithFrame:rect]; | |
571 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( | |
572 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()]; | |
573 [button setImagePosition:NSImageOnly]; | |
574 [button setTarget:self]; | |
575 [button setAction:@selector(editPhoto:)]; | |
576 return button; | |
577 } | |
578 @end | 573 @end |
579 | 574 |
580 // A custom text control that turns into a textfield for editing when clicked. | 575 // A custom text control that turns into a textfield for editing when clicked. |
581 @interface EditableProfileNameButton : HoverImageButton { | 576 @interface EditableProfileNameButton : HoverImageButton { |
582 @private | 577 @private |
583 base::scoped_nsobject<NSTextField> profileNameTextField_; | 578 base::scoped_nsobject<NSTextField> profileNameTextField_; |
584 Profile* profile_; // Weak. | 579 Profile* profile_; // Weak. |
585 ProfileChooserController* controller_; | 580 ProfileChooserController* controller_; |
586 } | 581 } |
587 | 582 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 return self; | 754 return self; |
760 } | 755 } |
761 | 756 |
762 - (void)drawRect:(NSRect)dirtyRect { | 757 - (void)drawRect:(NSRect)dirtyRect { |
763 [backgroundColor_ setFill]; | 758 [backgroundColor_ setFill]; |
764 NSRectFill(dirtyRect); | 759 NSRectFill(dirtyRect); |
765 [super drawRect:dirtyRect]; | 760 [super drawRect:dirtyRect]; |
766 } | 761 } |
767 @end | 762 @end |
768 | 763 |
| 764 // A custom dummy button that is used to clear focus from the bubble's controls. |
| 765 @interface DummyWindowFocusButton : NSButton |
| 766 @end |
| 767 |
| 768 @implementation DummyWindowFocusButton |
| 769 // Ignore accessibility, as this is a placeholder button. |
| 770 - (BOOL)accessibilityIsIgnored { |
| 771 return YES; |
| 772 } |
| 773 |
| 774 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 775 return @[]; |
| 776 } |
| 777 |
| 778 - (BOOL)canBecomeKeyView { |
| 779 return false; |
| 780 } |
| 781 |
| 782 @end |
| 783 |
769 @interface ProfileChooserController () | 784 @interface ProfileChooserController () |
770 // Builds the profile chooser view. | 785 // Builds the profile chooser view. |
771 - (NSView*)buildProfileChooserView; | 786 - (NSView*)buildProfileChooserView; |
772 | 787 |
773 // Builds a tutorial card with a title label using |titleMessage|, a content | 788 // Builds a tutorial card with a title label using |titleMessage|, a content |
774 // label using |contentMessage|, a link using |linkMessage|, and a button using | 789 // label using |contentMessage|, a link using |linkMessage|, and a button using |
775 // |buttonMessage|. If |stackButton| is YES, places the button above the link. | 790 // |buttonMessage|. If |stackButton| is YES, places the button above the link. |
776 // Otherwise places both on the same row with the link left aligned and button | 791 // Otherwise places both on the same row with the link left aligned and button |
777 // right aligned. On click, the link would execute |linkAction|, and the button | 792 // right aligned. On click, the link would execute |linkAction|, and the button |
778 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. | 793 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1128 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
1114 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1129 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
1115 subView = [self buildProfileChooserView]; | 1130 subView = [self buildProfileChooserView]; |
1116 break; | 1131 break; |
1117 } | 1132 } |
1118 | 1133 |
1119 // Clears tutorial mode for all non-profile-chooser views. | 1134 // Clears tutorial mode for all non-profile-chooser views. |
1120 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1135 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
1121 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1136 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1122 | 1137 |
| 1138 // Add a dummy, empty element so that we don't initially display any |
| 1139 // focus rings. |
| 1140 NSButton* dummyFocusButton = |
| 1141 [[[DummyWindowFocusButton alloc] initWithFrame:NSZeroRect] autorelease]; |
| 1142 [dummyFocusButton setNextKeyView:subView]; |
| 1143 [[self window] makeFirstResponder:dummyFocusButton]; |
| 1144 |
1123 [contentView addSubview:subView]; | 1145 [contentView addSubview:subView]; |
| 1146 [contentView addSubview:dummyFocusButton]; |
1124 SetWindowSize([self window], | 1147 SetWindowSize([self window], |
1125 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); | 1148 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); |
1126 } | 1149 } |
1127 | 1150 |
1128 - (NSView*)buildProfileChooserView { | 1151 - (NSView*)buildProfileChooserView { |
1129 base::scoped_nsobject<NSView> container( | 1152 base::scoped_nsobject<NSView> container( |
1130 [[NSView alloc] initWithFrame:NSZeroRect]); | 1153 [[NSView alloc] initWithFrame:NSZeroRect]); |
1131 | 1154 |
1132 NSView* tutorialView = nil; | 1155 NSView* tutorialView = nil; |
1133 NSView* currentProfileView = nil; | 1156 NSView* currentProfileView = nil; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1657 guestItem.active = true; | 1680 guestItem.active = true; |
1658 guestItem.name = base::SysNSStringToUTF16( | 1681 guestItem.name = base::SysNSStringToUTF16( |
1659 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME)); | 1682 l10n_util::GetNSString(IDS_PROFILES_GUEST_PROFILE_NAME)); |
1660 | 1683 |
1661 return [self createCurrentProfileView:guestItem]; | 1684 return [self createCurrentProfileView:guestItem]; |
1662 } | 1685 } |
1663 | 1686 |
1664 - (NSButton*)createOtherProfileView:(int)itemIndex { | 1687 - (NSButton*)createOtherProfileView:(int)itemIndex { |
1665 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex); | 1688 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(itemIndex); |
1666 | 1689 |
1667 NSRect rect = NSMakeRect(0, 0, kFixedMenuWidth, kBlueButtonHeight); | 1690 NSRect rect = NSMakeRect( |
| 1691 0, 0, kFixedMenuWidth, kBlueButtonHeight + kSmallVerticalSpacing); |
1668 base::scoped_nsobject<BackgroundColorHoverButton> profileButton( | 1692 base::scoped_nsobject<BackgroundColorHoverButton> profileButton( |
1669 [[BackgroundColorHoverButton alloc] | 1693 [[BackgroundColorHoverButton alloc] |
1670 initWithFrame:rect | 1694 initWithFrame:rect |
1671 imageTitleSpacing:kImageTitleSpacing | 1695 imageTitleSpacing:kImageTitleSpacing |
1672 backgroundColor:GetDialogBackgroundColor()]); | 1696 backgroundColor:GetDialogBackgroundColor()]); |
1673 [profileButton setTitle:base::SysUTF16ToNSString(item.name)]; | 1697 [profileButton setTitle:base::SysUTF16ToNSString(item.name)]; |
1674 [profileButton setDefaultImage:CreateProfileImage( | 1698 [profileButton setDefaultImage:CreateProfileImage( |
1675 item.icon, kSmallImageSide).ToNSImage()]; | 1699 item.icon, kSmallImageSide).ToNSImage()]; |
1676 [profileButton setImagePosition:NSImageLeft]; | 1700 [profileButton setImagePosition:NSImageLeft]; |
1677 [profileButton setAlignment:NSLeftTextAlignment]; | 1701 [profileButton setAlignment:NSLeftTextAlignment]; |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2154 } | 2178 } |
2155 | 2179 |
2156 - (bool)shouldShowGoIncognito { | 2180 - (bool)shouldShowGoIncognito { |
2157 bool incognitoAvailable = | 2181 bool incognitoAvailable = |
2158 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2182 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2159 IncognitoModePrefs::DISABLED; | 2183 IncognitoModePrefs::DISABLED; |
2160 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2184 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2161 } | 2185 } |
2162 | 2186 |
2163 @end | 2187 @end |
OLD | NEW |