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

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

Revert of [Mac, Win] Only show the user manager tutorial if "See what's new" is clicked. (https://codereview.chromium.org/454153002/)

Reason for revert:
Breaks ProfileChooserControllerTest.InitialLayoutWithFastUserSwitcher,ProfileChooserControllerTest.InitialLayoutWithNewMenu,ProfileChooserControllerTest.OtherProfilesSortedAlphabetically on the waterfall.

Original issue's description:
> [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

TBR=guohui@chromium.org,rlp@chromium.org,sky@chromium.org,asvitkine@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=399679

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

Cr-Commit-Position: refs/heads/master@{#289017}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289017 0039d316-1c4b-4281-b951-d872f2087c98
parent aead5b17
...@@ -202,6 +202,10 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -202,6 +202,10 @@ void Profile::RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
prefs::kProfileAvatarTutorialShown, prefs::kProfileAvatarTutorialShown,
0, 0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kProfileUserManagerTutorialShown,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif #endif
} }
......
...@@ -303,7 +303,19 @@ void ShowUserManagerMaybeWithTutorial(Profile* profile) { ...@@ -303,7 +303,19 @@ void ShowUserManagerMaybeWithTutorial(Profile* profile) {
chrome::ShowUserManager(base::FilePath()); chrome::ShowUserManager(base::FilePath());
return; return;
} }
chrome::ShowUserManagerWithTutorial(profiles::USER_MANAGER_TUTORIAL_OVERVIEW); // 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);
}
} }
void EnableNewProfileManagementPreview(Profile* profile) { void EnableNewProfileManagementPreview(Profile* profile) {
......
...@@ -818,12 +818,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -818,12 +818,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
} }
- (IBAction)showUserManager:(id)sender { - (IBAction)showUserManager:(id)sender {
chrome::ShowUserManager(browser_->profile()->GetPath()); profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
} }
- (IBAction)exitGuest:(id)sender { - (IBAction)exitGuest:(id)sender {
DCHECK(browser_->profile()->IsGuestSession()); DCHECK(browser_->profile()->IsGuestSession());
chrome::ShowUserManager(base::FilePath()); [self showUserManager:sender];
profiles::CloseGuestProfileWindows(); profiles::CloseGuestProfileWindows();
} }
...@@ -849,6 +849,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -849,6 +849,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
} }
- (IBAction)addAccount:(id)sender { - (IBAction)addAccount:(id)sender {
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
[self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT]; [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT];
...@@ -918,6 +919,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -918,6 +919,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
- (IBAction)addPerson:(id)sender {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
}
- (IBAction)disconnectProfile:(id)sender { - (IBAction)disconnectProfile:(id)sender {
chrome::ShowSettings(browser_); chrome::ShowSettings(browser_);
} }
...@@ -1166,6 +1171,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1166,6 +1171,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
Profile* profile = browser_->profile(); Profile* profile = browser_->profile();
const AvatarMenu::Item& avatarItem = const AvatarMenu::Item& avatarItem =
avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex());
if (!avatarItem.signed_in) {
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1);
return nil;
}
const int showCount = profile->GetPrefs()->GetInteger( const int showCount = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown); prefs::kProfileAvatarTutorialShown);
...@@ -1184,9 +1194,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1184,9 +1194,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name); IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name);
NSString* contentMessage = l10n_util::GetNSString( NSString* contentMessage = l10n_util::GetNSString(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT);
// For local profiles, the "Not you" link doesn't make sense. NSString* linkMessage = l10n_util::GetNSStringF(
NSString* linkMessage = avatarItem.signed_in ? IDS_PROFILES_NOT_YOU, avatarItem.name);
l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name) : nil;
NSString* buttonMessage = l10n_util::GetNSString( NSString* buttonMessage = l10n_util::GetNSString(
IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON);
return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE
...@@ -1230,27 +1239,24 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1230,27 +1239,24 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
buttonSize.height += 2 * kTopBottomTextPadding; buttonSize.height += 2 * kTopBottomTextPadding;
[tutorialOkButton setFrameSize:buttonSize]; [tutorialOkButton setFrameSize:buttonSize];
[tutorialOkButton setAlignment:NSCenterTextAlignment]; [tutorialOkButton setAlignment:NSCenterTextAlignment];
[tutorialOkButton setFrameOrigin:NSMakePoint( [tutorialOkButton setFrameOrigin:NSMakePoint(
kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing, kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing,
yOffset)]; yOffset)];
[container addSubview:tutorialOkButton]; [container addSubview:tutorialOkButton];
if (linkMessage) { NSButton* learnMoreLink =
NSButton* learnMoreLink = [self linkButtonWithTitle:linkMessage
[self linkButtonWithTitle:linkMessage frameOrigin:NSZeroPoint
frameOrigin:NSZeroPoint action:linkAction];
action:linkAction]; [[learnMoreLink cell] setTextColor:[NSColor whiteColor]];
[[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) -
CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - NSHeight([learnMoreLink frame])) / 2;
NSHeight([learnMoreLink frame])) / 2; [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)];
[learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; [container addSubview:learnMoreLink];
[container addSubview:learnMoreLink];
yOffset = std::max(NSMaxY([learnMoreLink frame]), yOffset = std::max(NSMaxY([learnMoreLink frame]),
NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; NSMaxY([tutorialOkButton frame])) + kVerticalSpacing;
} else {
yOffset = NSMaxY([tutorialOkButton frame]) + kVerticalSpacing;
}
// Adds body content. // Adds body content.
NSTextField* contentLabel = BuildLabel( NSTextField* contentLabel = BuildLabel(
contentMessage, contentMessage,
...@@ -1764,6 +1770,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1764,6 +1770,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
return container.autorelease(); return container.autorelease();
} }
- (NSView*)buildSwitchUserView { - (NSView*)buildSwitchUserView {
base::scoped_nsobject<NSView> container( base::scoped_nsobject<NSView> container(
[[NSView alloc] initWithFrame:NSZeroRect]); [[NSView alloc] initWithFrame:NSZeroRect]);
...@@ -1799,7 +1806,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -1799,7 +1806,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
text:l10n_util::GetNSString( text:l10n_util::GetNSString(
IDS_PROFILES_ADD_PERSON_BUTTON) IDS_PROFILES_ADD_PERSON_BUTTON)
imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
action:@selector(showUserManager:)]; action:@selector(addPerson:)];
[container addSubview:addPersonButton]; [container addSubview:addPersonButton];
yOffset = NSMaxY([addPersonButton frame]); yOffset = NSMaxY([addPersonButton frame]);
......
...@@ -101,9 +101,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) { ...@@ -101,9 +101,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
subviews = [[subviews objectAtIndex:0] subviews]; subviews = [[subviews objectAtIndex:0] subviews];
// Three profiles means we should have one active card, one separator and // Three profiles means we should have one active card, one separator and
// one option buttons view. We also have an update promo for the new avatar // one option buttons view.
// menu. ASSERT_EQ(3U, [subviews count]);
ASSERT_EQ(4U, [subviews count]);
// There should be two buttons and a separator in the option buttons view. // There should be two buttons and a separator in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews]; NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
...@@ -166,9 +165,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) { ...@@ -166,9 +165,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) {
// Three profiles means we should have one active card and a // Three profiles means we should have one active card and a
// fast user switcher which has two "other" profiles and 2 separators, and // fast user switcher which has two "other" profiles and 2 separators, and
// an option buttons view with its separator. We also have a promo for // an option buttons view with its separator.
// the new avatar menu. ASSERT_EQ(7U, [subviews count]);
ASSERT_EQ(8U, [subviews count]);
// There should be two buttons and a separator in the option buttons view. // There should be two buttons and a separator in the option buttons view.
// These buttons are tested in InitialLayoutWithNewMenu. // These buttons are tested in InitialLayoutWithNewMenu.
...@@ -239,9 +237,8 @@ TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) { ...@@ -239,9 +237,8 @@ TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
@"Test 1", @"Test 1",
@"Test 2" }; @"Test 2" };
// There are four "other" profiles, each with a button and a separator, an // There are four "other" profiles, each with a button and a separator, an
// active profile card, and an option buttons view with a separator. We // active profile card, and an option buttons view with a separator.
// also have an update promo for the new avatar menu. ASSERT_EQ(11U, [subviews count]);
ASSERT_EQ(12U, [subviews count]);
// There should be four "other profiles" items, sorted alphabetically. The // There should be four "other profiles" items, sorted alphabetically. The
// "other profiles" start at index 2 (after the option buttons view and its // "other profiles" start at index 2 (after the option buttons view and its
// separator), and each have a separator. We need to iterate through the // separator), and each have a separator. We need to iterate through the
......
...@@ -673,13 +673,10 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -673,13 +673,10 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
sender->SetEnabled(false); sender->SetEnabled(false);
if (sender == users_button_) { if (sender == users_button_) {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
// If this is a guest session, also close all the guest browser windows. // 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(); profiles::CloseGuestProfileWindows();
} else {
chrome::ShowUserManager(browser_->profile()->GetPath());
}
} else if (sender == go_incognito_button_) { } else if (sender == go_incognito_button_) {
DCHECK(ShouldShowGoIncognito()); DCHECK(ShouldShowGoIncognito());
chrome::NewIncognitoWindow(browser_); chrome::NewIncognitoWindow(browser_);
...@@ -719,7 +716,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, ...@@ -719,7 +716,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
} else if (sender == signin_current_profile_link_) { } else if (sender == signin_current_profile_link_) {
ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
} else if (sender == add_person_button_) { } else if (sender == add_person_button_) {
chrome::ShowUserManager(browser_->profile()->GetPath()); profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
} else if (sender == disconnect_button_) { } else if (sender == disconnect_button_) {
chrome::ShowSettings(browser_); chrome::ShowSettings(browser_);
} else if (sender == switch_user_cancel_button_) { } else if (sender == switch_user_cancel_button_) {
...@@ -962,16 +959,12 @@ views::View* ProfileChooserView::CreateTutorialView( ...@@ -962,16 +959,12 @@ views::View* ProfileChooserView::CreateTutorialView(
button_columns->AddColumn(views::GridLayout::TRAILING, button_columns->AddColumn(views::GridLayout::TRAILING,
views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 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->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing);
if (!link_text.empty()) { layout->AddView(*link);
*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 = new views::LabelButton(this, button_text);
(*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
...@@ -1401,6 +1394,11 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( ...@@ -1401,6 +1394,11 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
return NULL; return NULL;
Profile* profile = browser_->profile(); Profile* profile = browser_->profile();
if (!avatar_item.signed_in) {
profile->GetPrefs()->SetInteger(
prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1);
return NULL;
}
const int show_count = profile->GetPrefs()->GetInteger( const int show_count = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown); prefs::kProfileAvatarTutorialShown);
...@@ -1415,18 +1413,14 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( ...@@ -1415,18 +1413,14 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
prefs::kProfileAvatarTutorialShown, show_count + 1); prefs::kProfileAvatarTutorialShown, show_count + 1);
} }
// 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( return CreateTutorialView(
profiles::TUTORIAL_MODE_WELCOME_UPGRADE, profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatar_item.name), IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatar_item.name),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT),
link_message, l10n_util::GetStringFUTF16(
IDS_PROFILES_NOT_YOU, avatar_item.name),
l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON),
&tutorial_not_you_link_, &tutorial_not_you_link_,
&tutorial_see_whats_new_button_); &tutorial_see_whats_new_button_);
......
...@@ -1154,6 +1154,10 @@ const char kProfileGAIAInfoPictureURL[] = "profile.gaia_info_picture_url"; ...@@ -1154,6 +1154,10 @@ const char kProfileGAIAInfoPictureURL[] = "profile.gaia_info_picture_url";
const char kProfileAvatarTutorialShown[] = const char kProfileAvatarTutorialShown[] =
"profile.avatar_bubble_tutorial_shown"; "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 // Indicates if we've already shown a notification that high contrast
// mode is on, recommending high-contrast extensions and themes. // mode is on, recommending high-contrast extensions and themes.
const char kInvertNotificationShown[] = "invert_notification_version_2_shown"; const char kInvertNotificationShown[] = "invert_notification_version_2_shown";
......
...@@ -363,6 +363,7 @@ extern const char kProfileGAIAInfoUpdateTime[]; ...@@ -363,6 +363,7 @@ extern const char kProfileGAIAInfoUpdateTime[];
extern const char kProfileGAIAInfoPictureURL[]; extern const char kProfileGAIAInfoPictureURL[];
extern const char kProfileAvatarTutorialShown[]; extern const char kProfileAvatarTutorialShown[];
extern const char kProfileUserManagerTutorialShown[];
extern const char kInvertNotificationShown[]; 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