Chromium Code Reviews| 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/app/vector_icons/vector_icons.h" | 10 #include "chrome/app/vector_icons/vector_icons.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 // Spacing between the edge of the material design user menu and the | 109 // Spacing between the edge of the material design user menu and the |
| 110 // top/bottom or left/right of the menu items. | 110 // top/bottom or left/right of the menu items. |
| 111 const int kMenuEdgeMargin = 16; | 111 const int kMenuEdgeMargin = 16; |
| 112 | 112 |
| 113 const int kVerticalSpacing = 16; | 113 const int kVerticalSpacing = 16; |
| 114 | 114 |
| 115 const int kTitleViewNativeWidgetOffset = 8; | 115 const int kTitleViewNativeWidgetOffset = 8; |
| 116 | 116 |
| 117 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 117 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| 118 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 118 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
| 119 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | |
| 120 } | 119 } |
| 121 | 120 |
| 122 // DEPRECATED: New user menu components should use views::BoxLayout instead. | 121 // DEPRECATED: New user menu components should use views::BoxLayout instead. |
| 123 // Creates a GridLayout with a single column. This ensures that all the child | 122 // Creates a GridLayout with a single column. This ensures that all the child |
| 124 // views added get auto-expanded to fill the full width of the bubble. | 123 // views added get auto-expanded to fill the full width of the bubble. |
| 125 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { | 124 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
| 126 views::GridLayout* layout = new views::GridLayout(view); | 125 views::GridLayout* layout = new views::GridLayout(view); |
| 127 view->SetLayoutManager(layout); | 126 view->SetLayoutManager(layout); |
| 128 | 127 |
| 129 views::ColumnSet* columns = layout->AddColumnSet(0); | 128 views::ColumnSet* columns = layout->AddColumnSet(0); |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 | 525 |
| 527 // static | 526 // static |
| 528 void ProfileChooserView::ShowBubble( | 527 void ProfileChooserView::ShowBubble( |
| 529 profiles::BubbleViewMode view_mode, | 528 profiles::BubbleViewMode view_mode, |
| 530 profiles::TutorialMode tutorial_mode, | 529 profiles::TutorialMode tutorial_mode, |
| 531 const signin::ManageAccountsParams& manage_accounts_params, | 530 const signin::ManageAccountsParams& manage_accounts_params, |
| 532 signin_metrics::AccessPoint access_point, | 531 signin_metrics::AccessPoint access_point, |
| 533 views::View* anchor_view, | 532 views::View* anchor_view, |
| 534 Browser* browser, | 533 Browser* browser, |
| 535 bool is_source_keyboard) { | 534 bool is_source_keyboard) { |
| 536 // Don't start creating the view if it would be an empty fast user switcher. | |
| 537 // It has to happen here to prevent the view system from creating an empty | |
| 538 // container. | |
| 539 // Same for material design user menu since fast profile switcher will be | |
| 540 // migrated to the left-click menu. | |
| 541 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) | |
| 542 return; | |
| 543 | |
| 544 if (IsShowing()) { | 535 if (IsShowing()) { |
| 545 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 536 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
| 546 profile_bubble_->tutorial_mode_ = tutorial_mode; | 537 profile_bubble_->tutorial_mode_ = tutorial_mode; |
| 547 profile_bubble_->ShowViewFromMode(view_mode); | 538 profile_bubble_->ShowViewFromMode(view_mode); |
| 548 } | 539 } |
| 549 return; | 540 return; |
| 550 } | 541 } |
| 551 | 542 |
| 552 profile_bubble_ = | 543 profile_bubble_ = |
| 553 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, | 544 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 sub_view = CreateAccountRemovalView(); | 743 sub_view = CreateAccountRemovalView(); |
| 753 break; | 744 break; |
| 754 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 745 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
| 755 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 746 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
| 756 sub_view = CreateSwitchUserView(); | 747 sub_view = CreateSwitchUserView(); |
| 757 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 748 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
| 758 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 749 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
| 759 break; | 750 break; |
| 760 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 751 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
| 761 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 752 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
| 762 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | |
| 763 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 753 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
| 764 sub_view = CreateProfileChooserView(avatar_menu); | 754 sub_view = CreateProfileChooserView(avatar_menu); |
| 765 break; | 755 break; |
| 766 } | 756 } |
| 767 // Clears tutorial mode for all non-profile-chooser views. | 757 // Clears tutorial mode for all non-profile-chooser views. |
| 768 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 758 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
| 769 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 759 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
| 770 | 760 |
| 771 layout->StartRow(1, 0); | 761 layout->StartRow(1, 0); |
| 772 layout->AddView(sub_view); | 762 layout->AddView(sub_view); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1086 } | 1076 } |
| 1087 | 1077 |
| 1088 layout->StartRow(1, 0); | 1078 layout->StartRow(1, 0); |
| 1089 layout->AddView(CreateOtherProfilesView(other_profiles)); | 1079 layout->AddView(CreateOtherProfilesView(other_profiles)); |
| 1090 } | 1080 } |
| 1091 | 1081 |
| 1092 views::View* ProfileChooserView::CreateProfileChooserView( | 1082 views::View* ProfileChooserView::CreateProfileChooserView( |
| 1093 AvatarMenu* avatar_menu) { | 1083 AvatarMenu* avatar_menu) { |
| 1094 views::View* view = new views::View(); | 1084 views::View* view = new views::View(); |
| 1095 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1085 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 1096 | 1086 PopulateCompleteProfileChooserView(layout, avatar_menu); |
|
sky
2017/03/22 16:57:34
As PopulateCompleteProfileChooserView is only call
jlebel
2017/03/22 17:28:14
Done.
Also, I forgot to remove ProfileChooserView:
| |
| 1097 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { | |
| 1098 PopulateMinimalProfileChooserView(layout, avatar_menu); | |
| 1099 // The user is using right-click switching, no need to tell them about it. | |
| 1100 PrefService* local_state = g_browser_process->local_state(); | |
| 1101 local_state->SetBoolean( | |
| 1102 prefs::kProfileAvatarRightClickTutorialDismissed, true); | |
| 1103 } else { | |
| 1104 PopulateCompleteProfileChooserView(layout, avatar_menu); | |
| 1105 } | |
| 1106 | |
| 1107 return view; | 1087 return view; |
| 1108 } | 1088 } |
| 1109 | 1089 |
| 1110 void ProfileChooserView::DismissTutorial() { | 1090 void ProfileChooserView::DismissTutorial() { |
| 1111 // Never shows the upgrade tutorial again if manually closed. | 1091 // Never shows the upgrade tutorial again if manually closed. |
| 1112 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { | 1092 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { |
| 1113 browser_->profile()->GetPrefs()->SetInteger( | 1093 browser_->profile()->GetPrefs()->SetInteger( |
| 1114 prefs::kProfileAvatarTutorialShown, | 1094 prefs::kProfileAvatarTutorialShown, |
| 1115 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); | 1095 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); |
| 1116 } | 1096 } |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1966 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1946 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1967 IncognitoModePrefs::DISABLED; | 1947 IncognitoModePrefs::DISABLED; |
| 1968 return incognito_available && !browser_->profile()->IsGuestSession(); | 1948 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1969 } | 1949 } |
| 1970 | 1950 |
| 1971 void ProfileChooserView::PostActionPerformed( | 1951 void ProfileChooserView::PostActionPerformed( |
| 1972 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1952 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1973 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1953 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1974 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1954 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1975 } | 1955 } |
| OLD | NEW |