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 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 | 487 |
488 // static | 488 // static |
489 void ProfileChooserView::ShowBubble( | 489 void ProfileChooserView::ShowBubble( |
490 profiles::BubbleViewMode view_mode, | 490 profiles::BubbleViewMode view_mode, |
491 profiles::TutorialMode tutorial_mode, | 491 profiles::TutorialMode tutorial_mode, |
492 const signin::ManageAccountsParams& manage_accounts_params, | 492 const signin::ManageAccountsParams& manage_accounts_params, |
493 views::View* anchor_view, | 493 views::View* anchor_view, |
494 views::BubbleBorder::Arrow arrow, | 494 views::BubbleBorder::Arrow arrow, |
495 views::BubbleBorder::BubbleAlignment border_alignment, | 495 views::BubbleBorder::BubbleAlignment border_alignment, |
496 Browser* browser) { | 496 Browser* browser) { |
497 // Don't start creating the view if it would be an empty fast user switcher. | |
498 // This is the case when there is 0 or 1 profiles (the current one). It has | |
499 // to happen here to prevent the view system from creating an empty container. | |
500 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | |
501 g_browser_process->profile_manager()->GetNumberOfProfiles() <= 1) { | |
Mike Lerman
2015/02/20 15:34:00
The ProfileManager only shows you the number of Lo
anthonyvd
2015/02/20 19:06:05
Hm, this function is static and the avatar_menu_ o
Mike Lerman
2015/02/20 19:17:09
Ah - I didn't realize the ProfileManager just call
| |
502 return; | |
503 } | |
504 | |
497 if (IsShowing()) { | 505 if (IsShowing()) { |
498 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 506 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
499 profile_bubble_->tutorial_mode_ = tutorial_mode; | 507 profile_bubble_->tutorial_mode_ = tutorial_mode; |
500 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); | 508 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); |
501 } | 509 } |
502 return; | 510 return; |
503 } | 511 } |
504 | 512 |
505 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, | 513 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, |
506 view_mode, tutorial_mode, manage_accounts_params.service_type); | 514 view_mode, tutorial_mode, manage_accounts_params.service_type); |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
792 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); | 800 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
793 } else { | 801 } else { |
794 // Either one of the "other profiles", or one of the profile accounts | 802 // Either one of the "other profiles", or one of the profile accounts |
795 // buttons was pressed. | 803 // buttons was pressed. |
796 ButtonIndexes::const_iterator profile_match = | 804 ButtonIndexes::const_iterator profile_match = |
797 open_other_profile_indexes_map_.find(sender); | 805 open_other_profile_indexes_map_.find(sender); |
798 if (profile_match != open_other_profile_indexes_map_.end()) { | 806 if (profile_match != open_other_profile_indexes_map_.end()) { |
799 avatar_menu_->SwitchToProfile( | 807 avatar_menu_->SwitchToProfile( |
800 profile_match->second, | 808 profile_match->second, |
801 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 809 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
802 ProfileMetrics::SWITCH_PROFILE_ICON); | 810 ProfileMetrics::SWITCH_PROFILE_FAST_SWITCHER); |
803 } else { | 811 } else { |
804 // This was a profile accounts button. | 812 // This was a profile accounts button. |
805 AccountButtonIndexes::const_iterator account_match = | 813 AccountButtonIndexes::const_iterator account_match = |
806 delete_account_button_map_.find(sender); | 814 delete_account_button_map_.find(sender); |
807 if (account_match != delete_account_button_map_.end()) { | 815 if (account_match != delete_account_button_map_.end()) { |
808 account_id_to_remove_ = account_match->second; | 816 account_id_to_remove_ = account_match->second; |
809 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, | 817 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, |
810 avatar_menu_.get()); | 818 avatar_menu_.get()); |
811 } else { | 819 } else { |
812 account_match = reauth_account_button_map_.find(sender); | 820 account_match = reauth_account_button_map_.find(sender); |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1705 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1713 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1706 IncognitoModePrefs::DISABLED; | 1714 IncognitoModePrefs::DISABLED; |
1707 return incognito_available && !browser_->profile()->IsGuestSession(); | 1715 return incognito_available && !browser_->profile()->IsGuestSession(); |
1708 } | 1716 } |
1709 | 1717 |
1710 void ProfileChooserView::PostActionPerformed( | 1718 void ProfileChooserView::PostActionPerformed( |
1711 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1719 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1712 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1720 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1713 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1721 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1714 } | 1722 } |
OLD | NEW |