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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 void ProfileChooserView::WindowClosing() { | 694 void ProfileChooserView::WindowClosing() { |
691 DCHECK_EQ(profile_bubble_, this); | 695 DCHECK_EQ(profile_bubble_, this); |
692 profile_bubble_ = NULL; | 696 profile_bubble_ = NULL; |
693 | 697 |
694 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { | 698 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
695 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 699 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
696 SyncConfirmationUIClosed(false /* configure_sync_first */); | 700 SyncConfirmationUIClosed(false /* configure_sync_first */); |
697 } | 701 } |
698 } | 702 } |
699 | 703 |
| 704 bool ProfileChooserView::AcceleratorPressed( |
| 705 const ui::Accelerator& accelerator) { |
| 706 if (accelerator.key_code() != ui::VKEY_DOWN && |
| 707 accelerator.key_code() != ui::VKEY_UP) |
| 708 return BubbleDelegateView::AcceleratorPressed(accelerator); |
| 709 // Move the focus up or down. |
| 710 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
| 711 return true; |
| 712 } |
| 713 |
700 void ProfileChooserView::ButtonPressed(views::Button* sender, | 714 void ProfileChooserView::ButtonPressed(views::Button* sender, |
701 const ui::Event& event) { | 715 const ui::Event& event) { |
702 // Disable button after clicking so that it doesn't get clicked twice and | 716 // Disable button after clicking so that it doesn't get clicked twice and |
703 // start a second action... which can crash Chrome. But don't disable if it | 717 // start a second action... which can crash Chrome. But don't disable if it |
704 // has no parent (like in tests) because that will also crash. | 718 // has no parent (like in tests) because that will also crash. |
705 if (sender->parent()) | 719 if (sender->parent()) |
706 sender->SetEnabled(false); | 720 sender->SetEnabled(false); |
707 | 721 |
708 if (sender == users_button_) { | 722 if (sender == users_button_) { |
709 // If this is a guest session, close all the guest browser windows. | 723 // If this is a guest session, close all the guest browser windows. |
(...skipping 928 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 |