Index: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
diff --git a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
index 84185ba06796f3efa61d8759490c31405f354ce4..8a7c1d710ab46ad2407cbcb301d045e26b90ec66 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
@@ -12,6 +12,7 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
+#include "chrome/browser/first_run/first_run.h" |
#include "chrome/browser/lifetime/application_lifetime.h" |
#include "chrome/browser/prefs/incognito_mode_prefs.h" |
#include "chrome/browser/profiles/avatar_menu.h" |
@@ -32,6 +33,8 @@ |
#include "chrome/browser/ui/browser_window.h" |
#include "chrome/browser/ui/chrome_pages.h" |
#include "chrome/browser/ui/chrome_style.h" |
+#include "chrome/browser/ui/webui/signin/login_ui_service.h" |
+#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
#import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
#import "chrome/browser/ui/cocoa/info_bubble_view.h" |
#import "chrome/browser/ui/cocoa/info_bubble_window.h" |
@@ -88,12 +91,13 @@ const CGFloat kFixedGaiaViewHeight = 400; |
// Fixed size for the account removal view. |
const CGFloat kFixedAccountRemovalViewWidth = 280; |
-// Fixed size for the end-preview view. |
-const int kFixedEndPreviewViewWidth = 280; |
+ |
+// Fixed size for the switch user view. |
+const int kFixedSwitchUserViewWidth = 280; |
// Maximum number of times to show the welcome tutorial in the profile avatar |
// bubble. |
-const int kProfileAvatarTutorialShowMax = 1; |
+const int kUpgradeWelcomeTutorialShowMax = 1; |
// The tag number for the primary account. |
const int kPrimaryProfileTag = -1; |
@@ -192,7 +196,7 @@ NSColor* GetDialogBackgroundColor() { |
// Builds a title card with one back button right aligned and one label center |
// aligned. |
NSView* BuildTitleCard(NSRect frame_rect, |
- int message_id, |
+ NSString* message, |
id back_button_target, |
SEL back_button_action) { |
base::scoped_nsobject<NSView> container( |
@@ -211,8 +215,7 @@ NSView* BuildTitleCard(NSRect frame_rect, |
[button setFrameOrigin:NSMakePoint(kHorizontalSpacing, 0)]; |
NSTextField* title_label = |
- BuildLabel(l10n_util::GetNSString(message_id), NSZeroPoint, |
- GetDialogBackgroundColor(), nil /* text_color */); |
+ BuildLabel(message, NSZeroPoint, GetDialogBackgroundColor(), nil); |
[title_label setAlignment:NSCenterTextAlignment]; |
[title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
[title_label sizeToFit]; |
@@ -289,6 +292,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
+ if (viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) |
+ [controller_ setTutorialMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN]; |
[controller_ initMenuContentsWithView: |
switches::IsEnableAccountConsistency() ? |
profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
@@ -306,6 +311,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// AvatarMenuObserver: |
virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { |
+ // Do not refresh the avatar menu if the user is on a signin related view. |
+ profiles::BubbleViewMode viewMode = [controller_ viewMode]; |
+ if (viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
+ viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
+ viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
+ return; |
+ } |
+ |
// While the bubble is open, the avatar menu can only change from the |
// profile chooser view by modifying the current profile's photo or name. |
[controller_ |
@@ -704,24 +717,28 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Builds the profile chooser view. |
- (NSView*)buildProfileChooserView; |
-// Builds a tutorial card with a title label using |titleMessageId|, a content |
-// label using |contentMessageId|, and a bottom row with a right-aligned link |
-// using |linkMessageId|, and a left aligned button using |buttonMessageId|. |
+// Builds a tutorial card with a title label using |titleMessage|, a content |
+// label using |contentMessage|, and a bottom row with a right-aligned link |
+// using |linkMessage|, and a left aligned button using |buttonMessage|. |
// On click, the link would execute |linkAction|, and the button would execute |
// |buttonAction|. It sets |tutorialMode_| to the given |mode|. |
- (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
- titleMessage:(int)titleMessageId |
- contentMessage:(int)contentMessageId |
- linkMessage:(int)linkMessageId |
- buttonMessage:(int)buttonMessageId |
+ titleMessage:(NSString*)titleMessage |
+ contentMessage:(NSString*)contentMessage |
+ linkMessage:(NSString*)linkMessage |
+ buttonMessage:(NSString*)buttonMessage |
linkAction:(SEL)linkAction |
buttonAction:(SEL)buttonAction; |
-// Builds a a tutorial card for new profile management preview if needed. if |
-// new profile management is not enabled yet, then it prompts the user to try |
-// out the feature. Otherwise, it notifies the user that the feature has been |
-// enabled if needed. |
-- (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item; |
+// Builds a tutorial card to introduce an upgrade user to the new avatar menu if |
+// needed. |tutorial_shown| indicates if the tutorial has already been shown in |
+// the previous active view. |avatar_item| refers to the current profile. |
+- (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded; |
+ |
+// Builds a tutorial card to have the user confirm the last Chrome signin, |
+// Chrome sync will be delayed until the user either dismisses the tutorial, or |
+// configures sync through the "Settings" link. |
+- (NSView*)buildSigninConfirmationView; |
// Creates the main profile card for the profile |item| at the top of |
// the bubble. |
@@ -758,8 +775,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Creates the account removal view. |
- (NSView*)buildAccountRemovalView; |
-// Creates the end-preview view. |
-- (NSView*)buildEndPreviewView; |
+// Create a view that shows various options for an upgrade user who is not |
+// the same person as the currently signed in user. |
+- (NSView*)buildSwitchUserView; |
// Creates a button with |text|, an icon given by |imageResourceId| and with |
// |action|. |
@@ -790,6 +808,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
return viewMode_; |
} |
+- (void)setTutorialMode:(profiles::TutorialMode)tutorialMode { |
+ tutorialMode_ = tutorialMode; |
+} |
+ |
- (IBAction)switchToProfile:(id)sender { |
// Check the event flags to see if a new window should be created. |
bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( |
@@ -878,52 +900,47 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
} |
-- (IBAction)openTutorialLearnMoreURL:(id)sender { |
- ProfileMetrics::LogProfileUpgradeEnrollment( |
- ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
- // TODO(guohui): update |learnMoreUrl| once it is decided. |
- const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); |
- chrome::NavigateParams params(browser_->profile(), learnMoreUrl, |
- content::PAGE_TRANSITION_LINK); |
- params.disposition = NEW_FOREGROUND_TAB; |
- chrome::Navigate(¶ms); |
-} |
- |
-- (IBAction)enableNewProfileManagementPreview:(id)sender { |
- ProfileMetrics::LogProfileUpgradeEnrollment( |
- ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); |
- profiles::EnableNewProfileManagementPreview(browser_->profile()); |
-} |
- |
-- (IBAction)dismissTutorial:(id)sender { |
- ProfileMetrics::LogProfileUpgradeEnrollment( |
- ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); |
- // If the user manually dismissed the tutorial, never show it again by setting |
- // the number of times shown to the maximum plus 1, so that later we could |
- // distinguish between the dismiss case and the case when the tutorial is |
- // indeed shown for the maximum number of times. |
- browser_->profile()->GetPrefs()->SetInteger( |
- prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
- [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
+- (IBAction)seeWhatsNew:(id)sender { |
+ chrome::ShowUserManagerWithTutorial( |
+ profiles::USER_MANAGER_TUTORIAL_OVERVIEW); |
+} |
+ |
+- (IBAction)showSwitchUserView:(id)sender { |
+ [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_SWITCH_USER]; |
+} |
+ |
+- (IBAction)configureSyncSettings:(id)sender { |
+ tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
+ LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
+ SyncConfirmationUIClosed(true); |
} |
-- (IBAction)showSendFeedbackTutorial:(id)sender { |
- ProfileMetrics::LogProfileUpgradeEnrollment( |
- ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); |
- tutorialMode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK; |
+- (IBAction)syncSettingsConfirmed:(id)sender { |
+ tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
+ LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
+ SyncConfirmationUIClosed(false); |
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
} |
-- (IBAction)showEndPreviewView:(id)sender { |
- [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_END_PREVIEW]; |
+- (IBAction)addPerson:(id)sender { |
+ profiles::ShowUserManagerMaybeWithTutorial(browser_->profile()); |
+} |
+ |
+- (IBAction)disconnectProfile:(id)sender { |
+ chrome::ShowSettings(browser_); |
} |
-- (IBAction)sendFeedback:(id)sender { |
- chrome::OpenFeedbackDialog(browser_); |
+- (IBAction)navigateBackFromSwitchUserView:(id)sender { |
+ [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
} |
-- (IBAction)endPreviewAndRelaunch:(id)sender { |
- profiles::DisableNewProfileManagementPreview(browser_->profile()); |
+- (void)windowWillClose:(NSNotification*)notification { |
+ if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
+ LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
+ SyncConfirmationUIClosed(false); |
+ } |
+ |
+ [super windowWillClose:notification]; |
} |
- (void)cleanUpEmbeddedViewContents { |
@@ -998,8 +1015,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
subView = [self buildAccountRemovalView]; |
break; |
- case profiles::BUBBLE_VIEW_MODE_END_PREVIEW: |
- subView = [self buildEndPreviewView]; |
+ case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
+ subView = [self buildSwitchUserView]; |
break; |
case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
@@ -1022,16 +1039,27 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[[NSMutableArray alloc] init]); |
// Local and guest profiles cannot lock their profile. |
bool enableLock = false; |
- // Store the most recently displayed tutorial mode |
- profiles::TutorialMode lastTutorialMode = tutorialMode_; |
// Loop over the profiles in reverse, so that they are sorted by their |
// y-coordinate, and separate them into active and "other" profiles. |
for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
if (item.active) { |
- if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
- tutorialView = [self buildPreviewTutorialIfNeeded:item]; |
+ if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
+ switch (tutorialMode_) { |
+ case profiles::TUTORIAL_MODE_NONE: |
+ case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
+ tutorialView = |
+ [self buildWelcomeUpgradeTutorialViewIfNeeded]; |
+ break; |
+ case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: |
+ tutorialView = [self buildSigninConfirmationView]; |
+ break; |
+ case profiles::TUTORIAL_MODE_SHOW_ERROR: |
+ // TODO(guohui): not implemented yet. |
+ NOTREACHED(); |
+ } |
+ } |
currentProfileView = [self createCurrentProfileView:item]; |
enableLock = switches::IsNewProfileManagement() && item.signed_in; |
} else { |
@@ -1112,11 +1140,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
[container addSubview:tutorialView]; |
yOffset = NSMaxY([tutorialView frame]); |
- if (!switches::IsEnableAccountConsistency() && |
- tutorialMode_ != lastTutorialMode) { |
- ProfileMetrics::LogProfileUpgradeEnrollment( |
- ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO); |
- } |
+ //TODO(mlerman): update UMA stats for the new tutorials. |
} else { |
tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
} |
@@ -1125,67 +1149,74 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
return container.autorelease(); |
} |
-- (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { |
- if (!switches::IsEnableAccountConsistency()) { |
- return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_ENABLE_PREVIEW |
- titleMessage:IDS_PROFILES_PREVIEW_TUTORIAL_TITLE |
- contentMessage:IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT |
- linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE |
- buttonMessage:IDS_PROFILES_TUTORIAL_TRY_BUTTON |
- linkAction:@selector(openTutorialLearnMoreURL:) |
- buttonAction: |
- @selector(enableNewProfileManagementPreview:)]; |
- } |
- |
- if (!switches::IsNewProfileManagementPreviewEnabled()) |
+- (NSView*)buildSigninConfirmationView { |
+ NSString* titleMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE); |
+ NSString* contentMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT); |
+ NSString* linkMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_SYNC_SETTINGS_LINK); |
+ NSString* buttonMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_TUTORIAL_OK_BUTTON); |
+ return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN |
+ titleMessage:titleMessage |
+ contentMessage:contentMessage |
+ linkMessage:linkMessage |
+ buttonMessage:buttonMessage |
+ linkAction:@selector(configureSyncSettings:) |
+ buttonAction:@selector(syncSettingsConfirmed:)]; |
+} |
+ |
+- (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { |
+ if (first_run::IsChromeFirstRun()) |
return nil; |
- if (tutorialMode_ == profiles::TUTORIAL_MODE_SEND_FEEDBACK) { |
- return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_SEND_FEEDBACK |
- titleMessage:IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE |
- contentMessage: |
- IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT |
- linkMessage:IDS_PROFILES_END_PREVIEW |
- buttonMessage:IDS_PROFILES_SEND_FEEDBACK_BUTTON |
- linkAction:@selector(showEndPreviewView:) |
- buttonAction:@selector(sendFeedback:)]; |
+ Profile* profile = browser_->profile(); |
+ const AvatarMenu::Item& avatarItem = |
+ avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
+ if (!avatarItem.signed_in) { |
+ profile->GetPrefs()->SetInteger( |
+ prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1); |
+ return nil; |
} |
- Profile* profile = browser_->profile(); |
const int showCount = profile->GetPrefs()->GetInteger( |
prefs::kProfileAvatarTutorialShown); |
// Do not show the tutorial if user has dismissed it. |
- if (showCount > kProfileAvatarTutorialShowMax) |
+ if (showCount > kUpgradeWelcomeTutorialShowMax) |
return nil; |
- if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME) { |
- if (showCount == kProfileAvatarTutorialShowMax) |
+ if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { |
+ if (showCount == kUpgradeWelcomeTutorialShowMax) |
return nil; |
profile->GetPrefs()->SetInteger( |
prefs::kProfileAvatarTutorialShown, showCount + 1); |
} |
- return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME |
- titleMessage:IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE |
- contentMessage: |
- IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT |
- linkMessage:IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE |
- buttonMessage:IDS_PROFILES_TUTORIAL_OK_BUTTON |
- linkAction:@selector(openTutorialLearnMoreURL:) |
- buttonAction:@selector(dismissTutorial:)]; |
+ NSString* titleMessage = l10n_util::GetNSStringF( |
+ IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name); |
+ NSString* contentMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); |
+ NSString* linkMessage = l10n_util::GetNSStringF( |
+ IDS_PROFILES_NOT_YOU, avatarItem.name); |
+ NSString* buttonMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); |
+ return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE |
+ titleMessage:titleMessage |
+ contentMessage:contentMessage |
+ linkMessage:linkMessage |
+ buttonMessage:buttonMessage |
+ linkAction:@selector(showSwitchUserView:) |
+ buttonAction:@selector(seeWhatsNew:)]; |
} |
- (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
- titleMessage:(int)titleMessageId |
- contentMessage:(int)contentMessageId |
- linkMessage:(int)linkMessageId |
- buttonMessage:(int)buttonMessageId |
+ titleMessage:(NSString*)titleMessage |
+ contentMessage:(NSString*)contentMessage |
+ linkMessage:(NSString*)linkMessage |
+ buttonMessage:(NSString*)buttonMessage |
linkAction:(SEL)linkAction |
buttonAction:(SEL)buttonAction { |
- // No promotion to Enable Accounst Consistency. |
- if (mode == profiles::TUTORIAL_MODE_ENABLE_PREVIEW) |
- return nil; |
- |
tutorialMode_ = mode; |
NSColor* tutorialBackgroundColor = |
@@ -1199,8 +1230,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Adds links and buttons at the bottom. |
base::scoped_nsobject<NSButton> tutorialOkButton([[HoverButton alloc] |
initWithFrame:NSZeroRect]); |
- [tutorialOkButton setTitle:l10n_util::GetNSString( |
- buttonMessageId)]; |
+ [tutorialOkButton setTitle:buttonMessage]; |
[tutorialOkButton setBezelStyle:NSRoundedBezelStyle]; |
[tutorialOkButton setTarget:self]; |
[tutorialOkButton setAction:buttonAction]; |
@@ -1218,7 +1248,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[container addSubview:tutorialOkButton]; |
NSButton* learnMoreLink = |
- [self linkButtonWithTitle:l10n_util::GetNSString(linkMessageId) |
+ [self linkButtonWithTitle:linkMessage |
frameOrigin:NSZeroPoint |
action:linkAction]; |
[[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; |
@@ -1232,7 +1262,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Adds body content. |
NSTextField* contentLabel = BuildLabel( |
- l10n_util::GetNSString(contentMessageId), |
+ contentMessage, |
NSMakePoint(kHorizontalSpacing, yOffset), |
tutorialBackgroundColor, |
gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); |
@@ -1243,38 +1273,19 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Adds title. |
NSTextField* titleLabel = |
- BuildLabel(l10n_util::GetNSString(titleMessageId), |
+ BuildLabel(titleMessage, |
NSMakePoint(kHorizontalSpacing, yOffset), |
tutorialBackgroundColor, |
[NSColor whiteColor] /* text_color */); |
[titleLabel setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
- [titleLabel sizeToFit]; |
- [titleLabel setFrameSize: |
- NSMakeSize(availableWidth, NSHeight([titleLabel frame]))]; |
+ [titleLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
+ [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:titleLabel]; |
[container addSubview:titleLabel]; |
yOffset = NSMaxY([titleLabel frame]) + kVerticalSpacing; |
[container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
- |
- // Adds caret at the bottom. |
- NSImage* caretImage = ui::ResourceBundle::GetSharedInstance(). |
- GetNativeImageNamed(IDR_ICON_PROFILES_MENU_CARET).AsNSImage(); |
- base::scoped_nsobject<NSImageView> caretView( |
- [[NSImageView alloc] initWithFrame:NSMakeRect( |
- kHorizontalSpacing, 0, caretImage.size.width, |
- caretImage.size.height)]); |
- [caretView setImage:caretImage]; |
- |
- base::scoped_nsobject<NSView> containerWithCaret([[NSView alloc] |
- initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0)]); |
- [containerWithCaret addSubview:caretView]; |
- |
- [container setFrameOrigin:NSMakePoint(0, caretImage.size.height)]; |
- [containerWithCaret addSubview:container]; |
- |
- [containerWithCaret setFrameSize: |
- NSMakeSize(kFixedMenuWidth, NSMaxY([container frame]))]; |
- return containerWithCaret.autorelease(); |
+ [container setFrameOrigin:NSZeroPoint]; |
+ return container.autorelease(); |
} |
- (NSView*)createCurrentProfileView:(const AvatarMenu::Item&)item { |
@@ -1347,26 +1358,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
[container addSubview:supervisedIcon]; |
} |
- if (switches::IsNewProfileManagementPreviewEnabled()) { |
- base::scoped_nsobject<HoverImageButton> questionButton( |
- [[HoverImageButton alloc] initWithFrame:NSZeroRect]); |
- [questionButton setBordered:NO]; |
- ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
- [questionButton setDefaultImage:rb->GetNativeImageNamed( |
- IDR_ICON_PROFILES_MENU_QUESTION_STABLE).ToNSImage()]; |
- [questionButton setHoverImage:rb->GetNativeImageNamed( |
- IDR_ICON_PROFILES_MENU_QUESTION_HOVER).ToNSImage()]; |
- [questionButton setPressedImage:rb->GetNativeImageNamed( |
- IDR_ICON_PROFILES_MENU_QUESTION_SELECT).ToNSImage()]; |
- [questionButton setTarget:self]; |
- [questionButton setAction:@selector(showSendFeedbackTutorial:)]; |
- [questionButton sizeToFit]; |
- const CGFloat size = NSHeight([questionButton frame]) + 2; |
- [questionButton setFrame: |
- NSMakeRect(kHorizontalSpacing, yOffset - size, size, size)]; |
- [container addSubview:questionButton]; |
- } |
- |
[container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
return container.autorelease(); |
} |
@@ -1698,7 +1689,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
NSView* titleView = BuildTitleCard( |
NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), |
- messageId, |
+ l10n_util::GetNSString(messageId), |
self /* backButtonTarget*/, |
@selector(navigateBackFromSigninPage:) /* backButtonAction */); |
[container addSubview:titleView]; |
@@ -1769,7 +1760,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
NSView* titleView = BuildTitleCard( |
NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), |
- IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, |
+ l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
self /* backButtonTarget*/, |
@selector(showAccountManagement:) /* backButtonAction */); |
[container addSubview:titleView]; |
@@ -1779,33 +1770,56 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
return container.autorelease(); |
} |
-- (NSView*)buildEndPreviewView { |
+ |
+- (NSView*)buildSwitchUserView { |
base::scoped_nsobject<NSView> container( |
[[NSView alloc] initWithFrame:NSZeroRect]); |
CGFloat availableWidth = |
- kFixedEndPreviewViewWidth - 2 * kHorizontalSpacing; |
- CGFloat yOffset = kVerticalSpacing; |
+ kFixedSwitchUserViewWidth - 2 * kHorizontalSpacing; |
+ CGFloat yOffset = 0; |
+ NSRect viewRect = NSMakeRect(0, yOffset, |
+ kFixedSwitchUserViewWidth, |
+ kBlueButtonHeight + kSmallVerticalSpacing); |
- // Adds the "end preview and relaunch" button at the bottom. |
- base::scoped_nsobject<NSButton> endPreviewAndRelaunchButton( |
- [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); |
- [endPreviewAndRelaunchButton setTitle:l10n_util::GetNSString( |
- IDS_PROFILES_END_PREVIEW_AND_RELAUNCH)]; |
- [endPreviewAndRelaunchButton setTarget:self]; |
- [endPreviewAndRelaunchButton setAction:@selector(endPreviewAndRelaunch:)]; |
- [endPreviewAndRelaunchButton sizeToFit]; |
- [endPreviewAndRelaunchButton setAlignment:NSCenterTextAlignment]; |
- CGFloat xOffset = (kFixedEndPreviewViewWidth - |
- NSWidth([endPreviewAndRelaunchButton frame])) / 2; |
- [endPreviewAndRelaunchButton setFrameOrigin:NSMakePoint(xOffset, yOffset)]; |
- [container addSubview:endPreviewAndRelaunchButton]; |
- yOffset = NSMaxY([endPreviewAndRelaunchButton frame]) + kVerticalSpacing; |
- |
- // Adds the main text label. |
- NSPoint contentFrameOrigin = NSMakePoint(kHorizontalSpacing, yOffset); |
- NSString* contentStr = |
- l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT); |
- NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, |
+ const AvatarMenu::Item& avatarItem = |
+ avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
+ |
+ // Adds "Disconnect your Google Account" button at the bottom. |
+ NSButton* disconnectButton = |
+ [self hoverButtonWithRect:viewRect |
+ text:l10n_util::GetNSString( |
+ IDS_PROFILES_DISCONNECT_BUTTON) |
+ imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
+ action:@selector(disconnectProfile:)]; |
+ [container addSubview:disconnectButton]; |
+ yOffset = NSMaxY([disconnectButton frame]); |
+ |
+ NSBox* separator = [self horizontalSeparatorWithFrame: |
+ NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
+ [container addSubview:separator]; |
+ yOffset = NSMaxY([separator frame]); |
+ |
+ // Adds "Add person" button. |
+ viewRect.origin.y = yOffset; |
+ NSButton* addPersonButton = |
+ [self hoverButtonWithRect:viewRect |
+ text:l10n_util::GetNSString( |
+ IDS_PROFILES_ADD_PERSON_BUTTON) |
+ imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
+ action:@selector(addPerson:)]; |
+ [container addSubview:addPersonButton]; |
+ yOffset = NSMaxY([addPersonButton frame]); |
+ |
+ separator = [self horizontalSeparatorWithFrame: |
+ NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
+ [container addSubview:separator]; |
+ yOffset = NSMaxY([separator frame]); |
+ |
+ // Adds the content text. |
+ NSTextField* contentLabel = BuildLabel( |
+ l10n_util::GetNSStringF( |
+ IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatarItem.name), |
+ NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing), |
GetDialogBackgroundColor(), nil /* text_color */); |
[contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
@@ -1813,20 +1827,20 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; |
// Adds the title card. |
- NSBox* separator = [self horizontalSeparatorWithFrame: |
- NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)]; |
+ separator = [self horizontalSeparatorWithFrame: |
+ NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)]; |
[container addSubview:separator]; |
yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
NSView* titleView = BuildTitleCard( |
- NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0), |
- IDS_PROFILES_END_PREVIEW, |
+ NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0), |
+ l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name), |
self /* backButtonTarget*/, |
- @selector(showSendFeedbackTutorial:) /* backButtonAction */); |
+ @selector(navigateBackFromSwitchUserView:) /* backButtonAction */); |
[container addSubview:titleView]; |
yOffset = NSMaxY([titleView frame]); |
- [container setFrameSize:NSMakeSize(kFixedEndPreviewViewWidth, yOffset)]; |
+ [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; |
return container.autorelease(); |
} |