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 29afe4656c062367f0de181eae0430a6f5dd7c9a..d5debdb4bb83abbd8ff9889840efaf1632530f17 100644 |
--- a/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm |
@@ -878,6 +878,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
// Builds the profile chooser view. |
- (NSView*)buildProfileChooserView; |
+- (NSView*)buildTutorialViewIfNeededForItem:(const AvatarMenu::Item&)item; |
+ |
// Builds a tutorial card with a title label using |titleMessage|, a content |
// label using |contentMessage|, a link using |linkMessage|, and a button using |
// |buttonMessage|. If |stackButton| is YES, places the button above the link. |
@@ -894,10 +896,22 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
linkAction:(SEL)linkAction |
buttonAction:(SEL)buttonAction; |
+// Returns YES if the Welcome/Upgrade tutorial bubble should be shown to the |
+// user, NO otherwise. |
+- (BOOL)shouldShowWelcomeUpgradeTutorial; |
+ |
+// Returns YES if the tutorial informing the user about right-click user |
+// switching should be shown, NO otherwise. |
+- (BOOL)shouldShowRightClickTutorialView; |
+ |
// 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; |
+- (NSView*)buildWelcomeUpgradeTutorialView:(const AvatarMenu::Item&)item; |
+ |
+// Builds a tutorial card to inform the user about right-click user switching if |
+// needed. |
+- (NSView*)buildRightClickTutorialView; |
// 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 |
@@ -1129,6 +1143,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); |
} |
+ if(tutorialMode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) { |
+ PrefService* localState = g_browser_process->local_state(); |
+ localState->SetBoolean( |
+ prefs::kProfileAvatarRightClickTutorialDismissed, true); |
+ } |
+ |
tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
} |
@@ -1270,6 +1290,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
bool displayLock = false; |
bool isFastProfileChooser = |
viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
+ if (isFastProfileChooser) { |
+ // The user is using right-click switching, no need to tell them about it. |
+ PrefService* localState = g_browser_process->local_state(); |
+ localState->SetBoolean( |
+ prefs::kProfileAvatarRightClickTutorialDismissed, true); |
+ } |
// Loop over the profiles in reverse, so that they are sorted by their |
// y-coordinate, and separate them into active and "other" profiles. |
@@ -1277,18 +1303,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
if (item.active) { |
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: |
- tutorialView = [self buildSigninErrorView]; |
- } |
+ tutorialView = [self buildTutorialViewIfNeededForItem:item]; |
} |
currentProfileView = [self createCurrentProfileView:item]; |
displayLock = item.signed_in && |
@@ -1425,24 +1440,30 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
buttonAction:nil]; |
} |
-- (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { |
+- (BOOL)shouldShowWelcomeUpgradeTutorial { |
Profile* profile = browser_->profile(); |
- const AvatarMenu::Item& avatarItem = |
- avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
const int showCount = profile->GetPrefs()->GetInteger( |
prefs::kProfileAvatarTutorialShown); |
// Do not show the tutorial if user has dismissed it. |
if (showCount > signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
- return nil; |
+ return NO; |
- if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { |
- if (showCount == signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
- return nil; |
- profile->GetPrefs()->SetInteger( |
- prefs::kProfileAvatarTutorialShown, showCount + 1); |
- } |
+ return tutorialMode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE || |
groby-ooo-7-16
2015/05/07 01:59:01
That's returning a bool, not BOOL. Since you neve
anthonyvd
2015/05/12 16:09:11
Thanks! Done.
|
+ showCount != signin_ui_util::kUpgradeWelcomeTutorialShowMax; |
+} |
+ |
+- (BOOL)shouldShowRightClickTutorialView { |
+ PrefService* localState = g_browser_process->local_state(); |
+ const bool dismissed = localState->GetBoolean( |
+ prefs::kProfileAvatarRightClickTutorialDismissed); |
+ |
+ // Don't show the tutorial if it's already been dismissed or if right-clicking |
+ // wouldn't show any targets. |
+ return !dismissed && profiles::HasProfileSwitchTargets(browser_->profile()); |
+} |
+- (NSView*)buildWelcomeUpgradeTutorialView:(const AvatarMenu::Item&)item { |
ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW); |
@@ -1451,9 +1472,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
NSString* contentMessage = l10n_util::GetNSString( |
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); |
// For local profiles, the "Not you" link doesn't make sense. |
- NSString* linkMessage = avatarItem.signed_in ? |
+ NSString* linkMessage = item.signed_in ? |
ElideMessage( |
- l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatarItem.name), |
+ l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, item.name), |
kFixedMenuWidth - 2 * kHorizontalSpacing) : |
nil; |
NSString* buttonMessage = l10n_util::GetNSString( |
@@ -1469,6 +1490,51 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
buttonAction:@selector(seeWhatsNew:)]; |
} |
+- (NSView*)buildRightClickTutorialView { |
+ NSString* titleMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_RIGHT_CLICK_TUTORIAL_TITLE); |
+ NSString* contentMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_RIGHT_CLICK_TUTORIAL_CONTENT_TEXT); |
+ NSString* buttonMessage = l10n_util::GetNSString( |
+ IDS_PROFILES_TUTORIAL_OK_BUTTON); |
+ |
+ return |
+ [self tutorialViewWithMode:profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING |
+ titleMessage:titleMessage |
+ contentMessage:contentMessage |
+ linkMessage:nil |
+ buttonMessage:buttonMessage |
+ stackButton:NO |
+ hasCloseButton:NO |
+ linkAction:nil |
+ buttonAction:@selector(dismissTutorial:)]; |
+} |
+ |
+- (NSView*)buildTutorialViewIfNeededForItem:(const AvatarMenu::Item&)item { |
+ if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) |
+ return [self buildSigninConfirmationView]; |
+ |
+ if (tutorialMode_ == profiles::TUTORIAL_MODE_SHOW_ERROR) |
+ return [self buildSigninErrorView]; |
+ |
+ if ([self shouldShowWelcomeUpgradeTutorial]) { |
groby-ooo-7-16
2015/05/07 01:59:01
If I read this correctly, this code only updates t
anthonyvd
2015/05/12 16:09:11
I moved this code as-is from line 1439 of the prev
|
+ if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { |
+ Profile* profile = browser_->profile(); |
+ const int showCount = profile->GetPrefs()->GetInteger( |
+ prefs::kProfileAvatarTutorialShown); |
+ profile->GetPrefs()->SetInteger( |
+ prefs::kProfileAvatarTutorialShown, showCount + 1); |
+ } |
+ |
+ return [self buildWelcomeUpgradeTutorialView:item]; |
+ } |
+ |
+ if ([self shouldShowRightClickTutorialView]) |
+ return [self buildRightClickTutorialView]; |
+ |
+ return nil; |
+} |
+ |
- (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
titleMessage:(NSString*)titleMessage |
contentMessage:(NSString*)contentMessage |