| 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" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/first_run/first_run.h" |
| 15 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 17 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 17 #include "chrome/browser/profiles/avatar_menu.h" | 18 #include "chrome/browser/profiles/avatar_menu.h" |
| 18 #include "chrome/browser/profiles/avatar_menu_observer.h" | 19 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 20 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 20 #include "chrome/browser/profiles/profile_info_cache.h" | 21 #include "chrome/browser/profiles/profile_info_cache.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/profiles/profile_metrics.h" | 23 #include "chrome/browser/profiles/profile_metrics.h" |
| 23 #include "chrome/browser/profiles/profile_window.h" | 24 #include "chrome/browser/profiles/profile_window.h" |
| 24 #include "chrome/browser/profiles/profiles_state.h" | 25 #include "chrome/browser/profiles/profiles_state.h" |
| 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 26 #include "chrome/browser/signin/signin_header_helper.h" | 27 #include "chrome/browser/signin/signin_header_helper.h" |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/signin/signin_promo.h" | 29 #include "chrome/browser/signin/signin_promo.h" |
| 29 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" | 31 #include "chrome/browser/ui/browser_commands.h" |
| 31 #include "chrome/browser/ui/browser_dialogs.h" | 32 #include "chrome/browser/ui/browser_dialogs.h" |
| 32 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 33 #include "chrome/browser/ui/chrome_pages.h" | 34 #include "chrome/browser/ui/chrome_pages.h" |
| 34 #include "chrome/browser/ui/chrome_style.h" | 35 #include "chrome/browser/ui/chrome_style.h" |
| 36 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 37 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 35 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" | 38 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
| 36 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 39 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 37 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 40 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 38 #import "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" | 41 #import "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" |
| 39 #include "chrome/browser/ui/singleton_tabs.h" | 42 #include "chrome/browser/ui/singleton_tabs.h" |
| 40 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 41 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 42 #include "components/signin/core/common/profile_management_switches.h" | 45 #include "components/signin/core/common/profile_management_switches.h" |
| 43 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 46 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
| 44 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 47 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const int kBezelThickness = 3; // Width of the bezel on an NSButton. | 84 const int kBezelThickness = 3; // Width of the bezel on an NSButton. |
| 82 const int kImageTitleSpacing = 10; | 85 const int kImageTitleSpacing = 10; |
| 83 const int kBlueButtonHeight = 30; | 86 const int kBlueButtonHeight = 30; |
| 84 | 87 |
| 85 // Fixed size for embedded sign in pages as defined in Gaia. | 88 // Fixed size for embedded sign in pages as defined in Gaia. |
| 86 const CGFloat kFixedGaiaViewWidth = 360; | 89 const CGFloat kFixedGaiaViewWidth = 360; |
| 87 const CGFloat kFixedGaiaViewHeight = 400; | 90 const CGFloat kFixedGaiaViewHeight = 400; |
| 88 | 91 |
| 89 // Fixed size for the account removal view. | 92 // Fixed size for the account removal view. |
| 90 const CGFloat kFixedAccountRemovalViewWidth = 280; | 93 const CGFloat kFixedAccountRemovalViewWidth = 280; |
| 91 // Fixed size for the end-preview view. | 94 |
| 92 const int kFixedEndPreviewViewWidth = 280; | 95 // Fixed size for the switch user view. |
| 96 const int kFixedSwitchUserViewWidth = 280; |
| 93 | 97 |
| 94 // Maximum number of times to show the welcome tutorial in the profile avatar | 98 // Maximum number of times to show the welcome tutorial in the profile avatar |
| 95 // bubble. | 99 // bubble. |
| 96 const int kProfileAvatarTutorialShowMax = 1; | 100 const int kUpgradeWelcomeTutorialShowMax = 1; |
| 97 | 101 |
| 98 // The tag number for the primary account. | 102 // The tag number for the primary account. |
| 99 const int kPrimaryProfileTag = -1; | 103 const int kPrimaryProfileTag = -1; |
| 100 | 104 |
| 101 gfx::Image CreateProfileImage(const gfx::Image& icon, int imageSize) { | 105 gfx::Image CreateProfileImage(const gfx::Image& icon, int imageSize) { |
| 102 return profiles::GetSizedAvatarIcon( | 106 return profiles::GetSizedAvatarIcon( |
| 103 icon, true /* image is a square */, imageSize, imageSize); | 107 icon, true /* image is a square */, imageSize, imageSize); |
| 104 } | 108 } |
| 105 | 109 |
| 106 // Updates the window size and position. | 110 // Updates the window size and position. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Returns the native dialog background color. | 189 // Returns the native dialog background color. |
| 186 NSColor* GetDialogBackgroundColor() { | 190 NSColor* GetDialogBackgroundColor() { |
| 187 return gfx::SkColorToCalibratedNSColor( | 191 return gfx::SkColorToCalibratedNSColor( |
| 188 ui::NativeTheme::instance()->GetSystemColor( | 192 ui::NativeTheme::instance()->GetSystemColor( |
| 189 ui::NativeTheme::kColorId_DialogBackground)); | 193 ui::NativeTheme::kColorId_DialogBackground)); |
| 190 } | 194 } |
| 191 | 195 |
| 192 // Builds a title card with one back button right aligned and one label center | 196 // Builds a title card with one back button right aligned and one label center |
| 193 // aligned. | 197 // aligned. |
| 194 NSView* BuildTitleCard(NSRect frame_rect, | 198 NSView* BuildTitleCard(NSRect frame_rect, |
| 195 int message_id, | 199 NSString* message, |
| 196 id back_button_target, | 200 id back_button_target, |
| 197 SEL back_button_action) { | 201 SEL back_button_action) { |
| 198 base::scoped_nsobject<NSView> container( | 202 base::scoped_nsobject<NSView> container( |
| 199 [[NSView alloc] initWithFrame:frame_rect]); | 203 [[NSView alloc] initWithFrame:frame_rect]); |
| 200 | 204 |
| 201 base::scoped_nsobject<HoverImageButton> button( | 205 base::scoped_nsobject<HoverImageButton> button( |
| 202 [[HoverImageButton alloc] initWithFrame:frame_rect]); | 206 [[HoverImageButton alloc] initWithFrame:frame_rect]); |
| 203 [button setBordered:NO]; | 207 [button setBordered:NO]; |
| 204 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 208 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 205 [button setDefaultImage:rb->GetNativeImageNamed(IDR_BACK).ToNSImage()]; | 209 [button setDefaultImage:rb->GetNativeImageNamed(IDR_BACK).ToNSImage()]; |
| 206 [button setHoverImage:rb->GetNativeImageNamed(IDR_BACK_H).ToNSImage()]; | 210 [button setHoverImage:rb->GetNativeImageNamed(IDR_BACK_H).ToNSImage()]; |
| 207 [button setPressedImage:rb->GetNativeImageNamed(IDR_BACK_P).ToNSImage()]; | 211 [button setPressedImage:rb->GetNativeImageNamed(IDR_BACK_P).ToNSImage()]; |
| 208 [button setTarget:back_button_target]; | 212 [button setTarget:back_button_target]; |
| 209 [button setAction:back_button_action]; | 213 [button setAction:back_button_action]; |
| 210 [button setFrameSize:NSMakeSize(kProfileButtonHeight, kProfileButtonHeight)]; | 214 [button setFrameSize:NSMakeSize(kProfileButtonHeight, kProfileButtonHeight)]; |
| 211 [button setFrameOrigin:NSMakePoint(kHorizontalSpacing, 0)]; | 215 [button setFrameOrigin:NSMakePoint(kHorizontalSpacing, 0)]; |
| 212 | 216 |
| 213 NSTextField* title_label = | 217 NSTextField* title_label = |
| 214 BuildLabel(l10n_util::GetNSString(message_id), NSZeroPoint, | 218 BuildLabel(message, NSZeroPoint, GetDialogBackgroundColor(), nil); |
| 215 GetDialogBackgroundColor(), nil /* text_color */); | |
| 216 [title_label setAlignment:NSCenterTextAlignment]; | 219 [title_label setAlignment:NSCenterTextAlignment]; |
| 217 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | 220 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
| 218 [title_label sizeToFit]; | 221 [title_label sizeToFit]; |
| 219 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2; | 222 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2; |
| 220 CGFloat y_offset = | 223 CGFloat y_offset = |
| 221 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2; | 224 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2; |
| 222 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)]; | 225 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)]; |
| 223 | 226 |
| 224 [container addSubview:button]; | 227 [container addSubview:button]; |
| 225 [container addSubview:title_label]; | 228 [container addSubview:title_label]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 // OAuth2TokenService::Observer: | 285 // OAuth2TokenService::Observer: |
| 283 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { | 286 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE { |
| 284 // Tokens can only be added by adding an account through the inline flow, | 287 // Tokens can only be added by adding an account through the inline flow, |
| 285 // which is started from the account management view. Refresh it to show the | 288 // which is started from the account management view. Refresh it to show the |
| 286 // update. | 289 // update. |
| 287 profiles::BubbleViewMode viewMode = [controller_ viewMode]; | 290 profiles::BubbleViewMode viewMode = [controller_ viewMode]; |
| 288 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || | 291 if (viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || |
| 289 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 292 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 290 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 293 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 291 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { | 294 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
| 295 if (viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) |
| 296 [controller_ setTutorialMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN]; |
| 292 [controller_ initMenuContentsWithView: | 297 [controller_ initMenuContentsWithView: |
| 293 switches::IsEnableAccountConsistency() ? | 298 switches::IsEnableAccountConsistency() ? |
| 294 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 299 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
| 295 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 300 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
| 296 } | 301 } |
| 297 } | 302 } |
| 298 | 303 |
| 299 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { | 304 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE { |
| 300 // Tokens can only be removed from the account management view. Refresh it | 305 // Tokens can only be removed from the account management view. Refresh it |
| 301 // to show the update. | 306 // to show the update. |
| 302 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 307 if ([controller_ viewMode] == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
| 303 [controller_ initMenuContentsWithView: | 308 [controller_ initMenuContentsWithView: |
| 304 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 309 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
| 305 } | 310 } |
| 306 | 311 |
| 307 // AvatarMenuObserver: | 312 // AvatarMenuObserver: |
| 308 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { | 313 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { |
| 314 // Do not refresh the avatar menu if the user is on a signin related view. |
| 315 profiles::BubbleViewMode viewMode = [controller_ viewMode]; |
| 316 if (viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 317 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 318 viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
| 319 return; |
| 320 } |
| 321 |
| 309 // While the bubble is open, the avatar menu can only change from the | 322 // While the bubble is open, the avatar menu can only change from the |
| 310 // profile chooser view by modifying the current profile's photo or name. | 323 // profile chooser view by modifying the current profile's photo or name. |
| 311 [controller_ | 324 [controller_ |
| 312 initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 325 initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
| 313 } | 326 } |
| 314 | 327 |
| 315 // content::NotificationObserver: | 328 // content::NotificationObserver: |
| 316 virtual void Observe( | 329 virtual void Observe( |
| 317 int type, | 330 int type, |
| 318 const content::NotificationSource& source, | 331 const content::NotificationSource& source, |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 [backgroundColor_ setFill]; | 710 [backgroundColor_ setFill]; |
| 698 NSRectFill(dirtyRect); | 711 NSRectFill(dirtyRect); |
| 699 [super drawRect:dirtyRect]; | 712 [super drawRect:dirtyRect]; |
| 700 } | 713 } |
| 701 @end | 714 @end |
| 702 | 715 |
| 703 @interface ProfileChooserController () | 716 @interface ProfileChooserController () |
| 704 // Builds the profile chooser view. | 717 // Builds the profile chooser view. |
| 705 - (NSView*)buildProfileChooserView; | 718 - (NSView*)buildProfileChooserView; |
| 706 | 719 |
| 707 // Builds a tutorial card with a title label using |titleMessageId|, a content | 720 // Builds a tutorial card with a title label using |titleMessage|, a content |
| 708 // label using |contentMessageId|, and a bottom row with a right-aligned link | 721 // label using |contentMessage|, and a bottom row with a right-aligned link |
| 709 // using |linkMessageId|, and a left aligned button using |buttonMessageId|. | 722 // using |linkMessage|, and a left aligned button using |buttonMessage|. |
| 710 // On click, the link would execute |linkAction|, and the button would execute | 723 // On click, the link would execute |linkAction|, and the button would execute |
| 711 // |buttonAction|. It sets |tutorialMode_| to the given |mode|. | 724 // |buttonAction|. It sets |tutorialMode_| to the given |mode|. |
| 712 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode | 725 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
| 713 titleMessage:(int)titleMessageId | 726 titleMessage:(NSString*)titleMessage |
| 714 contentMessage:(int)contentMessageId | 727 contentMessage:(NSString*)contentMessage |
| 715 linkMessage:(int)linkMessageId | 728 linkMessage:(NSString*)linkMessage |
| 716 buttonMessage:(int)buttonMessageId | 729 buttonMessage:(NSString*)buttonMessage |
| 717 linkAction:(SEL)linkAction | 730 linkAction:(SEL)linkAction |
| 718 buttonAction:(SEL)buttonAction; | 731 buttonAction:(SEL)buttonAction; |
| 719 | 732 |
| 720 // Builds a a tutorial card for new profile management preview if needed. if | 733 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if |
| 721 // new profile management is not enabled yet, then it prompts the user to try | 734 // needed. |tutorial_shown| indicates if the tutorial has already been shown in |
| 722 // out the feature. Otherwise, it notifies the user that the feature has been | 735 // the previous active view. |avatar_item| refers to the current profile. |
| 723 // enabled if needed. | 736 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded; |
| 724 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item; | 737 |
| 738 // Builds a tutorial card to have the user confirm the last Chrome signin, |
| 739 // Chrome sync will be delayed until the user either dismisses the tutorial, or |
| 740 // configures sync through the "Settings" link. |
| 741 - (NSView*)buildSigninConfirmationView; |
| 725 | 742 |
| 726 // Creates the main profile card for the profile |item| at the top of | 743 // Creates the main profile card for the profile |item| at the top of |
| 727 // the bubble. | 744 // the bubble. |
| 728 - (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item; | 745 - (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item; |
| 729 | 746 |
| 730 // Creates the possible links for the main profile card with profile |item|. | 747 // Creates the possible links for the main profile card with profile |item|. |
| 731 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item | 748 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item |
| 732 rect:(NSRect)rect; | 749 rect:(NSRect)rect; |
| 733 | 750 |
| 734 // Creates the disclaimer text for supervised users, telling them that the | 751 // Creates the disclaimer text for supervised users, telling them that the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 751 | 768 |
| 752 // Creates the list of accounts for the active profile. | 769 // Creates the list of accounts for the active profile. |
| 753 - (NSView*)createAccountsListWithRect:(NSRect)rect; | 770 - (NSView*)createAccountsListWithRect:(NSRect)rect; |
| 754 | 771 |
| 755 // Creates the Gaia sign-in/add account view. | 772 // Creates the Gaia sign-in/add account view. |
| 756 - (NSView*)buildGaiaEmbeddedView; | 773 - (NSView*)buildGaiaEmbeddedView; |
| 757 | 774 |
| 758 // Creates the account removal view. | 775 // Creates the account removal view. |
| 759 - (NSView*)buildAccountRemovalView; | 776 - (NSView*)buildAccountRemovalView; |
| 760 | 777 |
| 761 // Creates the end-preview view. | 778 // Create a view that shows various options for an upgrade user who is not |
| 762 - (NSView*)buildEndPreviewView; | 779 // the same person as the currently signed in user. |
| 780 - (NSView*)buildSwitchUserView; |
| 763 | 781 |
| 764 // Creates a button with |text|, an icon given by |imageResourceId| and with | 782 // Creates a button with |text|, an icon given by |imageResourceId| and with |
| 765 // |action|. | 783 // |action|. |
| 766 - (NSButton*)hoverButtonWithRect:(NSRect)rect | 784 - (NSButton*)hoverButtonWithRect:(NSRect)rect |
| 767 text:(NSString*)text | 785 text:(NSString*)text |
| 768 imageResourceId:(int)imageResourceId | 786 imageResourceId:(int)imageResourceId |
| 769 action:(SEL)action; | 787 action:(SEL)action; |
| 770 | 788 |
| 771 // Creates a generic link button with |title| and an |action| positioned at | 789 // Creates a generic link button with |title| and an |action| positioned at |
| 772 // |frameOrigin|. | 790 // |frameOrigin|. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 783 reauthRequired:(BOOL)reauthRequired; | 801 reauthRequired:(BOOL)reauthRequired; |
| 784 | 802 |
| 785 - (bool)shouldShowGoIncognito; | 803 - (bool)shouldShowGoIncognito; |
| 786 @end | 804 @end |
| 787 | 805 |
| 788 @implementation ProfileChooserController | 806 @implementation ProfileChooserController |
| 789 - (profiles::BubbleViewMode) viewMode { | 807 - (profiles::BubbleViewMode) viewMode { |
| 790 return viewMode_; | 808 return viewMode_; |
| 791 } | 809 } |
| 792 | 810 |
| 811 - (void)setTutorialMode:(profiles::TutorialMode)tutorialMode { |
| 812 tutorialMode_ = tutorialMode; |
| 813 } |
| 814 |
| 793 - (IBAction)switchToProfile:(id)sender { | 815 - (IBAction)switchToProfile:(id)sender { |
| 794 // Check the event flags to see if a new window should be created. | 816 // Check the event flags to see if a new window should be created. |
| 795 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( | 817 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( |
| 796 [NSApp currentEvent]) == NEW_WINDOW; | 818 [NSApp currentEvent]) == NEW_WINDOW; |
| 797 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, | 819 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, |
| 798 ProfileMetrics::SWITCH_PROFILE_ICON); | 820 ProfileMetrics::SWITCH_PROFILE_ICON); |
| 799 } | 821 } |
| 800 | 822 |
| 801 - (IBAction)showUserManager:(id)sender { | 823 - (IBAction)showUserManager:(id)sender { |
| 802 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); | 824 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 - (IBAction)removeAccount:(id)sender { | 893 - (IBAction)removeAccount:(id)sender { |
| 872 DCHECK(!accountIdToRemove_.empty()); | 894 DCHECK(!accountIdToRemove_.empty()); |
| 873 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 895 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| 874 browser_->profile())->RevokeCredentials(accountIdToRemove_); | 896 browser_->profile())->RevokeCredentials(accountIdToRemove_); |
| 875 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; | 897 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; |
| 876 accountIdToRemove_.clear(); | 898 accountIdToRemove_.clear(); |
| 877 | 899 |
| 878 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 900 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
| 879 } | 901 } |
| 880 | 902 |
| 881 - (IBAction)openTutorialLearnMoreURL:(id)sender { | 903 - (IBAction)seeWhatsNew:(id)sender { |
| 882 ProfileMetrics::LogProfileUpgradeEnrollment( | 904 chrome::ShowUserManagerWithTutorial( |
| 883 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); | 905 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); |
| 884 // TODO(guohui): update |learnMoreUrl| once it is decided. | |
| 885 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); | |
| 886 chrome::NavigateParams params(browser_->profile(), learnMoreUrl, | |
| 887 content::PAGE_TRANSITION_LINK); | |
| 888 params.disposition = NEW_FOREGROUND_TAB; | |
| 889 chrome::Navigate(¶ms); | |
| 890 } | 906 } |
| 891 | 907 |
| 892 - (IBAction)enableNewProfileManagementPreview:(id)sender { | 908 - (IBAction)showSwitchUserView:(id)sender { |
| 893 ProfileMetrics::LogProfileUpgradeEnrollment( | 909 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_SWITCH_USER]; |
| 894 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); | |
| 895 profiles::EnableNewProfileManagementPreview(browser_->profile()); | |
| 896 } | 910 } |
| 897 | 911 |
| 898 - (IBAction)dismissTutorial:(id)sender { | 912 - (IBAction)configureSyncSettings:(id)sender { |
| 899 ProfileMetrics::LogProfileUpgradeEnrollment( | 913 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 900 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); | 914 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
| 901 // If the user manually dismissed the tutorial, never show it again by setting | 915 SyncConfirmationUIClosed(true); |
| 902 // the number of times shown to the maximum plus 1, so that later we could | 916 } |
| 903 // distinguish between the dismiss case and the case when the tutorial is | 917 |
| 904 // indeed shown for the maximum number of times. | 918 - (IBAction)syncSettingsConfirmed:(id)sender { |
| 905 browser_->profile()->GetPrefs()->SetInteger( | 919 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 906 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 920 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
| 921 SyncConfirmationUIClosed(false); |
| 907 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 922 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
| 908 } | 923 } |
| 909 | 924 |
| 910 - (IBAction)showSendFeedbackTutorial:(id)sender { | 925 - (IBAction)addPerson:(id)sender { |
| 911 ProfileMetrics::LogProfileUpgradeEnrollment( | 926 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
| 912 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); | 927 } |
| 913 tutorialMode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK; | 928 |
| 929 - (IBAction)disconnectProfile:(id)sender { |
| 930 chrome::ShowSettings(browser_); |
| 931 } |
| 932 |
| 933 - (IBAction)navigateBackFromSwitchUserView:(id)sender { |
| 914 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 934 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
| 915 } | 935 } |
| 916 | 936 |
| 917 - (IBAction)showEndPreviewView:(id)sender { | 937 - (void)windowWillClose:(NSNotification*)notification { |
| 918 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_END_PREVIEW]; | 938 if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
| 919 } | 939 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
| 940 SyncConfirmationUIClosed(false); |
| 941 } |
| 920 | 942 |
| 921 - (IBAction)sendFeedback:(id)sender { | 943 [super windowWillClose:notification]; |
| 922 chrome::OpenFeedbackDialog(browser_); | |
| 923 } | |
| 924 | |
| 925 - (IBAction)endPreviewAndRelaunch:(id)sender { | |
| 926 profiles::DisableNewProfileManagementPreview(browser_->profile()); | |
| 927 } | 944 } |
| 928 | 945 |
| 929 - (void)cleanUpEmbeddedViewContents { | 946 - (void)cleanUpEmbeddedViewContents { |
| 930 webContents_.reset(); | 947 webContents_.reset(); |
| 931 } | 948 } |
| 932 | 949 |
| 933 - (id)initWithBrowser:(Browser*)browser | 950 - (id)initWithBrowser:(Browser*)browser |
| 934 anchoredAt:(NSPoint)point | 951 anchoredAt:(NSPoint)point |
| 935 withMode:(profiles::BubbleViewMode)mode | 952 withMode:(profiles::BubbleViewMode)mode |
| 936 withServiceType:(signin::GAIAServiceType)serviceType { | 953 withServiceType:(signin::GAIAServiceType)serviceType { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 | 1008 |
| 992 switch (viewMode_) { | 1009 switch (viewMode_) { |
| 993 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 1010 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
| 994 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 1011 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
| 995 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: | 1012 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
| 996 subView = [self buildGaiaEmbeddedView]; | 1013 subView = [self buildGaiaEmbeddedView]; |
| 997 break; | 1014 break; |
| 998 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 1015 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
| 999 subView = [self buildAccountRemovalView]; | 1016 subView = [self buildAccountRemovalView]; |
| 1000 break; | 1017 break; |
| 1001 case profiles::BUBBLE_VIEW_MODE_END_PREVIEW: | 1018 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
| 1002 subView = [self buildEndPreviewView]; | 1019 subView = [self buildSwitchUserView]; |
| 1003 break; | 1020 break; |
| 1004 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1021 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
| 1005 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1022 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
| 1006 subView = [self buildProfileChooserView]; | 1023 subView = [self buildProfileChooserView]; |
| 1007 break; | 1024 break; |
| 1008 } | 1025 } |
| 1009 | 1026 |
| 1010 [contentView addSubview:subView]; | 1027 [contentView addSubview:subView]; |
| 1011 SetWindowSize([self window], | 1028 SetWindowSize([self window], |
| 1012 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); | 1029 NSMakeSize(NSWidth([subView frame]), NSHeight([subView frame]))); |
| 1013 } | 1030 } |
| 1014 | 1031 |
| 1015 - (NSView*)buildProfileChooserView { | 1032 - (NSView*)buildProfileChooserView { |
| 1016 base::scoped_nsobject<NSView> container( | 1033 base::scoped_nsobject<NSView> container( |
| 1017 [[NSView alloc] initWithFrame:NSZeroRect]); | 1034 [[NSView alloc] initWithFrame:NSZeroRect]); |
| 1018 | 1035 |
| 1019 NSView* tutorialView = nil; | 1036 NSView* tutorialView = nil; |
| 1020 NSView* currentProfileView = nil; | 1037 NSView* currentProfileView = nil; |
| 1021 base::scoped_nsobject<NSMutableArray> otherProfiles( | 1038 base::scoped_nsobject<NSMutableArray> otherProfiles( |
| 1022 [[NSMutableArray alloc] init]); | 1039 [[NSMutableArray alloc] init]); |
| 1023 // Local and guest profiles cannot lock their profile. | 1040 // Local and guest profiles cannot lock their profile. |
| 1024 bool enableLock = false; | 1041 bool enableLock = false; |
| 1025 // Store the most recently displayed tutorial mode | |
| 1026 profiles::TutorialMode lastTutorialMode = tutorialMode_; | |
| 1027 | 1042 |
| 1028 // Loop over the profiles in reverse, so that they are sorted by their | 1043 // Loop over the profiles in reverse, so that they are sorted by their |
| 1029 // y-coordinate, and separate them into active and "other" profiles. | 1044 // y-coordinate, and separate them into active and "other" profiles. |
| 1030 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { | 1045 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
| 1031 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); | 1046 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
| 1032 if (item.active) { | 1047 if (item.active) { |
| 1033 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1048 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
| 1034 tutorialView = [self buildPreviewTutorialIfNeeded:item]; | 1049 switch (tutorialMode_) { |
| 1050 case profiles::TUTORIAL_MODE_NONE: |
| 1051 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
| 1052 tutorialView = |
| 1053 [self buildWelcomeUpgradeTutorialViewIfNeeded]; |
| 1054 break; |
| 1055 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: |
| 1056 tutorialView = [self buildSigninConfirmationView]; |
| 1057 break; |
| 1058 case profiles::TUTORIAL_MODE_SHOW_ERROR: |
| 1059 // TODO(guohui): not implemented yet. |
| 1060 NOTREACHED(); |
| 1061 } |
| 1062 } |
| 1035 currentProfileView = [self createCurrentProfileView:item]; | 1063 currentProfileView = [self createCurrentProfileView:item]; |
| 1036 enableLock = switches::IsNewProfileManagement() && item.signed_in; | 1064 enableLock = switches::IsNewProfileManagement() && item.signed_in; |
| 1037 } else { | 1065 } else { |
| 1038 [otherProfiles addObject:[self createOtherProfileView:i]]; | 1066 [otherProfiles addObject:[self createOtherProfileView:i]]; |
| 1039 } | 1067 } |
| 1040 } | 1068 } |
| 1041 if (!currentProfileView) // Guest windows don't have an active profile. | 1069 if (!currentProfileView) // Guest windows don't have an active profile. |
| 1042 currentProfileView = [self createGuestProfileView]; | 1070 currentProfileView = [self createGuestProfileView]; |
| 1043 | 1071 |
| 1044 // |yOffset| is the next position at which to draw in |container| | 1072 // |yOffset| is the next position at which to draw in |container| |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 yOffset += kVerticalSpacing; | 1133 yOffset += kVerticalSpacing; |
| 1106 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1134 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1107 [container addSubview:currentProfileView]; | 1135 [container addSubview:currentProfileView]; |
| 1108 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1136 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
| 1109 } | 1137 } |
| 1110 | 1138 |
| 1111 if (tutorialView) { | 1139 if (tutorialView) { |
| 1112 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1140 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
| 1113 [container addSubview:tutorialView]; | 1141 [container addSubview:tutorialView]; |
| 1114 yOffset = NSMaxY([tutorialView frame]); | 1142 yOffset = NSMaxY([tutorialView frame]); |
| 1115 if (!switches::IsEnableAccountConsistency() && | 1143 //TODO(mlerman): update UMA stats for the new tutorials. |
| 1116 tutorialMode_ != lastTutorialMode) { | |
| 1117 ProfileMetrics::LogProfileUpgradeEnrollment( | |
| 1118 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO); | |
| 1119 } | |
| 1120 } else { | 1144 } else { |
| 1121 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1145 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
| 1122 } | 1146 } |
| 1123 | 1147 |
| 1124 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1148 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| 1125 return container.autorelease(); | 1149 return container.autorelease(); |
| 1126 } | 1150 } |
| 1127 | 1151 |
| 1128 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { | 1152 - (NSView*)buildSigninConfirmationView { |
| 1129 if (!switches::IsEnableAccountConsistency()) { | 1153 NSString* titleMessage = l10n_util::GetNSString( |
| 1130 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_ENABLE_PREVIEW | 1154 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE); |
| 1131 titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE | 1155 NSString* contentMessage = l10n_util::GetNSString( |
| 1132 contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT | 1156 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT); |
| 1133 linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE | 1157 NSString* linkMessage = l10n_util::GetNSString( |
| 1134 buttonMessage:IDS_PROFILES_TUTORIAL_TRY_BUTTON | 1158 IDS_PROFILES_SYNC_SETTINGS_LINK); |
| 1135 linkAction:@selector(openTutorialLearnMoreURL:) | 1159 NSString* buttonMessage = l10n_util::GetNSString( |
| 1136 buttonAction: | 1160 IDS_PROFILES_TUTORIAL_OK_BUTTON); |
| 1137 @selector(enableNewProfileManagementPreview:)]; | 1161 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN |
| 1162 titleMessage:titleMessage |
| 1163 contentMessage:contentMessage |
| 1164 linkMessage:linkMessage |
| 1165 buttonMessage:buttonMessage |
| 1166 linkAction:@selector(configureSyncSettings:) |
| 1167 buttonAction:@selector(syncSettingsConfirmed:)]; |
| 1168 } |
| 1169 |
| 1170 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { |
| 1171 if (first_run::IsChromeFirstRun()) |
| 1172 return nil; |
| 1173 |
| 1174 Profile* profile = browser_->profile(); |
| 1175 const AvatarMenu::Item& avatarItem = |
| 1176 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
| 1177 if (!avatarItem.signed_in) { |
| 1178 profile->GetPrefs()->SetInteger( |
| 1179 prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1); |
| 1180 return nil; |
| 1138 } | 1181 } |
| 1139 | 1182 |
| 1140 if (!switches::IsNewProfileManagementPreviewEnabled()) | |
| 1141 return nil; | |
| 1142 | |
| 1143 if (tutorialMode_ == profiles::TUTORIAL_MODE_SEND_FEEDBACK) { | |
| 1144 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_SEND_FEEDBACK | |
| 1145 titleMessage:IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE | |
| 1146 contentMessage: | |
| 1147 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT | |
| 1148 linkMessage:IDS_PROFILES_END_PREVIEW | |
| 1149 buttonMessage:IDS_PROFILES_SEND_FEEDBACK_BUTTON | |
| 1150 linkAction:@selector(showEndPreviewView:) | |
| 1151 buttonAction:@selector(sendFeedback:)]; | |
| 1152 } | |
| 1153 | |
| 1154 Profile* profile = browser_->profile(); | |
| 1155 const int showCount = profile->GetPrefs()->GetInteger( | 1183 const int showCount = profile->GetPrefs()->GetInteger( |
| 1156 prefs::kProfileAvatarTutorialShown); | 1184 prefs::kProfileAvatarTutorialShown); |
| 1157 // Do not show the tutorial if user has dismissed it. | 1185 // Do not show the tutorial if user has dismissed it. |
| 1158 if (showCount > kProfileAvatarTutorialShowMax) | 1186 if (showCount > kUpgradeWelcomeTutorialShowMax) |
| 1159 return nil; | 1187 return nil; |
| 1160 | 1188 |
| 1161 if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME) { | 1189 if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { |
| 1162 if (showCount == kProfileAvatarTutorialShowMax) | 1190 if (showCount == kUpgradeWelcomeTutorialShowMax) |
| 1163 return nil; | 1191 return nil; |
| 1164 profile->GetPrefs()->SetInteger( | 1192 profile->GetPrefs()->SetInteger( |
| 1165 prefs::kProfileAvatarTutorialShown, showCount + 1); | 1193 prefs::kProfileAvatarTutorialShown, showCount + 1); |
| 1166 } | 1194 } |
| 1167 | 1195 |
| 1168 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME | 1196 NSString* titleMessage = l10n_util::GetNSStringF( |
| 1169 titleMessage:IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE | 1197 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name); |
| 1170 contentMessage: | 1198 NSString* contentMessage = l10n_util::GetNSString( |
| 1171 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT | 1199 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); |
| 1172 linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE | 1200 NSString* linkMessage = l10n_util::GetNSStringF( |
| 1173 buttonMessage:IDS_PROFILES_TUTORIAL_OK_BUTTON | 1201 IDS_PROFILES_NOT_YOU, avatarItem.name); |
| 1174 linkAction:@selector(openTutorialLearnMoreURL:) | 1202 NSString* buttonMessage = l10n_util::GetNSString( |
| 1175 buttonAction:@selector(dismissTutorial:)]; | 1203 IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); |
| 1204 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE |
| 1205 titleMessage:titleMessage |
| 1206 contentMessage:contentMessage |
| 1207 linkMessage:linkMessage |
| 1208 buttonMessage:buttonMessage |
| 1209 linkAction:@selector(showSwitchUserView:) |
| 1210 buttonAction:@selector(seeWhatsNew:)]; |
| 1176 } | 1211 } |
| 1177 | 1212 |
| 1178 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode | 1213 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
| 1179 titleMessage:(int)titleMessageId | 1214 titleMessage:(NSString*)titleMessage |
| 1180 contentMessage:(int)contentMessageId | 1215 contentMessage:(NSString*)contentMessage |
| 1181 linkMessage:(int)linkMessageId | 1216 linkMessage:(NSString*)linkMessage |
| 1182 buttonMessage:(int)buttonMessageId | 1217 buttonMessage:(NSString*)buttonMessage |
| 1183 linkAction:(SEL)linkAction | 1218 linkAction:(SEL)linkAction |
| 1184 buttonAction:(SEL)buttonAction { | 1219 buttonAction:(SEL)buttonAction { |
| 1185 // No promotion to Enable Accounst Consistency. | |
| 1186 if (mode == profiles::TUTORIAL_MODE_ENABLE_PREVIEW) | |
| 1187 return nil; | |
| 1188 | |
| 1189 tutorialMode_ = mode; | 1220 tutorialMode_ = mode; |
| 1190 | 1221 |
| 1191 NSColor* tutorialBackgroundColor = | 1222 NSColor* tutorialBackgroundColor = |
| 1192 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialBackgroundColor); | 1223 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialBackgroundColor); |
| 1193 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] | 1224 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] |
| 1194 initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0) | 1225 initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0) |
| 1195 withColor:tutorialBackgroundColor]); | 1226 withColor:tutorialBackgroundColor]); |
| 1196 CGFloat availableWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; | 1227 CGFloat availableWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; |
| 1197 CGFloat yOffset = kSmallVerticalSpacing; | 1228 CGFloat yOffset = kSmallVerticalSpacing; |
| 1198 | 1229 |
| 1199 // Adds links and buttons at the bottom. | 1230 // Adds links and buttons at the bottom. |
| 1200 base::scoped_nsobject<NSButton> tutorialOkButton([[HoverButton alloc] | 1231 base::scoped_nsobject<NSButton> tutorialOkButton([[HoverButton alloc] |
| 1201 initWithFrame:NSZeroRect]); | 1232 initWithFrame:NSZeroRect]); |
| 1202 [tutorialOkButton setTitle:l10n_util::GetNSString( | 1233 [tutorialOkButton setTitle:buttonMessage]; |
| 1203 buttonMessageId)]; | |
| 1204 [tutorialOkButton setBezelStyle:NSRoundedBezelStyle]; | 1234 [tutorialOkButton setBezelStyle:NSRoundedBezelStyle]; |
| 1205 [tutorialOkButton setTarget:self]; | 1235 [tutorialOkButton setTarget:self]; |
| 1206 [tutorialOkButton setAction:buttonAction]; | 1236 [tutorialOkButton setAction:buttonAction]; |
| 1207 [tutorialOkButton sizeToFit]; | 1237 [tutorialOkButton sizeToFit]; |
| 1208 NSSize buttonSize = [tutorialOkButton frame].size; | 1238 NSSize buttonSize = [tutorialOkButton frame].size; |
| 1209 const CGFloat kTopBottomTextPadding = 6; | 1239 const CGFloat kTopBottomTextPadding = 6; |
| 1210 const CGFloat kLeftRightTextPadding = 15; | 1240 const CGFloat kLeftRightTextPadding = 15; |
| 1211 buttonSize.width += 2 * kLeftRightTextPadding; | 1241 buttonSize.width += 2 * kLeftRightTextPadding; |
| 1212 buttonSize.height += 2 * kTopBottomTextPadding; | 1242 buttonSize.height += 2 * kTopBottomTextPadding; |
| 1213 [tutorialOkButton setFrameSize:buttonSize]; | 1243 [tutorialOkButton setFrameSize:buttonSize]; |
| 1214 [tutorialOkButton setAlignment:NSCenterTextAlignment]; | 1244 [tutorialOkButton setAlignment:NSCenterTextAlignment]; |
| 1215 [tutorialOkButton setFrameOrigin:NSMakePoint( | 1245 [tutorialOkButton setFrameOrigin:NSMakePoint( |
| 1216 kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing, | 1246 kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing, |
| 1217 yOffset)]; | 1247 yOffset)]; |
| 1218 [container addSubview:tutorialOkButton]; | 1248 [container addSubview:tutorialOkButton]; |
| 1219 | 1249 |
| 1220 NSButton* learnMoreLink = | 1250 NSButton* learnMoreLink = |
| 1221 [self linkButtonWithTitle:l10n_util::GetNSString(linkMessageId) | 1251 [self linkButtonWithTitle:linkMessage |
| 1222 frameOrigin:NSZeroPoint | 1252 frameOrigin:NSZeroPoint |
| 1223 action:linkAction]; | 1253 action:linkAction]; |
| 1224 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; | 1254 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; |
| 1225 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - | 1255 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - |
| 1226 NSHeight([learnMoreLink frame])) / 2; | 1256 NSHeight([learnMoreLink frame])) / 2; |
| 1227 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; | 1257 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; |
| 1228 [container addSubview:learnMoreLink]; | 1258 [container addSubview:learnMoreLink]; |
| 1229 | 1259 |
| 1230 yOffset = std::max(NSMaxY([learnMoreLink frame]), | 1260 yOffset = std::max(NSMaxY([learnMoreLink frame]), |
| 1231 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; | 1261 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; |
| 1232 | 1262 |
| 1233 // Adds body content. | 1263 // Adds body content. |
| 1234 NSTextField* contentLabel = BuildLabel( | 1264 NSTextField* contentLabel = BuildLabel( |
| 1235 l10n_util::GetNSString(contentMessageId), | 1265 contentMessage, |
| 1236 NSMakePoint(kHorizontalSpacing, yOffset), | 1266 NSMakePoint(kHorizontalSpacing, yOffset), |
| 1237 tutorialBackgroundColor, | 1267 tutorialBackgroundColor, |
| 1238 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); | 1268 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); |
| 1239 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1269 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
| 1240 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1270 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
| 1241 [container addSubview:contentLabel]; | 1271 [container addSubview:contentLabel]; |
| 1242 yOffset = NSMaxY([contentLabel frame]) + kSmallVerticalSpacing; | 1272 yOffset = NSMaxY([contentLabel frame]) + kSmallVerticalSpacing; |
| 1243 | 1273 |
| 1244 // Adds title. | 1274 // Adds title. |
| 1245 NSTextField* titleLabel = | 1275 NSTextField* titleLabel = |
| 1246 BuildLabel(l10n_util::GetNSString(titleMessageId), | 1276 BuildLabel(titleMessage, |
| 1247 NSMakePoint(kHorizontalSpacing, yOffset), | 1277 NSMakePoint(kHorizontalSpacing, yOffset), |
| 1248 tutorialBackgroundColor, | 1278 tutorialBackgroundColor, |
| 1249 [NSColor whiteColor] /* text_color */); | 1279 [NSColor whiteColor] /* text_color */); |
| 1250 [titleLabel setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | 1280 [titleLabel setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
| 1251 [titleLabel sizeToFit]; | 1281 [titleLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
| 1252 [titleLabel setFrameSize: | 1282 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:titleLabel]; |
| 1253 NSMakeSize(availableWidth, NSHeight([titleLabel frame]))]; | |
| 1254 [container addSubview:titleLabel]; | 1283 [container addSubview:titleLabel]; |
| 1255 yOffset = NSMaxY([titleLabel frame]) + kVerticalSpacing; | 1284 yOffset = NSMaxY([titleLabel frame]) + kVerticalSpacing; |
| 1256 | 1285 |
| 1257 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1286 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| 1258 | 1287 [container setFrameOrigin:NSZeroPoint]; |
| 1259 // Adds caret at the bottom. | 1288 return container.autorelease(); |
| 1260 NSImage* caretImage = ui::ResourceBundle::GetSharedInstance(). | |
| 1261 GetNativeImageNamed(IDR_ICON_PROFILES_MENU_CARET).AsNSImage(); | |
| 1262 base::scoped_nsobject<NSImageView> caretView( | |
| 1263 [[NSImageView alloc] initWithFrame:NSMakeRect( | |
| 1264 kHorizontalSpacing, 0, caretImage.size.width, | |
| 1265 caretImage.size.height)]); | |
| 1266 [caretView setImage:caretImage]; | |
| 1267 | |
| 1268 base::scoped_nsobject<NSView> containerWithCaret([[NSView alloc] | |
| 1269 initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0)]); | |
| 1270 [containerWithCaret addSubview:caretView]; | |
| 1271 | |
| 1272 [container setFrameOrigin:NSMakePoint(0, caretImage.size.height)]; | |
| 1273 [containerWithCaret addSubview:container]; | |
| 1274 | |
| 1275 [containerWithCaret setFrameSize: | |
| 1276 NSMakeSize(kFixedMenuWidth, NSMaxY([container frame]))]; | |
| 1277 return containerWithCaret.autorelease(); | |
| 1278 } | 1289 } |
| 1279 | 1290 |
| 1280 - (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item { | 1291 - (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item { |
| 1281 base::scoped_nsobject<NSView> container([[NSView alloc] | 1292 base::scoped_nsobject<NSView> container([[NSView alloc] |
| 1282 initWithFrame:NSZeroRect]); | 1293 initWithFrame:NSZeroRect]); |
| 1283 | 1294 |
| 1284 CGFloat xOffset = kHorizontalSpacing; | 1295 CGFloat xOffset = kHorizontalSpacing; |
| 1285 CGFloat yOffset = 0; | 1296 CGFloat yOffset = 0; |
| 1286 CGFloat availableTextWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; | 1297 CGFloat availableTextWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; |
| 1287 | 1298 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 [supervisedIcon setImage:rb->GetNativeImageNamed( | 1351 [supervisedIcon setImage:rb->GetNativeImageNamed( |
| 1341 IDR_ICON_PROFILES_MENU_SUPERVISED).ToNSImage()]; | 1352 IDR_ICON_PROFILES_MENU_SUPERVISED).ToNSImage()]; |
| 1342 NSSize size = [[supervisedIcon image] size]; | 1353 NSSize size = [[supervisedIcon image] size]; |
| 1343 [supervisedIcon setFrameSize:size]; | 1354 [supervisedIcon setFrameSize:size]; |
| 1344 NSRect parentFrame = [iconView frame]; | 1355 NSRect parentFrame = [iconView frame]; |
| 1345 [supervisedIcon setFrameOrigin:NSMakePoint(NSMaxX(parentFrame) - size.width, | 1356 [supervisedIcon setFrameOrigin:NSMakePoint(NSMaxX(parentFrame) - size.width, |
| 1346 NSMinY(parentFrame))]; | 1357 NSMinY(parentFrame))]; |
| 1347 [container addSubview:supervisedIcon]; | 1358 [container addSubview:supervisedIcon]; |
| 1348 } | 1359 } |
| 1349 | 1360 |
| 1350 if (switches::IsNewProfileManagementPreviewEnabled()) { | |
| 1351 base::scoped_nsobject<HoverImageButton> questionButton( | |
| 1352 [[HoverImageButton alloc] initWithFrame:NSZeroRect]); | |
| 1353 [questionButton setBordered:NO]; | |
| 1354 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
| 1355 [questionButton setDefaultImage:rb->GetNativeImageNamed( | |
| 1356 IDR_ICON_PROFILES_MENU_QUESTION_STABLE).ToNSImage()]; | |
| 1357 [questionButton setHoverImage:rb->GetNativeImageNamed( | |
| 1358 IDR_ICON_PROFILES_MENU_QUESTION_HOVER).ToNSImage()]; | |
| 1359 [questionButton setPressedImage:rb->GetNativeImageNamed( | |
| 1360 IDR_ICON_PROFILES_MENU_QUESTION_SELECT).ToNSImage()]; | |
| 1361 [questionButton setTarget:self]; | |
| 1362 [questionButton setAction:@selector(showSendFeedbackTutorial:)]; | |
| 1363 [questionButton sizeToFit]; | |
| 1364 const CGFloat size = NSHeight([questionButton frame]) + 2; | |
| 1365 [questionButton setFrame: | |
| 1366 NSMakeRect(kHorizontalSpacing, yOffset - size, size, size)]; | |
| 1367 [container addSubview:questionButton]; | |
| 1368 } | |
| 1369 | |
| 1370 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1361 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
| 1371 return container.autorelease(); | 1362 return container.autorelease(); |
| 1372 } | 1363 } |
| 1373 | 1364 |
| 1374 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item | 1365 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item |
| 1375 rect:(NSRect)rect { | 1366 rect:(NSRect)rect { |
| 1376 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); | 1367 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
| 1377 | 1368 |
| 1378 // Don't double-apply the left margin to the sub-views. | 1369 // Don't double-apply the left margin to the sub-views. |
| 1379 rect.origin.x = 0; | 1370 rect.origin.x = 0; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1691 yOffset = NSMaxY([webview frame]); | 1682 yOffset = NSMaxY([webview frame]); |
| 1692 | 1683 |
| 1693 // Adds the title card. | 1684 // Adds the title card. |
| 1694 NSBox* separator = [self horizontalSeparatorWithFrame: | 1685 NSBox* separator = [self horizontalSeparatorWithFrame: |
| 1695 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; | 1686 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; |
| 1696 [container addSubview:separator]; | 1687 [container addSubview:separator]; |
| 1697 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1688 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
| 1698 | 1689 |
| 1699 NSView* titleView = BuildTitleCard( | 1690 NSView* titleView = BuildTitleCard( |
| 1700 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), | 1691 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), |
| 1701 messageId, | 1692 l10n_util::GetNSString(messageId), |
| 1702 self /* backButtonTarget*/, | 1693 self /* backButtonTarget*/, |
| 1703 @selector(navigateBackFromSigninPage:) /* backButtonAction */); | 1694 @selector(navigateBackFromSigninPage:) /* backButtonAction */); |
| 1704 [container addSubview:titleView]; | 1695 [container addSubview:titleView]; |
| 1705 yOffset = NSMaxY([titleView frame]); | 1696 yOffset = NSMaxY([titleView frame]); |
| 1706 | 1697 |
| 1707 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; | 1698 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; |
| 1708 return container.autorelease(); | 1699 return container.autorelease(); |
| 1709 } | 1700 } |
| 1710 | 1701 |
| 1711 - (NSView*)buildAccountRemovalView { | 1702 - (NSView*)buildAccountRemovalView { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; | 1753 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; |
| 1763 | 1754 |
| 1764 // Adds the title card. | 1755 // Adds the title card. |
| 1765 NSBox* separator = [self horizontalSeparatorWithFrame: | 1756 NSBox* separator = [self horizontalSeparatorWithFrame: |
| 1766 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; | 1757 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; |
| 1767 [container addSubview:separator]; | 1758 [container addSubview:separator]; |
| 1768 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1759 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
| 1769 | 1760 |
| 1770 NSView* titleView = BuildTitleCard( | 1761 NSView* titleView = BuildTitleCard( |
| 1771 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), | 1762 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), |
| 1772 IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, | 1763 l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
| 1773 self /* backButtonTarget*/, | 1764 self /* backButtonTarget*/, |
| 1774 @selector(showAccountManagement:) /* backButtonAction */); | 1765 @selector(showAccountManagement:) /* backButtonAction */); |
| 1775 [container addSubview:titleView]; | 1766 [container addSubview:titleView]; |
| 1776 yOffset = NSMaxY([titleView frame]); | 1767 yOffset = NSMaxY([titleView frame]); |
| 1777 | 1768 |
| 1778 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; | 1769 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; |
| 1779 return container.autorelease(); | 1770 return container.autorelease(); |
| 1780 } | 1771 } |
| 1781 | 1772 |
| 1782 - (NSView*)buildEndPreviewView { | 1773 |
| 1774 - (NSView*)buildSwitchUserView { |
| 1783 base::scoped_nsobject<NSView> container( | 1775 base::scoped_nsobject<NSView> container( |
| 1784 [[NSView alloc] initWithFrame:NSZeroRect]); | 1776 [[NSView alloc] initWithFrame:NSZeroRect]); |
| 1785 CGFloat availableWidth = | 1777 CGFloat availableWidth = |
| 1786 kFixedEndPreviewViewWidth - 2 * kHorizontalSpacing; | 1778 kFixedSwitchUserViewWidth - 2 * kHorizontalSpacing; |
| 1787 CGFloat yOffset = kVerticalSpacing; | 1779 CGFloat yOffset = 0; |
| 1780 NSRect viewRect = NSMakeRect(0, yOffset, |
| 1781 kFixedSwitchUserViewWidth, |
| 1782 kBlueButtonHeight + kSmallVerticalSpacing); |
| 1788 | 1783 |
| 1789 // Adds the "end preview and relaunch" button at the bottom. | 1784 const AvatarMenu::Item& avatarItem = |
| 1790 base::scoped_nsobject<NSButton> endPreviewAndRelaunchButton( | 1785 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
| 1791 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); | |
| 1792 [endPreviewAndRelaunchButton setTitle:l10n_util::GetNSString( | |
| 1793 IDS_PROFILES_END_PREVIEW_AND_RELAUNCH)]; | |
| 1794 [endPreviewAndRelaunchButton setTarget:self]; | |
| 1795 [endPreviewAndRelaunchButton setAction:@selector(endPreviewAndRelaunch:)]; | |
| 1796 [endPreviewAndRelaunchButton sizeToFit]; | |
| 1797 [endPreviewAndRelaunchButton setAlignment:NSCenterTextAlignment]; | |
| 1798 CGFloat xOffset = (kFixedEndPreviewViewWidth - | |
| 1799 NSWidth([endPreviewAndRelaunchButton frame])) / 2; | |
| 1800 [endPreviewAndRelaunchButton setFrameOrigin:NSMakePoint(xOffset, yOffset)]; | |
| 1801 [container addSubview:endPreviewAndRelaunchButton]; | |
| 1802 yOffset = NSMaxY([endPreviewAndRelaunchButton frame]) + kVerticalSpacing; | |
| 1803 | 1786 |
| 1804 // Adds the main text label. | 1787 // Adds "Disconnect your Google Account" button at the bottom. |
| 1805 NSPoint contentFrameOrigin = NSMakePoint(kHorizontalSpacing, yOffset); | 1788 NSButton* disconnectButton = |
| 1806 NSString* contentStr = | 1789 [self hoverButtonWithRect:viewRect |
| 1807 l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT); | 1790 text:l10n_util::GetNSString( |
| 1808 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, | 1791 IDS_PROFILES_DISCONNECT_BUTTON) |
| 1792 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
| 1793 action:@selector(disconnectProfile:)]; |
| 1794 [container addSubview:disconnectButton]; |
| 1795 yOffset = NSMaxY([disconnectButton frame]); |
| 1796 |
| 1797 NSBox* separator = [self horizontalSeparatorWithFrame: |
| 1798 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| 1799 [container addSubview:separator]; |
| 1800 yOffset = NSMaxY([separator frame]); |
| 1801 |
| 1802 // Adds "Add person" button. |
| 1803 viewRect.origin.y = yOffset; |
| 1804 NSButton* addPersonButton = |
| 1805 [self hoverButtonWithRect:viewRect |
| 1806 text:l10n_util::GetNSString( |
| 1807 IDS_PROFILES_ADD_PERSON_BUTTON) |
| 1808 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
| 1809 action:@selector(addPerson:)]; |
| 1810 [container addSubview:addPersonButton]; |
| 1811 yOffset = NSMaxY([addPersonButton frame]); |
| 1812 |
| 1813 separator = [self horizontalSeparatorWithFrame: |
| 1814 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
| 1815 [container addSubview:separator]; |
| 1816 yOffset = NSMaxY([separator frame]); |
| 1817 |
| 1818 // Adds the content text. |
| 1819 NSTextField* contentLabel = BuildLabel( |
| 1820 l10n_util::GetNSStringF( |
| 1821 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatarItem.name), |
| 1822 NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing), |
| 1809 GetDialogBackgroundColor(), nil /* text_color */); | 1823 GetDialogBackgroundColor(), nil /* text_color */); |
| 1810 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1824 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
| 1811 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1825 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
| 1812 [container addSubview:contentLabel]; | 1826 [container addSubview:contentLabel]; |
| 1813 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; | 1827 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; |
| 1814 | 1828 |
| 1815 // Adds the title card. | 1829 // Adds the title card. |
| 1816 NSBox* separator = [self horizontalSeparatorWithFrame: | 1830 separator = [self horizontalSeparatorWithFrame: |
| 1817 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)]; | 1831 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)]; |
| 1818 [container addSubview:separator]; | 1832 [container addSubview:separator]; |
| 1819 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1833 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
| 1820 | 1834 |
| 1821 NSView* titleView = BuildTitleCard( | 1835 NSView* titleView = BuildTitleCard( |
| 1822 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0), | 1836 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0), |
| 1823 IDS_PROFILES_END_PREVIEW, | 1837 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name), |
| 1824 self /* backButtonTarget*/, | 1838 self /* backButtonTarget*/, |
| 1825 @selector(showSendFeedbackTutorial:) /* backButtonAction */); | 1839 @selector(navigateBackFromSwitchUserView:) /* backButtonAction */); |
| 1826 [container addSubview:titleView]; | 1840 [container addSubview:titleView]; |
| 1827 yOffset = NSMaxY([titleView frame]); | 1841 yOffset = NSMaxY([titleView frame]); |
| 1828 | 1842 |
| 1829 [container setFrameSize:NSMakeSize(kFixedEndPreviewViewWidth, yOffset)]; | 1843 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; |
| 1830 return container.autorelease(); | 1844 return container.autorelease(); |
| 1831 } | 1845 } |
| 1832 | 1846 |
| 1833 // Called when clicked on the settings link. | 1847 // Called when clicked on the settings link. |
| 1834 - (BOOL)textView:(NSTextView*)textView | 1848 - (BOOL)textView:(NSTextView*)textView |
| 1835 clickedOnLink:(id)link | 1849 clickedOnLink:(id)link |
| 1836 atIndex:(NSUInteger)charIndex { | 1850 atIndex:(NSUInteger)charIndex { |
| 1837 chrome::ShowSettings(browser_); | 1851 chrome::ShowSettings(browser_); |
| 1838 return YES; | 1852 return YES; |
| 1839 } | 1853 } |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1947 } | 1961 } |
| 1948 | 1962 |
| 1949 - (bool)shouldShowGoIncognito { | 1963 - (bool)shouldShowGoIncognito { |
| 1950 bool incognitoAvailable = | 1964 bool incognitoAvailable = |
| 1951 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1965 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1952 IncognitoModePrefs::DISABLED; | 1966 IncognitoModePrefs::DISABLED; |
| 1953 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 1967 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 1954 } | 1968 } |
| 1955 | 1969 |
| 1956 @end | 1970 @end |
| OLD | NEW |