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