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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2687693002: Linux/Windows: Setting focus to the first profile in profile switcher (Closed)
Patch Set: Renaming |focus_first_profile| to |is_source_keyboard| Created 3 years, 10 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
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/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"
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 751 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
752 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 752 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
753 753
754 // static 754 // static
755 void ProfileChooserView::ShowBubble( 755 void ProfileChooserView::ShowBubble(
756 profiles::BubbleViewMode view_mode, 756 profiles::BubbleViewMode view_mode,
757 profiles::TutorialMode tutorial_mode, 757 profiles::TutorialMode tutorial_mode,
758 const signin::ManageAccountsParams& manage_accounts_params, 758 const signin::ManageAccountsParams& manage_accounts_params,
759 signin_metrics::AccessPoint access_point, 759 signin_metrics::AccessPoint access_point,
760 views::View* anchor_view, 760 views::View* anchor_view,
761 Browser* browser) { 761 Browser* browser,
762 bool is_source_keyboard) {
762 // Don't start creating the view if it would be an empty fast user switcher. 763 // Don't start creating the view if it would be an empty fast user switcher.
763 // It has to happen here to prevent the view system from creating an empty 764 // It has to happen here to prevent the view system from creating an empty
764 // container. 765 // container.
765 // Same for material design user menu since fast profile switcher will be 766 // Same for material design user menu since fast profile switcher will be
766 // migrated to the left-click menu. 767 // migrated to the left-click menu.
767 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && 768 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
768 (!profiles::HasProfileSwitchTargets(browser->profile()) || 769 (!profiles::HasProfileSwitchTargets(browser->profile()) ||
769 switches::IsMaterialDesignUserMenu())) { 770 switches::IsMaterialDesignUserMenu())) {
770 return; 771 return;
771 } 772 }
772 773
773 if (IsShowing()) { 774 if (IsShowing()) {
774 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { 775 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
775 profile_bubble_->tutorial_mode_ = tutorial_mode; 776 profile_bubble_->tutorial_mode_ = tutorial_mode;
776 profile_bubble_->ShowViewFromMode(view_mode); 777 profile_bubble_->ShowViewFromMode(view_mode);
777 } 778 }
778 return; 779 return;
779 } 780 }
780 781
781 profile_bubble_ = 782 profile_bubble_ =
782 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, 783 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode,
783 manage_accounts_params.service_type, access_point); 784 manage_accounts_params.service_type, access_point);
784 views::Widget* widget = 785 views::Widget* widget =
785 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); 786 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_);
786 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 787 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
787 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 788 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
788 widget->Show(); 789 widget->Show();
790 if (is_source_keyboard)
791 profile_bubble_->FocusFirstProfileButton();
789 } 792 }
790 793
791 // static 794 // static
792 bool ProfileChooserView::IsShowing() { 795 bool ProfileChooserView::IsShowing() {
793 return profile_bubble_ != NULL; 796 return profile_bubble_ != NULL;
794 } 797 }
795 798
796 // static 799 // static
797 void ProfileChooserView::Hide() { 800 void ProfileChooserView::Hide() {
798 if (IsShowing()) 801 if (IsShowing())
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 sync_error_upgrade_button_ = nullptr; 842 sync_error_upgrade_button_ = nullptr;
840 sync_error_signin_again_button_ = nullptr; 843 sync_error_signin_again_button_ = nullptr;
841 sync_error_signout_button_ = nullptr; 844 sync_error_signout_button_ = nullptr;
842 manage_accounts_link_ = nullptr; 845 manage_accounts_link_ = nullptr;
843 manage_accounts_button_ = nullptr; 846 manage_accounts_button_ = nullptr;
844 signin_current_profile_button_ = nullptr; 847 signin_current_profile_button_ = nullptr;
845 auth_error_email_button_ = nullptr; 848 auth_error_email_button_ = nullptr;
846 current_profile_photo_ = nullptr; 849 current_profile_photo_ = nullptr;
847 current_profile_name_ = nullptr; 850 current_profile_name_ = nullptr;
848 current_profile_card_ = nullptr; 851 current_profile_card_ = nullptr;
852 first_profile_button_ = nullptr;
849 guest_profile_button_ = nullptr; 853 guest_profile_button_ = nullptr;
850 users_button_ = nullptr; 854 users_button_ = nullptr;
851 go_incognito_button_ = nullptr; 855 go_incognito_button_ = nullptr;
852 lock_button_ = nullptr; 856 lock_button_ = nullptr;
853 close_all_windows_button_ = nullptr; 857 close_all_windows_button_ = nullptr;
854 add_account_link_ = nullptr; 858 add_account_link_ = nullptr;
855 gaia_signin_cancel_button_ = nullptr; 859 gaia_signin_cancel_button_ = nullptr;
856 remove_account_button_ = nullptr; 860 remove_account_button_ = nullptr;
857 account_removal_cancel_button_ = nullptr; 861 account_removal_cancel_button_ = nullptr;
858 add_person_button_ = nullptr; 862 add_person_button_ = nullptr;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 // Hides the user menu if it is currently shown. The user menu automatically 1014 // Hides the user menu if it is currently shown. The user menu automatically
1011 // closes when it loses focus; however, on Windows, the signin modals do not 1015 // closes when it loses focus; however, on Windows, the signin modals do not
1012 // take away focus, thus we need to manually close the bubble. 1016 // take away focus, thus we need to manually close the bubble.
1013 Hide(); 1017 Hide();
1014 browser_->ShowModalSigninWindow(mode, access_point_); 1018 browser_->ShowModalSigninWindow(mode, access_point_);
1015 } else { 1019 } else {
1016 ShowView(mode, avatar_menu_.get()); 1020 ShowView(mode, avatar_menu_.get());
1017 } 1021 }
1018 } 1022 }
1019 1023
1024 void ProfileChooserView::FocusFirstProfileButton() {
1025 if (first_profile_button_)
1026 first_profile_button_->RequestFocus();
1027 }
1028
1020 void ProfileChooserView::WindowClosing() { 1029 void ProfileChooserView::WindowClosing() {
1021 DCHECK_EQ(profile_bubble_, this); 1030 DCHECK_EQ(profile_bubble_, this);
1022 profile_bubble_ = NULL; 1031 profile_bubble_ = NULL;
1023 1032
1024 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 1033 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
1025 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 1034 LoginUIServiceFactory::GetForProfile(browser_->profile())->
1026 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); 1035 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS);
1027 } 1036 }
1028 } 1037 }
1029 1038
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 if (!item.active) { 1935 if (!item.active) {
1927 gfx::Image image = profiles::GetSizedAvatarIcon( 1936 gfx::Image image = profiles::GetSizedAvatarIcon(
1928 item.icon, true, kProfileIconSize, kProfileIconSize, 1937 item.icon, true, kProfileIconSize, kProfileIconSize,
1929 profiles::SHAPE_CIRCLE); 1938 profiles::SHAPE_CIRCLE);
1930 views::LabelButton* button = new BackgroundColorHoverButton( 1939 views::LabelButton* button = new BackgroundColorHoverButton(
1931 this, profiles::GetProfileSwitcherTextForItem(item), 1940 this, profiles::GetProfileSwitcherTextForItem(item),
1932 *image.ToImageSkia()); 1941 *image.ToImageSkia());
1933 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); 1942 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin);
1934 open_other_profile_indexes_map_[button] = i; 1943 open_other_profile_indexes_map_[button] = i;
1935 1944
1945 if (!first_profile_button_)
1946 first_profile_button_ = button;
1936 layout->StartRow(1, 0); 1947 layout->StartRow(1, 0);
1937 layout->AddView(button); 1948 layout->AddView(button);
1938 } 1949 }
1939 } 1950 }
1940 1951
1941 // Add the "Guest" button for browsing as guest 1952 // Add the "Guest" button for browsing as guest
1942 if (!is_guest) { 1953 if (!is_guest) {
1943 PrefService* service = g_browser_process->local_state(); 1954 PrefService* service = g_browser_process->local_state();
1944 DCHECK(service); 1955 DCHECK(service);
1945 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { 1956 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2391 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2381 IncognitoModePrefs::DISABLED; 2392 IncognitoModePrefs::DISABLED;
2382 return incognito_available && !browser_->profile()->IsGuestSession(); 2393 return incognito_available && !browser_->profile()->IsGuestSession();
2383 } 2394 }
2384 2395
2385 void ProfileChooserView::PostActionPerformed( 2396 void ProfileChooserView::PostActionPerformed(
2386 ProfileMetrics::ProfileDesktopMenu action_performed) { 2397 ProfileMetrics::ProfileDesktopMenu action_performed) {
2387 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2398 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2388 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2399 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2389 } 2400 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698