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

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: Removing {} 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 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 737 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
738 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 738 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
739 739
740 // static 740 // static
741 void ProfileChooserView::ShowBubble( 741 void ProfileChooserView::ShowBubble(
742 profiles::BubbleViewMode view_mode, 742 profiles::BubbleViewMode view_mode,
743 profiles::TutorialMode tutorial_mode, 743 profiles::TutorialMode tutorial_mode,
744 const signin::ManageAccountsParams& manage_accounts_params, 744 const signin::ManageAccountsParams& manage_accounts_params,
745 signin_metrics::AccessPoint access_point, 745 signin_metrics::AccessPoint access_point,
746 views::View* anchor_view, 746 views::View* anchor_view,
747 Browser* browser) { 747 Browser* browser,
748 bool focus_first_profile_button) {
sky 2017/02/14 18:05:20 I think this is really whether a keyboard was used
jlebel 2017/02/20 16:11:23 Done.
748 // Don't start creating the view if it would be an empty fast user switcher. 749 // Don't start creating the view if it would be an empty fast user switcher.
749 // It has to happen here to prevent the view system from creating an empty 750 // It has to happen here to prevent the view system from creating an empty
750 // container. 751 // container.
751 // Same for material design user menu since fast profile switcher will be 752 // Same for material design user menu since fast profile switcher will be
752 // migrated to the left-click menu. 753 // migrated to the left-click menu.
753 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && 754 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER &&
754 (!profiles::HasProfileSwitchTargets(browser->profile()) || 755 (!profiles::HasProfileSwitchTargets(browser->profile()) ||
755 switches::IsMaterialDesignUserMenu())) { 756 switches::IsMaterialDesignUserMenu())) {
756 return; 757 return;
757 } 758 }
758 759
759 if (IsShowing()) { 760 if (IsShowing()) {
760 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { 761 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
761 profile_bubble_->tutorial_mode_ = tutorial_mode; 762 profile_bubble_->tutorial_mode_ = tutorial_mode;
762 profile_bubble_->ShowViewFromMode(view_mode); 763 profile_bubble_->ShowViewFromMode(view_mode);
763 } 764 }
764 return; 765 return;
765 } 766 }
766 767
767 profile_bubble_ = 768 profile_bubble_ =
768 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, 769 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode,
769 manage_accounts_params.service_type, access_point); 770 manage_accounts_params.service_type, access_point);
770 views::Widget* widget = 771 views::Widget* widget =
771 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); 772 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_);
772 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 773 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
773 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 774 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
774 widget->Show(); 775 widget->Show();
776 if (focus_first_profile_button)
777 profile_bubble_->FocusFirstProfileButton();
775 } 778 }
776 779
777 // static 780 // static
778 bool ProfileChooserView::IsShowing() { 781 bool ProfileChooserView::IsShowing() {
779 return profile_bubble_ != NULL; 782 return profile_bubble_ != NULL;
780 } 783 }
781 784
782 // static 785 // static
783 void ProfileChooserView::Hide() { 786 void ProfileChooserView::Hide() {
784 if (IsShowing()) 787 if (IsShowing())
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 sync_error_upgrade_button_ = nullptr; 828 sync_error_upgrade_button_ = nullptr;
826 sync_error_signin_again_button_ = nullptr; 829 sync_error_signin_again_button_ = nullptr;
827 sync_error_signout_button_ = nullptr; 830 sync_error_signout_button_ = nullptr;
828 manage_accounts_link_ = nullptr; 831 manage_accounts_link_ = nullptr;
829 manage_accounts_button_ = nullptr; 832 manage_accounts_button_ = nullptr;
830 signin_current_profile_button_ = nullptr; 833 signin_current_profile_button_ = nullptr;
831 auth_error_email_button_ = nullptr; 834 auth_error_email_button_ = nullptr;
832 current_profile_photo_ = nullptr; 835 current_profile_photo_ = nullptr;
833 current_profile_name_ = nullptr; 836 current_profile_name_ = nullptr;
834 current_profile_card_ = nullptr; 837 current_profile_card_ = nullptr;
838 first_profile_button_ = nullptr;
835 guest_profile_button_ = nullptr; 839 guest_profile_button_ = nullptr;
836 users_button_ = nullptr; 840 users_button_ = nullptr;
837 go_incognito_button_ = nullptr; 841 go_incognito_button_ = nullptr;
838 lock_button_ = nullptr; 842 lock_button_ = nullptr;
839 close_all_windows_button_ = nullptr; 843 close_all_windows_button_ = nullptr;
840 add_account_link_ = nullptr; 844 add_account_link_ = nullptr;
841 gaia_signin_cancel_button_ = nullptr; 845 gaia_signin_cancel_button_ = nullptr;
842 remove_account_button_ = nullptr; 846 remove_account_button_ = nullptr;
843 account_removal_cancel_button_ = nullptr; 847 account_removal_cancel_button_ = nullptr;
844 add_person_button_ = nullptr; 848 add_person_button_ = nullptr;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 // Hides the user menu if it is currently shown. The user menu automatically 1000 // Hides the user menu if it is currently shown. The user menu automatically
997 // closes when it loses focus; however, on Windows, the signin modals do not 1001 // closes when it loses focus; however, on Windows, the signin modals do not
998 // take away focus, thus we need to manually close the bubble. 1002 // take away focus, thus we need to manually close the bubble.
999 Hide(); 1003 Hide();
1000 browser_->ShowModalSigninWindow(mode, access_point_); 1004 browser_->ShowModalSigninWindow(mode, access_point_);
1001 } else { 1005 } else {
1002 ShowView(mode, avatar_menu_.get()); 1006 ShowView(mode, avatar_menu_.get());
1003 } 1007 }
1004 } 1008 }
1005 1009
1010 void ProfileChooserView::FocusFirstProfileButton() {
1011 if (first_profile_button_)
1012 first_profile_button_->RequestFocus();
1013 }
1014
1006 void ProfileChooserView::WindowClosing() { 1015 void ProfileChooserView::WindowClosing() {
1007 DCHECK_EQ(profile_bubble_, this); 1016 DCHECK_EQ(profile_bubble_, this);
1008 profile_bubble_ = NULL; 1017 profile_bubble_ = NULL;
1009 1018
1010 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 1019 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
1011 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 1020 LoginUIServiceFactory::GetForProfile(browser_->profile())->
1012 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); 1021 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS);
1013 } 1022 }
1014 } 1023 }
1015 1024
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 if (!item.active) { 1920 if (!item.active) {
1912 gfx::Image image = profiles::GetSizedAvatarIcon( 1921 gfx::Image image = profiles::GetSizedAvatarIcon(
1913 item.icon, true, kProfileIconSize, kProfileIconSize, 1922 item.icon, true, kProfileIconSize, kProfileIconSize,
1914 profiles::SHAPE_CIRCLE); 1923 profiles::SHAPE_CIRCLE);
1915 views::LabelButton* button = new BackgroundColorHoverButton( 1924 views::LabelButton* button = new BackgroundColorHoverButton(
1916 this, profiles::GetProfileSwitcherTextForItem(item), 1925 this, profiles::GetProfileSwitcherTextForItem(item),
1917 *image.ToImageSkia()); 1926 *image.ToImageSkia());
1918 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); 1927 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin);
1919 open_other_profile_indexes_map_[button] = i; 1928 open_other_profile_indexes_map_[button] = i;
1920 1929
1930 if (!first_profile_button_) {
sky 2017/02/14 18:05:20 no {}
jlebel 2017/02/20 16:11:23 Done.
1931 first_profile_button_ = button;
1932 }
1921 layout->StartRow(1, 0); 1933 layout->StartRow(1, 0);
1922 layout->AddView(button); 1934 layout->AddView(button);
1923 } 1935 }
1924 } 1936 }
1925 1937
1926 // Add the "Guest" button for browsing as guest 1938 // Add the "Guest" button for browsing as guest
1927 if (!is_guest) { 1939 if (!is_guest) {
1928 PrefService* service = g_browser_process->local_state(); 1940 PrefService* service = g_browser_process->local_state();
1929 DCHECK(service); 1941 DCHECK(service);
1930 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { 1942 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) {
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2377 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2366 IncognitoModePrefs::DISABLED; 2378 IncognitoModePrefs::DISABLED;
2367 return incognito_available && !browser_->profile()->IsGuestSession(); 2379 return incognito_available && !browser_->profile()->IsGuestSession();
2368 } 2380 }
2369 2381
2370 void ProfileChooserView::PostActionPerformed( 2382 void ProfileChooserView::PostActionPerformed(
2371 ProfileMetrics::ProfileDesktopMenu action_performed) { 2383 ProfileMetrics::ProfileDesktopMenu action_performed) {
2372 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2384 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2373 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2385 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2374 } 2386 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698