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) {
prefs::kProfileAvatarTutorialShown,
0,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
registry->RegisterBooleanPref(
prefs::kProfileUserManagerTutorialShown,
false,
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
#endif
}
......
......@@ -303,7 +303,19 @@ void ShowUserManagerMaybeWithTutorial(Profile* profile) {
chrome::ShowUserManager(base::FilePath());
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) {
......
......@@ -818,12 +818,12 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
}
- (IBAction)showUserManager:(id)sender {
chrome::ShowUserManager(browser_->profile()->GetPath());
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
}
- (IBAction)exitGuest:(id)sender {
DCHECK(browser_->profile()->IsGuestSession());
chrome::ShowUserManager(base::FilePath());
[self showUserManager:sender];
profiles::CloseGuestProfileWindows();
}
......@@ -849,6 +849,7 @@ 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];
......@@ -918,6 +919,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
[self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
}
- (IBAction)addPerson:(id)sender {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
}
- (IBAction)disconnectProfile:(id)sender {
chrome::ShowSettings(browser_);
}
......@@ -1166,6 +1171,11 @@ 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, kUpgradeWelcomeTutorialShowMax + 1);
return nil;
}
const int showCount = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown);
......@@ -1184,9 +1194,8 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name);
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 ?
l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name) : nil;
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
......@@ -1230,13 +1239,11 @@ 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];
if (linkMessage) {
NSButton* learnMoreLink =
[self linkButtonWithTitle:linkMessage
frameOrigin:NSZeroPoint
......@@ -1246,11 +1253,10 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
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,
......@@ -1764,6 +1770,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
return container.autorelease();
}
- (NSView*)buildSwitchUserView {
base::scoped_nsobject<NSView> container(
[[NSView alloc] initWithFrame:NSZeroRect]);
......@@ -1799,7 +1806,7 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
text:l10n_util::GetNSString(
IDS_PROFILES_ADD_PERSON_BUTTON)
imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
action:@selector(showUserManager:)];
action:@selector(addPerson:)];
[container addSubview:addPersonButton];
yOffset = NSMaxY([addPersonButton frame]);
......
......@@ -101,9 +101,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithNewMenu) {
subviews = [[subviews objectAtIndex:0] subviews];
// 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
// menu.
ASSERT_EQ(4U, [subviews count]);
// one option buttons view.
ASSERT_EQ(3U, [subviews count]);
// There should be two buttons and a separator in the option buttons view.
NSArray* buttonSubviews = [[subviews objectAtIndex:0] subviews];
......@@ -166,9 +165,8 @@ TEST_F(ProfileChooserControllerTest, InitialLayoutWithFastUserSwitcher) {
// Three profiles means we should have one active card and a
// 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
// the new avatar menu.
ASSERT_EQ(8U, [subviews count]);
// an option buttons view with its separator.
ASSERT_EQ(7U, [subviews count]);
// There should be two buttons and a separator in the option buttons view.
// These buttons are tested in InitialLayoutWithNewMenu.
......@@ -239,9 +237,8 @@ TEST_F(ProfileChooserControllerTest, OtherProfilesSortedAlphabetically) {
@"Test 1",
@"Test 2" };
// 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
// also have an update promo for the new avatar menu.
ASSERT_EQ(12U, [subviews count]);
// active profile card, and an option buttons view with a separator.
ASSERT_EQ(11U, [subviews count]);
// There should be four "other profiles" items, sorted alphabetically. The
// "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
......
......@@ -673,13 +673,10 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
sender->SetEnabled(false);
if (sender == users_button_) {
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
// If this is a guest session, also close all the guest browser windows.
if (browser_->profile()->IsGuestSession()) {
chrome::ShowUserManager(base::FilePath());
if (browser_->profile()->IsGuestSession())
profiles::CloseGuestProfileWindows();
} else {
chrome::ShowUserManager(browser_->profile()->GetPath());
}
} else if (sender == go_incognito_button_) {
DCHECK(ShouldShowGoIncognito());
chrome::NewIncognitoWindow(browser_);
......@@ -719,7 +716,7 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
} else if (sender == signin_current_profile_link_) {
ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
} else if (sender == add_person_button_) {
chrome::ShowUserManager(browser_->profile()->GetPath());
profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
} else if (sender == disconnect_button_) {
chrome::ShowSettings(browser_);
} else if (sender == switch_user_cancel_button_) {
......@@ -962,16 +959,12 @@ views::View* ProfileChooserView::CreateTutorialView(
button_columns->AddColumn(views::GridLayout::TRAILING,
views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing);
if (!link_text.empty()) {
*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);
} else {
layout->SkipColumns(1);
}
*button = new views::LabelButton(this, button_text);
(*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
......@@ -1401,6 +1394,11 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
return NULL;
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(
prefs::kProfileAvatarTutorialShown);
......@@ -1415,18 +1413,14 @@ views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
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(
profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
l10n_util::GetStringFUTF16(
IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatar_item.name),
l10n_util::GetStringUTF16(
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),
&tutorial_not_you_link_,
&tutorial_see_whats_new_button_);
......
......@@ -1154,6 +1154,10 @@ 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,6 +363,7 @@ 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