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