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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // If view mode is PROFILE_CHOOSER but there is an auth error, force | 590 // If view mode is PROFILE_CHOOSER but there is an auth error, force |
591 // ACCOUNT_MANAGEMENT mode. | 591 // ACCOUNT_MANAGEMENT mode. |
592 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 592 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
593 HasAuthError(browser_->profile()) && | 593 HasAuthError(browser_->profile()) && |
594 switches::IsEnableAccountConsistency() && | 594 switches::IsEnableAccountConsistency() && |
595 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). | 595 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). |
596 signed_in) { | 596 signed_in) { |
597 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; | 597 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; |
598 } | 598 } |
599 | 599 |
| 600 // The arrow keys can be used to tab between items. |
| 601 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); |
| 602 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); |
| 603 |
600 ShowView(view_mode_, avatar_menu_.get()); | 604 ShowView(view_mode_, avatar_menu_.get()); |
601 } | 605 } |
602 | 606 |
603 void ProfileChooserView::OnAvatarMenuChanged( | 607 void ProfileChooserView::OnAvatarMenuChanged( |
604 AvatarMenu* avatar_menu) { | 608 AvatarMenu* avatar_menu) { |
605 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || | 609 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || |
606 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 610 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
607 // Refresh the view with the new menu. We can't just update the local copy | 611 // Refresh the view with the new menu. We can't just update the local copy |
608 // as this may have been triggered by a sign out action, in which case | 612 // as this may have been triggered by a sign out action, in which case |
609 // the view is being destroyed. | 613 // the view is being destroyed. |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 return true; | 870 return true; |
867 | 871 |
868 profiles::UpdateProfileName(profile, new_profile_name); | 872 profiles::UpdateProfileName(profile, new_profile_name); |
869 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); | 873 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); |
870 current_profile_name_->ShowReadOnlyView(); | 874 current_profile_name_->ShowReadOnlyView(); |
871 return true; | 875 return true; |
872 } | 876 } |
873 return false; | 877 return false; |
874 } | 878 } |
875 | 879 |
| 880 bool ProfileChooserView::AcceleratorPressed( |
| 881 const ui::Accelerator& accelerator) { |
| 882 if (accelerator.key_code() != ui::VKEY_DOWN && |
| 883 accelerator.key_code() != ui::VKEY_UP) |
| 884 return BubbleDelegateView::AcceleratorPressed(accelerator); |
| 885 // Move the focus up or down. |
| 886 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
| 887 return true; |
| 888 } |
| 889 |
876 views::View* ProfileChooserView::CreateProfileChooserView( | 890 views::View* ProfileChooserView::CreateProfileChooserView( |
877 AvatarMenu* avatar_menu) { | 891 AvatarMenu* avatar_menu) { |
878 views::View* view = new views::View(); | 892 views::View* view = new views::View(); |
879 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 893 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
880 // Separate items into active and alternatives. | 894 // Separate items into active and alternatives. |
881 Indexes other_profiles; | 895 Indexes other_profiles; |
882 views::View* tutorial_view = NULL; | 896 views::View* tutorial_view = NULL; |
883 views::View* current_profile_view = NULL; | 897 views::View* current_profile_view = NULL; |
884 views::View* current_profile_accounts = NULL; | 898 views::View* current_profile_accounts = NULL; |
885 views::View* option_buttons_view = NULL; | 899 views::View* option_buttons_view = NULL; |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1652 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1639 IncognitoModePrefs::DISABLED; | 1653 IncognitoModePrefs::DISABLED; |
1640 return incognito_available && !browser_->profile()->IsGuestSession(); | 1654 return incognito_available && !browser_->profile()->IsGuestSession(); |
1641 } | 1655 } |
1642 | 1656 |
1643 void ProfileChooserView::PostActionPerformed( | 1657 void ProfileChooserView::PostActionPerformed( |
1644 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1658 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1645 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1659 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1646 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1660 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1647 } | 1661 } |
OLD | NEW |