Commit d1f323a8 authored by noms@chromium.org's avatar noms@chromium.org

[Mac, Win] Only show the user manager tutorial if "See what's new" is clicked.

- remove the profile preference that used to keep track of showing the
tutorial any time the user manager was shown for a particular profile.

- show the upgrade bubble for local profiles as well (so that local profiles
have a chance to see the tutorial)

- for the local profiles upgrade bubble, don't show the "Not you?" link as
it doesn't really make sense.

BUG=399679
TBR=rpetterson@chromium.org

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=288817

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=289005

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=289636

Review URL: https://codereview.chromium.org/454153002

Cr-Commit-Position: refs/heads/master@{#290021}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290021 0039d316-1c4b-4281-b951-d872f2087c98
parent 18719c95
......@@ -202,10 +202,6 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
prefs::kProfileAvatarTutorialShown,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kProfileUserManagerTutorialShown,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
}
......
......@@ -303,19 +303,7 @@ void ShowUserManagerMaybeWithTutorial(Profile* profile) {
chrome::ShowUserManager(base::FilePath());
return;
}
// Show the tutorial if the profile has not shown it before.
PrefService* pref_service = profile->GetPrefs();
bool tutorial_shown = pref_service->GetBoolean(
prefs::kProfileUserManagerTutorialShown);
if (!tutorial_shown)
pref_service->SetBoolean(prefs::kProfileUserManagerTutorialShown, true);
if (tutorial_shown) {
chrome::ShowUserManager(profile->GetPath());
} else {
chrome::ShowUserManagerWithTutorial(
profiles::USER_MANAGER_TUTORIAL_OVERVIEW);
}
chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW);
}
void EnableNewProfileManagementPreview(Profile* profile) {
......
......@@ -814,14 +814,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
}
- (IBAction)showUserManager:(id)sender {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
chrome::ShowUserManager(browser_->profile()->GetPath());
[self postActionPerformed:
ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER];
}
- (IBAction)exitGuest:(id)sender {
DCHECK(browser_->profile()->IsGuestSession());
[self showUserManager:sender];
chrome::ShowUserManager(base::FilePath());
profiles::CloseGuestProfileWindows();
}
......@@ -847,7 +847,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
}
- (IBAction)addAccount:(id)sender {
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
[self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT];
......@@ -925,12 +924,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
}
- (IBAction)addPerson:(id)sender {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
ProfileMetrics::LogProfileNewAvatarMenuNotYou(
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
}
- (IBAction)disconnectProfile:(id)sender {
chrome::ShowSettings(browser_);
ProfileMetrics::LogProfileNewAvatarMenuNotYou(
......@@ -1183,12 +1176,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
Profile* profile = browser_->profile();
const AvatarMenu::Item& avatarItem =
avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex());
if (!avatarItem.signed_in) {
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown,
signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
return nil;
}
const int showCount = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown);
......@@ -1210,8 +1197,9 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE);
NSString* contentMessage = l10n_util::GetNSString(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT);
NSString* linkMessage = l10n_util::GetNSStringF(
IDS_PROFILES_NOT_YOU, avatarItem.name);
// For local profiles, the "Not you" link doesn't make sense.
NSString* linkMessage = avatarItem.signed_in ?
l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name) : nil;
NSString* buttonMessage = l10n_util::GetNSString(
IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON);
return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE
......@@ -1255,24 +1243,27 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
buttonSize.height += 2 * kTopBottomTextPadding;
[tutorialOkButton setFrameSize:buttonSize];
[tutorialOkButton setAlignment:NSCenterTextAlignment];
[tutorialOkButton setFrameOrigin:NSMakePoint(
kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing,
yOffset)];
[container addSubview:tutorialOkButton];
NSButton* learnMoreLink =
[self linkButtonWithTitle:linkMessage
frameOrigin:NSZeroPoint
action:linkAction];
[[learnMoreLink cell] setTextColor:[NSColor whiteColor]];
CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) -
NSHeight([learnMoreLink frame])) / 2;
[learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)];
[container addSubview:learnMoreLink];
yOffset = std::max(NSMaxY([learnMoreLink frame]),
NSMaxY([tutorialOkButton frame])) + kVerticalSpacing;
if (linkMessage) {
NSButton* learnMoreLink =
[self linkButtonWithTitle:linkMessage
frameOrigin:NSZeroPoint
action:linkAction];
[[learnMoreLink cell] setTextColor:[NSColor whiteColor]];
CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) -
NSHeight([learnMoreLink frame])) / 2;
[learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)];
[container addSubview:learnMoreLink];
yOffset = std::max(NSMaxY([learnMoreLink frame]),
NSMaxY([tutorialOkButton frame])) + kVerticalSpacing;
} else {
yOffset = NSMaxY([tutorialOkButton frame]) + kVerticalSpacing;
}
// Adds body content.
NSTextField* contentLabel = BuildLabel(
contentMessage,
......@@ -1779,7 +1770,6 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
return container.autorelease();
}
- (NSView*)buildSwitchUserView {
ProfileMetrics::LogProfileNewAvatarMenuNotYou(
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
......@@ -1817,7 +1807,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
text:l10n_util::GetNSString(
IDS_PROFILES_ADD_PERSON_BUTTON)
imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
action:@selector(addPerson:)];
action:@selector(showUserManager:)];
[container addSubview:addPersonButton];
yOffset = NSMaxY([addPersonButton frame]);
......
......@@ -673,11 +673,14 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
sender->SetEnabled(false);
if (sender == users_button_) {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
// If this is a guest session, also close all the guest browser windows.
if (browser_->profile()->IsGuestSession())
if (browser_->profile()->IsGuestSession()) {
chrome::ShowUserManager(base::FilePath());
profiles::CloseGuestProfileWindows();
} else {
chrome::ShowUserManager(browser_->profile()->GetPath());
}
PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
} else if (sender == go_incognito_button_) {
DCHECK(ShouldShowGoIncognito());
chrome::NewIncognitoWindow(browser_);
......@@ -723,7 +726,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
} else if (sender == add_person_button_) {
ProfileMetrics::LogProfileNewAvatarMenuNotYou(
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
chrome::ShowUserManager(browser_->profile()->GetPath());
} else if (sender == disconnect_button_) {
ProfileMetrics::LogProfileNewAvatarMenuNotYou(
ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
......@@ -974,12 +977,16 @@ views::View* ProfileChooserView::CreateTutorialView(
button_columns->AddColumn(views::GridLayout::TRAILING,
views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
*link = CreateLink(link_text, this);
(*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT);
(*link)->SetAutoColorReadabilityEnabled(false);
(*link)->SetEnabledColor(SK_ColorWHITE);
layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing);
layout->AddView(*link);
if (!link_text.empty()) {
*link = CreateLink(link_text, this);
(*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT);
(*link)->SetAutoColorReadabilityEnabled(false);
(*link)->SetEnabledColor(SK_ColorWHITE);
layout->AddView(*link);
} else {
layout->SkipColumns(1);
}
*button = new views::LabelButton(this, button_text);
(*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
......@@ -1408,12 +1415,6 @@ views::View* ProfileChooserView::CreateAccountRemovalView() {
views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
bool tutorial_shown, const AvatarMenu::Item& avatar_item){
Profile* profile = browser_->profile();
if (!avatar_item.signed_in) {
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown,
signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
return NULL;
}
const int show_count = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown);
......@@ -1427,18 +1428,21 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, show_count + 1);
}
ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW);
// For local profiles, the "Not you" link doesn't make sense.
base::string16 link_message = avatar_item.signed_in ?
l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) :
base::string16();
return CreateTutorialView(
profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
l10n_util::GetStringUTF16(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE),
l10n_util::GetStringUTF16(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT),
l10n_util::GetStringFUTF16(
IDS_PROFILES_NOT_YOU, avatar_item.name),
link_message,
l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON),
&tutorial_not_you_link_,
&tutorial_see_whats_new_button_);
......
......@@ -1154,10 +1154,6 @@ const char kProfileGAIAInfoPictureURL[] = "profile.gaia_info_picture_url";
const char kProfileAvatarTutorialShown[] =
"profile.avatar_bubble_tutorial_shown";
// Boolean that specifies whether we have shown the user manager tutorial.
const char kProfileUserManagerTutorialShown[] =
"profile.user_manager_tutorial_shown";
// Indicates if we've already shown a notification that high contrast
// mode is on, recommending high-contrast extensions and themes.
const char kInvertNotificationShown[] = "invert_notification_version_2_shown";
......
......@@ -363,7 +363,6 @@ extern const char kProfileGAIAInfoUpdateTime[];
extern const char kProfileGAIAInfoPictureURL[];
extern const char kProfileAvatarTutorialShown[];
extern const char kProfileUserManagerTutorialShown[];
extern const char kInvertNotificationShown[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment