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

Side by Side 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: Rebase 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 profiles::TutorialMode tutorial_mode, 484 profiles::TutorialMode tutorial_mode,
485 const signin::ManageAccountsParams& manage_accounts_params, 485 const signin::ManageAccountsParams& manage_accounts_params,
486 views::View* anchor_view, 486 views::View* anchor_view,
487 views::BubbleBorder::Arrow arrow, 487 views::BubbleBorder::Arrow arrow,
488 views::BubbleBorder::BubbleAlignment border_alignment, 488 views::BubbleBorder::BubbleAlignment border_alignment,
489 Browser* browser) { 489 Browser* browser) {
490 // Don't start creating the view if it would be an empty fast user switcher. 490 // Don't start creating the view if it would be an empty fast user switcher.
491 // It has to happen here to prevent the view system from creating an empty 491 // It has to happen here to prevent the view system from creating an empty
492 // container. 492 // container.
493 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && 493 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
494 profiles::HasProfileSwitchTargets(browser->profile())) { 494 !profiles::HasProfileSwitchTargets(browser->profile())) {
495 return; 495 return;
496 } 496 }
497 497
498 if (IsShowing()) { 498 if (IsShowing()) {
499 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { 499 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
500 profile_bubble_->tutorial_mode_ = tutorial_mode; 500 profile_bubble_->tutorial_mode_ = tutorial_mode;
501 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); 501 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get());
502 } 502 }
503 return; 503 return;
504 } 504 }
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 views::View* current_profile_view = NULL; 906 views::View* current_profile_view = NULL;
907 views::View* current_profile_accounts = NULL; 907 views::View* current_profile_accounts = NULL;
908 views::View* option_buttons_view = NULL; 908 views::View* option_buttons_view = NULL;
909 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 909 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
910 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 910 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
911 if (item.active) { 911 if (item.active) {
912 option_buttons_view = CreateOptionsView( 912 option_buttons_view = CreateOptionsView(
913 item.signed_in && profiles::IsLockAvailable(browser_->profile())); 913 item.signed_in && profiles::IsLockAvailable(browser_->profile()));
914 current_profile_view = CreateCurrentProfileView(item, false); 914 current_profile_view = CreateCurrentProfileView(item, false);
915 if (IsProfileChooser(view_mode_)) { 915 if (IsProfileChooser(view_mode_)) {
916 switch (tutorial_mode_) { 916 tutorial_view = CreateTutorialViewIfNeeded(item);
917 case profiles::TUTORIAL_MODE_NONE:
918 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE:
919 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded(
920 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
921 item);
922 break;
923 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN:
924 tutorial_view = CreateSigninConfirmationView();
925 break;
926 case profiles::TUTORIAL_MODE_SHOW_ERROR:
927 tutorial_view = CreateSigninErrorView();
928 break;
929 }
930 } else { 917 } else {
931 current_profile_accounts = CreateCurrentProfileAccountsView(item); 918 current_profile_accounts = CreateCurrentProfileAccountsView(item);
932 } 919 }
933 } else { 920 } else {
934 other_profiles.push_back(i); 921 other_profiles.push_back(i);
935 } 922 }
936 } 923 }
937 924
938 if (tutorial_view) { 925 if (tutorial_view) {
939 // TODO(mlerman): update UMA stats for the new tutorial. 926 // TODO(mlerman): update UMA stats for the new tutorial.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 983
997 layout->StartRow(1, 0); 984 layout->StartRow(1, 0);
998 layout->AddView(CreateOtherProfilesView(other_profiles)); 985 layout->AddView(CreateOtherProfilesView(other_profiles));
999 } 986 }
1000 987
1001 views::View* ProfileChooserView::CreateProfileChooserView( 988 views::View* ProfileChooserView::CreateProfileChooserView(
1002 AvatarMenu* avatar_menu) { 989 AvatarMenu* avatar_menu) {
1003 views::View* view = new views::View(); 990 views::View* view = new views::View();
1004 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 991 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
1005 992
1006 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) 993 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
1007 PopulateMinimalProfileChooserView(layout, avatar_menu); 994 PopulateMinimalProfileChooserView(layout, avatar_menu);
1008 else 995 // The user is using right-click switching, no need to tell them about it.
996 PrefService* local_state = g_browser_process->local_state();
997 local_state->SetBoolean(
998 prefs::kProfileAvatarRightClickTutorialDismissed, true);
999 } else {
1009 PopulateCompleteProfileChooserView(layout, avatar_menu); 1000 PopulateCompleteProfileChooserView(layout, avatar_menu);
1001 }
1010 1002
1011 return view; 1003 return view;
1012 } 1004 }
1013 1005
1014 void ProfileChooserView::DismissTutorial() { 1006 void ProfileChooserView::DismissTutorial() {
1015 // Never shows the upgrade tutorial again if manually closed. 1007 // Never shows the upgrade tutorial again if manually closed.
1016 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { 1008 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1017 browser_->profile()->GetPrefs()->SetInteger( 1009 browser_->profile()->GetPrefs()->SetInteger(
1018 prefs::kProfileAvatarTutorialShown, 1010 prefs::kProfileAvatarTutorialShown,
1019 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); 1011 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
1020 } 1012 }
1021 1013
1014 if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) {
1015 PrefService* local_state = g_browser_process->local_state();
1016 local_state->SetBoolean(
1017 prefs::kProfileAvatarRightClickTutorialDismissed, true);
1018 }
1019
1022 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 1020 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
1023 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 1021 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
1024 } 1022 }
1025 1023
1024 views::View* ProfileChooserView::CreateTutorialViewIfNeeded(
1025 const AvatarMenu::Item& item) {
1026 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN)
1027 return CreateSigninConfirmationView();
1028
1029 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR)
1030 return CreateSigninErrorView();
1031
1032 if (profiles::ShouldShowWelcomeUpgradeTutorial(
1033 browser_->profile(), tutorial_mode_)) {
1034 if (tutorial_mode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1035 Profile* profile = browser_->profile();
1036 const int show_count = profile->GetPrefs()->GetInteger(
1037 prefs::kProfileAvatarTutorialShown);
1038 profile->GetPrefs()->SetInteger(
1039 prefs::kProfileAvatarTutorialShown, show_count + 1);
1040 }
1041
1042 return CreateWelcomeUpgradeTutorialView(item);
1043 }
1044
1045 if (profiles::ShouldShowRightClickTutorial(browser_->profile()))
1046 return CreateRightClickTutorialView();
1047
1048 return nullptr;
1049 }
1050
1026 views::View* ProfileChooserView::CreateTutorialView( 1051 views::View* ProfileChooserView::CreateTutorialView(
1027 profiles::TutorialMode tutorial_mode, 1052 profiles::TutorialMode tutorial_mode,
1028 const base::string16& title_text, 1053 const base::string16& title_text,
1029 const base::string16& content_text, 1054 const base::string16& content_text,
1030 const base::string16& link_text, 1055 const base::string16& link_text,
1031 const base::string16& button_text, 1056 const base::string16& button_text,
1032 bool stack_button, 1057 bool stack_button,
1033 views::Link** link, 1058 views::Link** link,
1034 views::LabelButton** button, 1059 views::LabelButton** button,
1035 views::ImageButton** close_button) { 1060 views::ImageButton** close_button) {
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 1590 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
1566 } 1591 }
1567 1592
1568 TitleCard* title_card = new TitleCard( 1593 TitleCard* title_card = new TitleCard(
1569 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1594 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1570 this, &account_removal_cancel_button_); 1595 this, &account_removal_cancel_button_);
1571 return TitleCard::AddPaddedTitleCard(view, title_card, 1596 return TitleCard::AddPaddedTitleCard(view, title_card,
1572 kFixedAccountRemovalViewWidth); 1597 kFixedAccountRemovalViewWidth);
1573 } 1598 }
1574 1599
1575 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( 1600 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView(
1576 bool tutorial_shown, const AvatarMenu::Item& avatar_item) { 1601 const AvatarMenu::Item& avatar_item) {
1577 Profile* profile = browser_->profile();
1578
1579 const int show_count = profile->GetPrefs()->GetInteger(
1580 prefs::kProfileAvatarTutorialShown);
1581 // Do not show the tutorial if user has dismissed it.
1582 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax)
1583 return NULL;
1584
1585 if (!tutorial_shown) {
1586 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax)
1587 return NULL;
1588 profile->GetPrefs()->SetInteger(
1589 prefs::kProfileAvatarTutorialShown, show_count + 1);
1590 }
1591 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( 1602 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
1592 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW); 1603 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW);
1593 1604
1594 // For local profiles, the "Not you" link doesn't make sense. 1605 // For local profiles, the "Not you" link doesn't make sense.
1595 base::string16 link_message = avatar_item.signed_in ? 1606 base::string16 link_message = avatar_item.signed_in ?
1596 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) : 1607 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) :
1597 base::string16(); 1608 base::string16();
1598 1609
1599 return CreateTutorialView( 1610 return CreateTutorialView(
1600 profiles::TUTORIAL_MODE_WELCOME_UPGRADE, 1611 profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 l10n_util::GetStringUTF16(IDS_PROFILES_ERROR_TUTORIAL_TITLE), 1647 l10n_util::GetStringUTF16(IDS_PROFILES_ERROR_TUTORIAL_TITLE),
1637 last_login_result, 1648 last_login_result,
1638 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 1649 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1639 base::string16(), 1650 base::string16(),
1640 false /* stack_button */, 1651 false /* stack_button */,
1641 &tutorial_learn_more_link_, 1652 &tutorial_learn_more_link_,
1642 NULL, 1653 NULL,
1643 &tutorial_close_button_); 1654 &tutorial_close_button_);
1644 } 1655 }
1645 1656
1657 views::View* ProfileChooserView::CreateRightClickTutorialView() {
1658 return CreateTutorialView(
1659 profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING,
1660 l10n_util::GetStringUTF16(IDS_PROFILES_RIGHT_CLICK_TUTORIAL_TITLE),
1661 l10n_util::GetStringUTF16(IDS_PROFILES_RIGHT_CLICK_TUTORIAL_CONTENT_TEXT),
1662 base::string16(),
1663 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
1664 false,
1665 nullptr,
1666 &tutorial_sync_settings_ok_button_,
1667 nullptr);
1668 }
1669
1646 views::View* ProfileChooserView::CreateSwitchUserView() { 1670 views::View* ProfileChooserView::CreateSwitchUserView() {
1647 views::View* view = new views::View(); 1671 views::View* view = new views::View();
1648 views::GridLayout* layout = CreateSingleColumnLayout( 1672 views::GridLayout* layout = CreateSingleColumnLayout(
1649 view, kFixedSwitchUserViewWidth); 1673 view, kFixedSwitchUserViewWidth);
1650 views::ColumnSet* columns = layout->AddColumnSet(1); 1674 views::ColumnSet* columns = layout->AddColumnSet(1);
1651 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1675 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew);
1652 int label_width = 1676 int label_width =
1653 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; 1677 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew;
1654 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1678 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1655 views::GridLayout::FIXED, label_width, label_width); 1679 views::GridLayout::FIXED, label_width, label_width);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1704 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1728 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1705 IncognitoModePrefs::DISABLED; 1729 IncognitoModePrefs::DISABLED;
1706 return incognito_available && !browser_->profile()->IsGuestSession(); 1730 return incognito_available && !browser_->profile()->IsGuestSession();
1707 } 1731 }
1708 1732
1709 void ProfileChooserView::PostActionPerformed( 1733 void ProfileChooserView::PostActionPerformed(
1710 ProfileMetrics::ProfileDesktopMenu action_performed) { 1734 ProfileMetrics::ProfileDesktopMenu action_performed) {
1711 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1735 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1712 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1736 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1713 } 1737 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698