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 | |
Alexei Svitkine (slow)
2015/02/19 22:24:28
Nit: No empty line in start of function body.
anthonyvd
2015/02/20 15:01:31
Done.
| |
498 // Don't start creating the view if it would be an empty fast user switcher. | |
499 // This is the case when there is 0 or 1 profiles (the current one). It has | |
500 // to happen here to prevent the view system from creating an empty container. | |
501 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | |
502 g_browser_process->profile_manager()->GetNumberOfProfiles() <= 1) { | |
503 return; | |
504 } | |
505 | |
497 if (IsShowing()) { | 506 if (IsShowing()) { |
498 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 507 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
499 profile_bubble_->tutorial_mode_ = tutorial_mode; | 508 profile_bubble_->tutorial_mode_ = tutorial_mode; |
500 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); | 509 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); |
501 } | 510 } |
502 return; | 511 return; |
503 } | 512 } |
504 | 513 |
505 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, | 514 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, |
506 view_mode, tutorial_mode, manage_accounts_params.service_type); | 515 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); | 801 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
793 } else { | 802 } else { |
794 // Either one of the "other profiles", or one of the profile accounts | 803 // Either one of the "other profiles", or one of the profile accounts |
795 // buttons was pressed. | 804 // buttons was pressed. |
796 ButtonIndexes::const_iterator profile_match = | 805 ButtonIndexes::const_iterator profile_match = |
797 open_other_profile_indexes_map_.find(sender); | 806 open_other_profile_indexes_map_.find(sender); |
798 if (profile_match != open_other_profile_indexes_map_.end()) { | 807 if (profile_match != open_other_profile_indexes_map_.end()) { |
799 avatar_menu_->SwitchToProfile( | 808 avatar_menu_->SwitchToProfile( |
800 profile_match->second, | 809 profile_match->second, |
801 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 810 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
802 ProfileMetrics::SWITCH_PROFILE_ICON); | 811 ProfileMetrics::SWITCH_PROFILE_FAST_SWITCHER); |
Mike Lerman
2015/02/20 14:40:57
Don't we want to send SWITCH_PROFILE_FAST_SWITCHER
anthonyvd
2015/02/20 15:01:31
You're absolutely right but SWITCH_PROFILE_ICON is
Mike Lerman
2015/02/20 15:33:59
We can always determine whether someone's in the N
anthonyvd
2015/02/20 19:06:05
Ah! I didn't think about separating by experiment.
| |
803 } else { | 812 } else { |
804 // This was a profile accounts button. | 813 // This was a profile accounts button. |
805 AccountButtonIndexes::const_iterator account_match = | 814 AccountButtonIndexes::const_iterator account_match = |
806 delete_account_button_map_.find(sender); | 815 delete_account_button_map_.find(sender); |
807 if (account_match != delete_account_button_map_.end()) { | 816 if (account_match != delete_account_button_map_.end()) { |
808 account_id_to_remove_ = account_match->second; | 817 account_id_to_remove_ = account_match->second; |
809 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, | 818 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, |
810 avatar_menu_.get()); | 819 avatar_menu_.get()); |
811 } else { | 820 } else { |
812 account_match = reauth_account_button_map_.find(sender); | 821 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()) != | 1714 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1706 IncognitoModePrefs::DISABLED; | 1715 IncognitoModePrefs::DISABLED; |
1707 return incognito_available && !browser_->profile()->IsGuestSession(); | 1716 return incognito_available && !browser_->profile()->IsGuestSession(); |
1708 } | 1717 } |
1709 | 1718 |
1710 void ProfileChooserView::PostActionPerformed( | 1719 void ProfileChooserView::PostActionPerformed( |
1711 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1720 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1712 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1721 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1713 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1722 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1714 } | 1723 } |
OLD | NEW |