Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5287)

Unified Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 1120013003: Add right-click user switching tutorial bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
index f55258026ec657bf0ba3466211ae3fa8ea3bc099..3f1646f669abe5752d6afb4e3453a01f02eb836b 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
@@ -491,7 +491,7 @@ void ProfileChooserView::ShowBubble(
// It has to happen here to prevent the view system from creating an empty
// container.
if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
- profiles::HasProfileSwitchTargets(browser->profile())) {
+ !profiles::HasProfileSwitchTargets(browser->profile())) {
return;
}
@@ -913,20 +913,7 @@ void ProfileChooserView::PopulateCompleteProfileChooserView(
item.signed_in && profiles::IsLockAvailable(browser_->profile()));
current_profile_view = CreateCurrentProfileView(item, false);
if (IsProfileChooser(view_mode_)) {
- switch (tutorial_mode_) {
- case profiles::TUTORIAL_MODE_NONE:
- case profiles::TUTORIAL_MODE_WELCOME_UPGRADE:
- tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded(
- tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
- item);
- break;
- case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN:
- tutorial_view = CreateSigninConfirmationView();
- break;
- case profiles::TUTORIAL_MODE_SHOW_ERROR:
- tutorial_view = CreateSigninErrorView();
- break;
- }
+ tutorial_view = CreateTutorialViewIfNeeded(item);
} else {
current_profile_accounts = CreateCurrentProfileAccountsView(item);
}
@@ -1003,10 +990,15 @@ views::View* ProfileChooserView::CreateProfileChooserView(
views::View* view = new views::View();
views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
- if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER)
+ if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
PopulateMinimalProfileChooserView(layout, avatar_menu);
- else
+ // The user is using right-click switching, no need to tell them about it.
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetBoolean(
+ prefs::kProfileAvatarRightClickTutorialDismissed, true);
+ } else {
PopulateCompleteProfileChooserView(layout, avatar_menu);
+ }
return view;
}
@@ -1019,10 +1011,42 @@ void ProfileChooserView::DismissTutorial() {
signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
}
+ if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) {
+ PrefService* local_state = g_browser_process->local_state();
+ local_state->SetBoolean(
+ prefs::kProfileAvatarRightClickTutorialDismissed, true);
+ }
+
tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
}
+views::View* ProfileChooserView::CreateTutorialViewIfNeeded(
+ const AvatarMenu::Item& item) {
+ if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN)
+ return CreateSigninConfirmationView();
+
+ if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR)
+ return CreateSigninErrorView();
+
+ if (ShouldShowWelcomeUpgradeTutorial()) {
+ if (tutorial_mode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
+ Profile* profile = browser_->profile();
+ const int show_count = profile->GetPrefs()->GetInteger(
+ prefs::kProfileAvatarTutorialShown);
+ profile->GetPrefs()->SetInteger(
+ prefs::kProfileAvatarTutorialShown, show_count + 1);
+ }
+
+ return CreateWelcomeUpgradeTutorialView(item);
+ }
+
+ if (ShouldShowRightClickTutorialView())
+ return CreateRightClickTutorialView();
+
+ return nullptr;
+}
+
views::View* ProfileChooserView::CreateTutorialView(
profiles::TutorialMode tutorial_mode,
const base::string16& title_text,
@@ -1572,22 +1596,31 @@ views::View* ProfileChooserView::CreateAccountRemovalView() {
kFixedAccountRemovalViewWidth);
}
-views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded(
- bool tutorial_shown, const AvatarMenu::Item& avatar_item) {
+bool ProfileChooserView::ShouldShowWelcomeUpgradeTutorial() {
Mike Lerman 2015/05/14 20:29:43 You can remove these method definitions from the h
anthonyvd 2015/05/15 13:26:56 Done.
Profile* profile = browser_->profile();
const int show_count = profile->GetPrefs()->GetInteger(
prefs::kProfileAvatarTutorialShown);
// Do not show the tutorial if user has dismissed it.
if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax)
- return NULL;
+ return false;
- if (!tutorial_shown) {
- if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax)
- return NULL;
- profile->GetPrefs()->SetInteger(
- prefs::kProfileAvatarTutorialShown, show_count + 1);
- }
+ return tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE ||
+ show_count != signin_ui_util::kUpgradeWelcomeTutorialShowMax;
+}
+
+bool ProfileChooserView::ShouldShowRightClickTutorialView() {
+ PrefService* local_state = g_browser_process->local_state();
+ const bool dismissed = local_state->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());
+}
+
+views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView(
+ const AvatarMenu::Item& avatar_item) {
ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW);
@@ -1643,6 +1676,19 @@ views::View* ProfileChooserView::CreateSigninErrorView() {
&tutorial_close_button_);
}
+views::View* ProfileChooserView::CreateRightClickTutorialView() {
+ return CreateTutorialView(
+ profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING,
+ l10n_util::GetStringUTF16(IDS_PROFILES_RIGHT_CLICK_TUTORIAL_TITLE),
+ l10n_util::GetStringUTF16(IDS_PROFILES_RIGHT_CLICK_TUTORIAL_CONTENT_TEXT),
+ base::string16(),
+ l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
+ false,
+ nullptr,
+ &tutorial_sync_settings_ok_button_,
+ nullptr);
+}
+
views::View* ProfileChooserView::CreateSwitchUserView() {
views::View* view = new views::View();
views::GridLayout* layout = CreateSingleColumnLayout(

Powered by Google App Engine
This is Rietveld 408576698