OLD | NEW |
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/macros.h" | 7 #include "base/macros.h" |
8 #include "base/metrics/user_metrics.h" | 8 #include "base/metrics/user_metrics.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/lifetime/application_lifetime.h" | 11 #include "chrome/browser/lifetime/application_lifetime.h" |
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 12 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/profiles/profile_metrics.h" | 15 #include "chrome/browser/profiles/profile_metrics.h" |
16 #include "chrome/browser/profiles/profile_window.h" | 16 #include "chrome/browser/profiles/profile_window.h" |
17 #include "chrome/browser/profiles/profiles_state.h" | 17 #include "chrome/browser/profiles/profiles_state.h" |
18 #include "chrome/browser/signin/chrome_signin_helper.h" | 18 #include "chrome/browser/signin/chrome_signin_helper.h" |
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
20 #include "chrome/browser/signin/signin_error_controller_factory.h" | 20 #include "chrome/browser/signin/signin_error_controller_factory.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "chrome/browser/signin/signin_promo.h" | 22 #include "chrome/browser/signin/signin_promo.h" |
23 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
26 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
| 27 #include "chrome/browser/ui/browser_list.h" |
27 #include "chrome/browser/ui/chrome_pages.h" | 28 #include "chrome/browser/ui/chrome_pages.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 29 #include "chrome/browser/ui/singleton_tabs.h" |
29 #include "chrome/browser/ui/user_manager.h" | 30 #include "chrome/browser/ui/user_manager.h" |
30 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views
.h" | 31 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views
.h" |
31 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 32 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
32 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 33 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
33 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 34 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
36 #include "chrome/grit/chromium_strings.h" | 37 #include "chrome/grit/chromium_strings.h" |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 void ProfileChooserView::ShowBubble( | 624 void ProfileChooserView::ShowBubble( |
624 profiles::BubbleViewMode view_mode, | 625 profiles::BubbleViewMode view_mode, |
625 profiles::TutorialMode tutorial_mode, | 626 profiles::TutorialMode tutorial_mode, |
626 const signin::ManageAccountsParams& manage_accounts_params, | 627 const signin::ManageAccountsParams& manage_accounts_params, |
627 signin_metrics::AccessPoint access_point, | 628 signin_metrics::AccessPoint access_point, |
628 views::View* anchor_view, | 629 views::View* anchor_view, |
629 Browser* browser) { | 630 Browser* browser) { |
630 // Don't start creating the view if it would be an empty fast user switcher. | 631 // Don't start creating the view if it would be an empty fast user switcher. |
631 // It has to happen here to prevent the view system from creating an empty | 632 // It has to happen here to prevent the view system from creating an empty |
632 // container. | 633 // container. |
| 634 // Same for material design user menu since fast profile switcher will be |
| 635 // migrated to the left-click menu. |
633 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | 636 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && |
634 !profiles::HasProfileSwitchTargets(browser->profile())) { | 637 (!profiles::HasProfileSwitchTargets(browser->profile()) || |
| 638 switches::IsMaterialDesignUserMenu())) { |
635 return; | 639 return; |
636 } | 640 } |
637 | 641 |
638 if (IsShowing()) { | 642 if (IsShowing()) { |
639 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 643 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
640 profile_bubble_->tutorial_mode_ = tutorial_mode; | 644 profile_bubble_->tutorial_mode_ = tutorial_mode; |
641 profile_bubble_->ShowViewFromMode(view_mode); | 645 profile_bubble_->ShowViewFromMode(view_mode); |
642 } | 646 } |
643 return; | 647 return; |
644 } | 648 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 ProfileOAuth2TokenService* oauth2_token_service = | 690 ProfileOAuth2TokenService* oauth2_token_service = |
687 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 691 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
688 if (oauth2_token_service) | 692 if (oauth2_token_service) |
689 oauth2_token_service->RemoveObserver(this); | 693 oauth2_token_service->RemoveObserver(this); |
690 } | 694 } |
691 | 695 |
692 void ProfileChooserView::ResetView() { | 696 void ProfileChooserView::ResetView() { |
693 open_other_profile_indexes_map_.clear(); | 697 open_other_profile_indexes_map_.clear(); |
694 delete_account_button_map_.clear(); | 698 delete_account_button_map_.clear(); |
695 reauth_account_button_map_.clear(); | 699 reauth_account_button_map_.clear(); |
696 manage_accounts_link_ = NULL; | 700 manage_accounts_link_ = nullptr; |
697 signin_current_profile_link_ = NULL; | 701 signin_current_profile_link_ = nullptr; |
698 auth_error_email_button_ = NULL; | 702 auth_error_email_button_ = nullptr; |
699 current_profile_photo_ = NULL; | 703 current_profile_photo_ = nullptr; |
700 current_profile_name_ = NULL; | 704 current_profile_name_ = nullptr; |
701 users_button_ = NULL; | 705 guest_profile_button_ = nullptr; |
702 go_incognito_button_ = NULL; | 706 users_button_ = nullptr; |
703 lock_button_ = NULL; | 707 go_incognito_button_ = nullptr; |
704 add_account_link_ = NULL; | 708 lock_button_ = nullptr; |
705 gaia_signin_cancel_button_ = NULL; | 709 close_all_windows_button_ = nullptr; |
706 remove_account_button_ = NULL; | 710 add_account_link_ = nullptr; |
707 account_removal_cancel_button_ = NULL; | 711 gaia_signin_cancel_button_ = nullptr; |
708 add_person_button_ = NULL; | 712 remove_account_button_ = nullptr; |
709 disconnect_button_ = NULL; | 713 account_removal_cancel_button_ = nullptr; |
710 switch_user_cancel_button_ = NULL; | 714 add_person_button_ = nullptr; |
711 tutorial_sync_settings_ok_button_ = NULL; | 715 disconnect_button_ = nullptr; |
712 tutorial_close_button_ = NULL; | 716 switch_user_cancel_button_ = nullptr; |
713 tutorial_sync_settings_link_ = NULL; | 717 tutorial_sync_settings_ok_button_ = nullptr; |
714 tutorial_see_whats_new_button_ = NULL; | 718 tutorial_close_button_ = nullptr; |
715 tutorial_not_you_link_ = NULL; | 719 tutorial_sync_settings_link_ = nullptr; |
716 tutorial_learn_more_link_ = NULL; | 720 tutorial_see_whats_new_button_ = nullptr; |
| 721 tutorial_not_you_link_ = nullptr; |
| 722 tutorial_learn_more_link_ = nullptr; |
717 } | 723 } |
718 | 724 |
719 void ProfileChooserView::Init() { | 725 void ProfileChooserView::Init() { |
720 set_close_on_deactivate(close_on_deactivate_for_testing_); | 726 set_close_on_deactivate(close_on_deactivate_for_testing_); |
721 | 727 |
722 avatar_menu_.reset(new AvatarMenu( | 728 avatar_menu_.reset(new AvatarMenu( |
723 &g_browser_process->profile_manager()->GetProfileAttributesStorage(), | 729 &g_browser_process->profile_manager()->GetProfileAttributesStorage(), |
724 this, browser_)); | 730 this, browser_)); |
725 avatar_menu_->RebuildMenu(); | 731 avatar_menu_->RebuildMenu(); |
726 | 732 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 | 901 |
896 bool ProfileChooserView::HandleContextMenu( | 902 bool ProfileChooserView::HandleContextMenu( |
897 const content::ContextMenuParams& params) { | 903 const content::ContextMenuParams& params) { |
898 // Suppresses the context menu because some features, such as inspecting | 904 // Suppresses the context menu because some features, such as inspecting |
899 // elements, are not appropriate in a bubble. | 905 // elements, are not appropriate in a bubble. |
900 return true; | 906 return true; |
901 } | 907 } |
902 | 908 |
903 void ProfileChooserView::ButtonPressed(views::Button* sender, | 909 void ProfileChooserView::ButtonPressed(views::Button* sender, |
904 const ui::Event& event) { | 910 const ui::Event& event) { |
905 if (sender == users_button_) { | 911 if (sender == guest_profile_button_) { |
| 912 PrefService* service = g_browser_process->local_state(); |
| 913 DCHECK(service); |
| 914 DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled)); |
| 915 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); |
| 916 } else if (sender == users_button_) { |
906 // If this is a guest session, close all the guest browser windows. | 917 // If this is a guest session, close all the guest browser windows. |
907 if (browser_->profile()->IsGuestSession()) { | 918 if (browser_->profile()->IsGuestSession()) { |
908 profiles::CloseGuestProfileWindows(); | 919 profiles::CloseGuestProfileWindows(); |
909 } else { | 920 } else { |
910 UserManager::Show(base::FilePath(), | 921 UserManager::Show(base::FilePath(), |
911 profiles::USER_MANAGER_NO_TUTORIAL, | 922 profiles::USER_MANAGER_NO_TUTORIAL, |
912 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 923 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
913 } | 924 } |
914 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 925 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
915 } else if (sender == go_incognito_button_) { | 926 } else if (sender == go_incognito_button_) { |
916 DCHECK(ShouldShowGoIncognito()); | 927 DCHECK(ShouldShowGoIncognito()); |
917 chrome::NewIncognitoWindow(browser_); | 928 chrome::NewIncognitoWindow(browser_); |
918 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); | 929 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); |
919 } else if (sender == lock_button_) { | 930 } else if (sender == lock_button_) { |
920 profiles::LockProfile(browser_->profile()); | 931 profiles::LockProfile(browser_->profile()); |
921 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 932 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
| 933 } else if (sender == close_all_windows_button_) { |
| 934 profiles::CloseProfileWindows(browser_->profile()); |
922 } else if (sender == auth_error_email_button_) { | 935 } else if (sender == auth_error_email_button_) { |
923 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 936 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
924 } else if (sender == tutorial_sync_settings_ok_button_) { | 937 } else if (sender == tutorial_sync_settings_ok_button_) { |
925 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 938 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
926 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | 939 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); |
927 DismissTutorial(); | 940 DismissTutorial(); |
928 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 941 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
929 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); | 942 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); |
930 } else if (sender == tutorial_close_button_) { | 943 } else if (sender == tutorial_close_button_) { |
931 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && | 944 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 // Separate items into active and alternatives. | 1097 // Separate items into active and alternatives. |
1085 Indexes other_profiles; | 1098 Indexes other_profiles; |
1086 views::View* tutorial_view = NULL; | 1099 views::View* tutorial_view = NULL; |
1087 views::View* current_profile_view = NULL; | 1100 views::View* current_profile_view = NULL; |
1088 views::View* current_profile_accounts = NULL; | 1101 views::View* current_profile_accounts = NULL; |
1089 views::View* option_buttons_view = NULL; | 1102 views::View* option_buttons_view = NULL; |
1090 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1103 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1091 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1104 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1092 if (item.active) { | 1105 if (item.active) { |
1093 option_buttons_view = CreateOptionsView( | 1106 option_buttons_view = CreateOptionsView( |
1094 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1107 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
| 1108 avatar_menu); |
1095 current_profile_view = CreateCurrentProfileView(item, false); | 1109 current_profile_view = CreateCurrentProfileView(item, false); |
1096 if (IsProfileChooser(view_mode_)) { | 1110 if (IsProfileChooser(view_mode_)) { |
1097 tutorial_view = CreateTutorialViewIfNeeded(item); | 1111 tutorial_view = CreateTutorialViewIfNeeded(item); |
1098 } else { | 1112 } else { |
1099 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1113 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1100 } | 1114 } |
1101 } else { | 1115 } else { |
1102 other_profiles.push_back(i); | 1116 other_profiles.push_back(i); |
1103 } | 1117 } |
1104 } | 1118 } |
1105 | 1119 |
1106 if (tutorial_view) { | 1120 if (tutorial_view) { |
1107 // TODO(mlerman): update UMA stats for the new tutorial. | 1121 // TODO(mlerman): update UMA stats for the new tutorial. |
1108 layout->StartRow(1, 0); | 1122 layout->StartRow(1, 0); |
1109 layout->AddView(tutorial_view); | 1123 layout->AddView(tutorial_view); |
1110 } else { | 1124 } else { |
1111 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 1125 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
1112 } | 1126 } |
1113 | 1127 |
1114 if (!current_profile_view) { | 1128 if (!current_profile_view) { |
1115 // Guest windows don't have an active profile. | 1129 // Guest windows don't have an active profile. |
1116 current_profile_view = CreateGuestProfileView(); | 1130 current_profile_view = CreateGuestProfileView(); |
1117 option_buttons_view = CreateOptionsView(false); | 1131 option_buttons_view = CreateOptionsView(false, avatar_menu); |
1118 } | 1132 } |
1119 | 1133 |
1120 layout->StartRow(1, 0); | 1134 layout->StartRow(1, 0); |
1121 layout->AddView(current_profile_view); | 1135 layout->AddView(current_profile_view); |
1122 | 1136 |
1123 if (!IsProfileChooser(view_mode_)) { | 1137 if (!IsProfileChooser(view_mode_)) { |
1124 DCHECK(current_profile_accounts); | 1138 DCHECK(current_profile_accounts); |
1125 layout->StartRow(0, 0); | 1139 layout->StartRow(0, 0); |
1126 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1140 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1127 layout->StartRow(1, 0); | 1141 layout->StartRow(1, 0); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 | 1505 |
1492 layout->StartRow(1, 0); | 1506 layout->StartRow(1, 0); |
1493 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1507 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1494 layout->StartRow(1, 0); | 1508 layout->StartRow(1, 0); |
1495 layout->AddView(button); | 1509 layout->AddView(button); |
1496 } | 1510 } |
1497 | 1511 |
1498 return view; | 1512 return view; |
1499 } | 1513 } |
1500 | 1514 |
1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1515 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| 1516 AvatarMenu* avatar_menu) { |
1502 views::View* view = new views::View(); | 1517 views::View* view = new views::View(); |
1503 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1518 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
1504 | 1519 |
| 1520 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; |
| 1521 if (switches::IsMaterialDesignUserMenu()) { |
| 1522 // Add the user switching buttons |
| 1523 const int kProfileIconSize = 18; |
| 1524 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 1525 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1526 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1527 if (!item.active) { |
| 1528 gfx::Image image = profiles::GetSizedAvatarIcon( |
| 1529 item.icon, true, kProfileIconSize, kProfileIconSize, |
| 1530 profiles::SHAPE_CIRCLE); |
| 1531 views::LabelButton* button = new BackgroundColorHoverButton( |
| 1532 this, profiles::GetProfileSwitcherTextForItem(item), |
| 1533 *image.ToImageSkia()); |
| 1534 open_other_profile_indexes_map_[button] = i; |
| 1535 |
| 1536 layout->StartRow(1, 0); |
| 1537 layout->AddView(button); |
| 1538 } |
| 1539 } |
| 1540 |
| 1541 // Add the "Guest" button for browsing as guest |
| 1542 if (!browser_->profile()->IsGuestSession()) { |
| 1543 PrefService* service = g_browser_process->local_state(); |
| 1544 DCHECK(service); |
| 1545 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| 1546 guest_profile_button_ = new BackgroundColorHoverButton( |
| 1547 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| 1548 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, kIconSize, |
| 1549 gfx::kChromeIconGrey)); |
| 1550 layout->StartRow(1, 0); |
| 1551 layout->AddView(guest_profile_button_); |
| 1552 } |
| 1553 } |
| 1554 } |
| 1555 |
1505 base::string16 text = browser_->profile()->IsGuestSession() ? | 1556 base::string16 text = browser_->profile()->IsGuestSession() ? |
1506 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1557 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1507 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1558 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
| 1559 gfx::VectorIconId settings_icon = gfx::VectorIconId::ACCOUNT_BOX; |
1508 if (!browser_->profile()->IsGuestSession() | 1560 if (!browser_->profile()->IsGuestSession() |
1509 && switches::IsMaterialDesignUserMenu()) { | 1561 && switches::IsMaterialDesignUserMenu()) { |
1510 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1562 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
| 1563 settings_icon = gfx::VectorIconId::SETTINGS; |
1511 } | 1564 } |
1512 const int kIconSize = 16; | |
1513 | |
1514 gfx::VectorIconId settings_icon = switches::IsMaterialDesignUserMenu() ? | |
1515 gfx::VectorIconId::SETTINGS : gfx::VectorIconId::ACCOUNT_BOX; | |
1516 users_button_ = new BackgroundColorHoverButton( | 1565 users_button_ = new BackgroundColorHoverButton( |
1517 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, | 1566 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, |
1518 gfx::kChromeIconGrey)); | 1567 gfx::kChromeIconGrey)); |
1519 | 1568 |
1520 layout->StartRow(1, 0); | 1569 layout->StartRow(1, 0); |
1521 layout->AddView(users_button_); | 1570 layout->AddView(users_button_); |
1522 | 1571 |
1523 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | 1572 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { |
1524 layout->StartRow(1, 0); | 1573 layout->StartRow(1, 0); |
1525 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1574 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1526 | 1575 |
1527 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1576 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1528 go_incognito_button_ = new BackgroundColorHoverButton( | 1577 go_incognito_button_ = new BackgroundColorHoverButton( |
1529 this, | 1578 this, |
1530 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | 1579 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), |
1531 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | 1580 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); |
1532 layout->StartRow(1, 0); | 1581 layout->StartRow(1, 0); |
1533 layout->AddView(go_incognito_button_); | 1582 layout->AddView(go_incognito_button_); |
1534 } | 1583 } |
1535 | 1584 |
1536 if (display_lock) { | 1585 if (display_lock) { |
1537 layout->StartRow(1, 0); | 1586 if (!switches::IsMaterialDesignUserMenu()) { |
1538 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1587 layout->StartRow(1, 0); |
| 1588 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
| 1589 } |
1539 | 1590 |
1540 lock_button_ = new BackgroundColorHoverButton( | 1591 lock_button_ = new BackgroundColorHoverButton( |
1541 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1592 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
1542 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | 1593 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
1543 gfx::kChromeIconGrey)); | 1594 gfx::kChromeIconGrey)); |
1544 layout->StartRow(1, 0); | 1595 layout->StartRow(1, 0); |
1545 layout->AddView(lock_button_); | 1596 layout->AddView(lock_button_); |
| 1597 } else if (switches::IsMaterialDesignUserMenu() && |
| 1598 !browser_->profile()->IsGuestSession()) { |
| 1599 int num_browsers = 0; |
| 1600 for (auto* browser : *BrowserList::GetInstance()) { |
| 1601 if (browser->profile()->GetOriginalProfile() == |
| 1602 browser_->profile()->GetOriginalProfile()) |
| 1603 num_browsers++; |
| 1604 } |
| 1605 if (num_browsers > 1) { |
| 1606 close_all_windows_button_ = new BackgroundColorHoverButton( |
| 1607 this, |
| 1608 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), |
| 1609 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
| 1610 gfx::kChromeIconGrey)); |
| 1611 layout->StartRow(1, 0); |
| 1612 layout->AddView(close_all_windows_button_); |
| 1613 } |
1546 } | 1614 } |
| 1615 |
| 1616 if (switches::IsMaterialDesignUserMenu()) |
| 1617 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1547 return view; | 1618 return view; |
1548 } | 1619 } |
1549 | 1620 |
1550 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1621 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1551 views::View* view = new views::View(); | 1622 views::View* view = new views::View(); |
1552 views::GridLayout* layout = CreateSingleColumnLayout( | 1623 views::GridLayout* layout = CreateSingleColumnLayout( |
1553 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1624 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
1554 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1625 layout->SetInsets(views::kRelatedControlVerticalSpacing, |
1555 views::kButtonHEdgeMarginNew, | 1626 views::kButtonHEdgeMarginNew, |
1556 views::kRelatedControlVerticalSpacing, | 1627 views::kRelatedControlVerticalSpacing, |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1897 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1968 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1898 IncognitoModePrefs::DISABLED; | 1969 IncognitoModePrefs::DISABLED; |
1899 return incognito_available && !browser_->profile()->IsGuestSession(); | 1970 return incognito_available && !browser_->profile()->IsGuestSession(); |
1900 } | 1971 } |
1901 | 1972 |
1902 void ProfileChooserView::PostActionPerformed( | 1973 void ProfileChooserView::PostActionPerformed( |
1903 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1974 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1904 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1975 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1905 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1976 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1906 } | 1977 } |
OLD | NEW |