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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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_ = NULL; |
697 signin_current_profile_link_ = NULL; | 701 signin_current_profile_link_ = NULL; |
698 auth_error_email_button_ = NULL; | 702 auth_error_email_button_ = NULL; |
699 current_profile_photo_ = NULL; | 703 current_profile_photo_ = NULL; |
700 current_profile_name_ = NULL; | 704 current_profile_name_ = NULL; |
705 guest_profile_button_ = NULL; | |
sky
2016/06/27 22:49:36
nullptr (feel free to change all NULLs in this fun
Jane
2016/06/28 13:44:25
Done.
| |
701 users_button_ = NULL; | 706 users_button_ = NULL; |
702 go_incognito_button_ = NULL; | 707 go_incognito_button_ = NULL; |
703 lock_button_ = NULL; | 708 lock_button_ = NULL; |
709 close_all_windows_button_ = NULL; | |
704 add_account_link_ = NULL; | 710 add_account_link_ = NULL; |
705 gaia_signin_cancel_button_ = NULL; | 711 gaia_signin_cancel_button_ = NULL; |
706 remove_account_button_ = NULL; | 712 remove_account_button_ = NULL; |
707 account_removal_cancel_button_ = NULL; | 713 account_removal_cancel_button_ = NULL; |
708 add_person_button_ = NULL; | 714 add_person_button_ = NULL; |
709 disconnect_button_ = NULL; | 715 disconnect_button_ = NULL; |
710 switch_user_cancel_button_ = NULL; | 716 switch_user_cancel_button_ = NULL; |
711 tutorial_sync_settings_ok_button_ = NULL; | 717 tutorial_sync_settings_ok_button_ = NULL; |
712 tutorial_close_button_ = NULL; | 718 tutorial_close_button_ = NULL; |
713 tutorial_sync_settings_link_ = NULL; | 719 tutorial_sync_settings_link_ = NULL; |
(...skipping 181 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_) { |
sky
2016/06/27 22:49:36
guest_profile_button_ and/or close_all_windows_but
Jane
2016/06/28 13:44:25
Sorry, I'm confused. The sender button can't be nu
sky
2016/06/28 19:10:02
I find it confusing that you can be checking again
| |
912 PrefService* service = g_browser_process->local_state(); | |
913 DCHECK(service); | |
914 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | |
915 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); | |
916 } else { | |
917 // The UI should have prevented the user from allowing the selection of | |
sky
2016/06/27 22:49:36
914 should be a DCHECK and not an if.
Jane
2016/06/28 13:44:25
Done.
| |
918 // guest mode. | |
919 NOTREACHED(); | |
920 } | |
921 } else if (sender == users_button_) { | |
906 // If this is a guest session, close all the guest browser windows. | 922 // If this is a guest session, close all the guest browser windows. |
907 if (browser_->profile()->IsGuestSession()) { | 923 if (browser_->profile()->IsGuestSession()) { |
908 profiles::CloseGuestProfileWindows(); | 924 profiles::CloseGuestProfileWindows(); |
909 } else { | 925 } else { |
910 UserManager::Show(base::FilePath(), | 926 UserManager::Show(base::FilePath(), |
911 profiles::USER_MANAGER_NO_TUTORIAL, | 927 profiles::USER_MANAGER_NO_TUTORIAL, |
912 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 928 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
913 } | 929 } |
914 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 930 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
915 } else if (sender == go_incognito_button_) { | 931 } else if (sender == go_incognito_button_) { |
916 DCHECK(ShouldShowGoIncognito()); | 932 DCHECK(ShouldShowGoIncognito()); |
917 chrome::NewIncognitoWindow(browser_); | 933 chrome::NewIncognitoWindow(browser_); |
918 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); | 934 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); |
919 } else if (sender == lock_button_) { | 935 } else if (sender == lock_button_) { |
920 profiles::LockProfile(browser_->profile()); | 936 profiles::LockProfile(browser_->profile()); |
921 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 937 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
938 } else if (sender == close_all_windows_button_) { | |
939 profiles::CloseProfileWindows(browser_->profile()); | |
922 } else if (sender == auth_error_email_button_) { | 940 } else if (sender == auth_error_email_button_) { |
923 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 941 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
924 } else if (sender == tutorial_sync_settings_ok_button_) { | 942 } else if (sender == tutorial_sync_settings_ok_button_) { |
925 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 943 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
926 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | 944 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); |
927 DismissTutorial(); | 945 DismissTutorial(); |
928 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 946 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
929 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); | 947 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); |
930 } else if (sender == tutorial_close_button_) { | 948 } else if (sender == tutorial_close_button_) { |
931 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && | 949 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. | 1102 // Separate items into active and alternatives. |
1085 Indexes other_profiles; | 1103 Indexes other_profiles; |
1086 views::View* tutorial_view = NULL; | 1104 views::View* tutorial_view = NULL; |
1087 views::View* current_profile_view = NULL; | 1105 views::View* current_profile_view = NULL; |
1088 views::View* current_profile_accounts = NULL; | 1106 views::View* current_profile_accounts = NULL; |
1089 views::View* option_buttons_view = NULL; | 1107 views::View* option_buttons_view = NULL; |
1090 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1108 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
1091 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1109 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
1092 if (item.active) { | 1110 if (item.active) { |
1093 option_buttons_view = CreateOptionsView( | 1111 option_buttons_view = CreateOptionsView( |
1094 item.signed_in && profiles::IsLockAvailable(browser_->profile())); | 1112 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
1113 avatar_menu); | |
1095 current_profile_view = CreateCurrentProfileView(item, false); | 1114 current_profile_view = CreateCurrentProfileView(item, false); |
1096 if (IsProfileChooser(view_mode_)) { | 1115 if (IsProfileChooser(view_mode_)) { |
1097 tutorial_view = CreateTutorialViewIfNeeded(item); | 1116 tutorial_view = CreateTutorialViewIfNeeded(item); |
1098 } else { | 1117 } else { |
1099 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 1118 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
1100 } | 1119 } |
1101 } else { | 1120 } else { |
1102 other_profiles.push_back(i); | 1121 other_profiles.push_back(i); |
1103 } | 1122 } |
1104 } | 1123 } |
1105 | 1124 |
1106 if (tutorial_view) { | 1125 if (tutorial_view) { |
1107 // TODO(mlerman): update UMA stats for the new tutorial. | 1126 // TODO(mlerman): update UMA stats for the new tutorial. |
1108 layout->StartRow(1, 0); | 1127 layout->StartRow(1, 0); |
1109 layout->AddView(tutorial_view); | 1128 layout->AddView(tutorial_view); |
1110 } else { | 1129 } else { |
1111 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 1130 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
1112 } | 1131 } |
1113 | 1132 |
1114 if (!current_profile_view) { | 1133 if (!current_profile_view) { |
1115 // Guest windows don't have an active profile. | 1134 // Guest windows don't have an active profile. |
1116 current_profile_view = CreateGuestProfileView(); | 1135 current_profile_view = CreateGuestProfileView(); |
1117 option_buttons_view = CreateOptionsView(false); | 1136 option_buttons_view = CreateOptionsView(false, avatar_menu); |
1118 } | 1137 } |
1119 | 1138 |
1120 layout->StartRow(1, 0); | 1139 layout->StartRow(1, 0); |
1121 layout->AddView(current_profile_view); | 1140 layout->AddView(current_profile_view); |
1122 | 1141 |
1123 if (!IsProfileChooser(view_mode_)) { | 1142 if (!IsProfileChooser(view_mode_)) { |
1124 DCHECK(current_profile_accounts); | 1143 DCHECK(current_profile_accounts); |
1125 layout->StartRow(0, 0); | 1144 layout->StartRow(0, 0); |
1126 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1145 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1127 layout->StartRow(1, 0); | 1146 layout->StartRow(1, 0); |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1491 | 1510 |
1492 layout->StartRow(1, 0); | 1511 layout->StartRow(1, 0); |
1493 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1512 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1494 layout->StartRow(1, 0); | 1513 layout->StartRow(1, 0); |
1495 layout->AddView(button); | 1514 layout->AddView(button); |
1496 } | 1515 } |
1497 | 1516 |
1498 return view; | 1517 return view; |
1499 } | 1518 } |
1500 | 1519 |
1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { | 1520 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
1521 AvatarMenu* avatar_menu) { | |
1502 views::View* view = new views::View(); | 1522 views::View* view = new views::View(); |
1503 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1523 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
1504 | 1524 |
1525 const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; | |
1526 if (switches::IsMaterialDesignUserMenu()) { | |
1527 // Add the user switching buttons | |
1528 const int kProfileIconSize = 18; | |
1529 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | |
1530 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | |
1531 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | |
1532 if (!item.active) { | |
1533 gfx::Image image = profiles::GetSizedAvatarIcon( | |
1534 item.icon, true, kProfileIconSize, kProfileIconSize, | |
1535 profiles::SHAPE_CIRCLE); | |
1536 views::LabelButton* button = new BackgroundColorHoverButton( | |
1537 this, profiles::GetProfileSwitcherTextForItem(item), | |
1538 *image.ToImageSkia()); | |
1539 open_other_profile_indexes_map_[button] = i; | |
1540 | |
1541 layout->StartRow(1, 0); | |
1542 layout->AddView(button); | |
1543 } | |
1544 } | |
1545 | |
1546 // Add the "Guest" button for browsing as guest | |
1547 if (!browser_->profile()->IsGuestSession()) { | |
1548 PrefService* service = g_browser_process->local_state(); | |
1549 DCHECK(service); | |
1550 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | |
1551 guest_profile_button_ = new BackgroundColorHoverButton( | |
1552 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | |
1553 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, kIconSize, | |
1554 gfx::kChromeIconGrey)); | |
1555 layout->StartRow(1, 0); | |
1556 layout->AddView(guest_profile_button_); | |
1557 } | |
1558 } | |
1559 } | |
1560 | |
1505 base::string16 text = browser_->profile()->IsGuestSession() ? | 1561 base::string16 text = browser_->profile()->IsGuestSession() ? |
1506 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1562 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
1507 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1563 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
1564 gfx::VectorIconId settings_icon = gfx::VectorIconId::ACCOUNT_BOX; | |
1508 if (!browser_->profile()->IsGuestSession() | 1565 if (!browser_->profile()->IsGuestSession() |
1509 && switches::IsMaterialDesignUserMenu()) { | 1566 && switches::IsMaterialDesignUserMenu()) { |
1510 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1567 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
1568 settings_icon = gfx::VectorIconId::SETTINGS; | |
1511 } | 1569 } |
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( | 1570 users_button_ = new BackgroundColorHoverButton( |
1517 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, | 1571 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, |
1518 gfx::kChromeIconGrey)); | 1572 gfx::kChromeIconGrey)); |
1519 | 1573 |
1520 layout->StartRow(1, 0); | 1574 layout->StartRow(1, 0); |
1521 layout->AddView(users_button_); | 1575 layout->AddView(users_button_); |
1522 | 1576 |
1523 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | 1577 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { |
1524 layout->StartRow(1, 0); | 1578 layout->StartRow(1, 0); |
1525 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1579 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
1526 | 1580 |
1527 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1581 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
1528 go_incognito_button_ = new BackgroundColorHoverButton( | 1582 go_incognito_button_ = new BackgroundColorHoverButton( |
1529 this, | 1583 this, |
1530 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | 1584 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), |
1531 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | 1585 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); |
1532 layout->StartRow(1, 0); | 1586 layout->StartRow(1, 0); |
1533 layout->AddView(go_incognito_button_); | 1587 layout->AddView(go_incognito_button_); |
1534 } | 1588 } |
1535 | 1589 |
1536 if (display_lock) { | 1590 if (display_lock) { |
1537 layout->StartRow(1, 0); | 1591 if (!switches::IsMaterialDesignUserMenu()) { |
1538 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 1592 layout->StartRow(1, 0); |
1593 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | |
1594 } | |
1539 | 1595 |
1540 lock_button_ = new BackgroundColorHoverButton( | 1596 lock_button_ = new BackgroundColorHoverButton( |
1541 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 1597 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
1542 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | 1598 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
1543 gfx::kChromeIconGrey)); | 1599 gfx::kChromeIconGrey)); |
1544 layout->StartRow(1, 0); | 1600 layout->StartRow(1, 0); |
1545 layout->AddView(lock_button_); | 1601 layout->AddView(lock_button_); |
1602 } else if (switches::IsMaterialDesignUserMenu() && | |
1603 !browser_->profile()->IsGuestSession()) { | |
1604 int num_browsers = 0; | |
1605 for (auto* browser : *BrowserList::GetInstance()) { | |
1606 if (browser->profile()->GetOriginalProfile() == | |
1607 browser_->profile()->GetOriginalProfile()) | |
1608 num_browsers++; | |
1609 } | |
1610 if (num_browsers > 1) { | |
1611 close_all_windows_button_ = new BackgroundColorHoverButton( | |
1612 this, | |
1613 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), | |
1614 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | |
1615 gfx::kChromeIconGrey)); | |
1616 layout->StartRow(1, 0); | |
1617 layout->AddView(close_all_windows_button_); | |
1618 } | |
1619 } | |
1620 | |
1621 if (switches::IsMaterialDesignUserMenu()) { | |
sky
2016/06/27 22:49:36
nit: no {}
Jane
2016/06/28 13:44:25
Done.
| |
1622 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | |
1546 } | 1623 } |
1547 return view; | 1624 return view; |
1548 } | 1625 } |
1549 | 1626 |
1550 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { | 1627 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
1551 views::View* view = new views::View(); | 1628 views::View* view = new views::View(); |
1552 views::GridLayout* layout = CreateSingleColumnLayout( | 1629 views::GridLayout* layout = CreateSingleColumnLayout( |
1553 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | 1630 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
1554 layout->SetInsets(views::kRelatedControlVerticalSpacing, | 1631 layout->SetInsets(views::kRelatedControlVerticalSpacing, |
1555 views::kButtonHEdgeMarginNew, | 1632 views::kButtonHEdgeMarginNew, |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1897 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1974 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1898 IncognitoModePrefs::DISABLED; | 1975 IncognitoModePrefs::DISABLED; |
1899 return incognito_available && !browser_->profile()->IsGuestSession(); | 1976 return incognito_available && !browser_->profile()->IsGuestSession(); |
1900 } | 1977 } |
1901 | 1978 |
1902 void ProfileChooserView::PostActionPerformed( | 1979 void ProfileChooserView::PostActionPerformed( |
1903 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1980 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1904 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1981 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1905 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1982 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1906 } | 1983 } |
OLD | NEW |