Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/browser/profiles/profile_metrics.h" | 15 #include "chrome/browser/profiles/profile_metrics.h" |
| 16 #include "chrome/browser/profiles/profile_window.h" | 16 #include "chrome/browser/profiles/profile_window.h" |
| 17 #include "chrome/browser/profiles/profiles_state.h" | 17 #include "chrome/browser/profiles/profiles_state.h" |
| 18 #include "chrome/browser/signin/chrome_signin_helper.h" | 18 #include "chrome/browser/signin/chrome_signin_helper.h" |
| 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 20 #include "chrome/browser/signin/signin_error_controller_factory.h" | 20 #include "chrome/browser/signin/signin_error_controller_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/signin/signin_promo.h" | 22 #include "chrome/browser/signin/signin_promo.h" |
| 23 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
| 24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
| 26 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
| 27 #include "chrome/browser/ui/browser_list.h" | |
| 27 #include "chrome/browser/ui/chrome_pages.h" | 28 #include "chrome/browser/ui/chrome_pages.h" |
| 28 #include "chrome/browser/ui/singleton_tabs.h" | 29 #include "chrome/browser/ui/singleton_tabs.h" |
| 29 #include "chrome/browser/ui/user_manager.h" | 30 #include "chrome/browser/ui/user_manager.h" |
| 30 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 31 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| 31 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 32 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 32 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 33 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 33 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 34 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 35 #include "chrome/grit/chromium_strings.h" | 36 #include "chrome/grit/chromium_strings.h" |
| 36 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 avatar_menu_.reset(new AvatarMenu( | 604 avatar_menu_.reset(new AvatarMenu( |
| 604 &g_browser_process->profile_manager()->GetProfileInfoCache(), | 605 &g_browser_process->profile_manager()->GetProfileInfoCache(), |
| 605 this, | 606 this, |
| 606 browser_)); | 607 browser_)); |
| 607 avatar_menu_->RebuildMenu(); | 608 avatar_menu_->RebuildMenu(); |
| 608 | 609 |
| 609 ProfileOAuth2TokenService* oauth2_token_service = | 610 ProfileOAuth2TokenService* oauth2_token_service = |
| 610 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 611 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| 611 if (oauth2_token_service) | 612 if (oauth2_token_service) |
| 612 oauth2_token_service->AddObserver(this); | 613 oauth2_token_service->AddObserver(this); |
| 614 | |
| 615 BrowserList::AddObserver(this); | |
|
Evan Stade
2015/09/03 19:35:22
So if we're not closing the bubble when its browse
| |
| 613 } | 616 } |
| 614 | 617 |
| 615 ProfileChooserView::~ProfileChooserView() { | 618 ProfileChooserView::~ProfileChooserView() { |
| 616 ProfileOAuth2TokenService* oauth2_token_service = | 619 // The browser could have already been removed by now. |
| 617 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 620 if (browser_) { |
| 618 if (oauth2_token_service) | 621 ProfileOAuth2TokenService* oauth2_token_service = |
| 619 oauth2_token_service->RemoveObserver(this); | 622 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
| 623 if (oauth2_token_service) | |
| 624 oauth2_token_service->RemoveObserver(this); | |
| 625 } | |
| 620 } | 626 } |
| 621 | 627 |
| 622 void ProfileChooserView::ResetView() { | 628 void ProfileChooserView::ResetView() { |
| 623 open_other_profile_indexes_map_.clear(); | 629 open_other_profile_indexes_map_.clear(); |
| 624 delete_account_button_map_.clear(); | 630 delete_account_button_map_.clear(); |
| 625 reauth_account_button_map_.clear(); | 631 reauth_account_button_map_.clear(); |
| 626 manage_accounts_link_ = NULL; | 632 manage_accounts_link_ = NULL; |
| 627 signin_current_profile_link_ = NULL; | 633 signin_current_profile_link_ = NULL; |
| 628 auth_error_email_button_ = NULL; | 634 auth_error_email_button_ = NULL; |
| 629 current_profile_photo_ = NULL; | 635 current_profile_photo_ = NULL; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 } | 694 } |
| 689 } | 695 } |
| 690 | 696 |
| 691 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { | 697 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
| 692 // Refresh the account management view when an account is removed from the | 698 // Refresh the account management view when an account is removed from the |
| 693 // profile. | 699 // profile. |
| 694 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 700 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
| 695 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 701 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
| 696 } | 702 } |
| 697 | 703 |
| 704 void ProfileChooserView::OnBrowserRemoved(Browser* browser) { | |
| 705 if (browser == browser_) { | |
| 706 browser_ = NULL; | |
|
Evan Stade
2015/09/03 17:38:39
There are many places in this file that reference
| |
| 707 } | |
| 708 } | |
| 709 | |
| 698 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, | 710 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
| 699 AvatarMenu* avatar_menu) { | 711 AvatarMenu* avatar_menu) { |
| 700 // The account management view should only be displayed if the active profile | 712 // The account management view should only be displayed if the active profile |
| 701 // is signed in. | 713 // is signed in. |
| 702 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 714 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
| 703 DCHECK(switches::IsEnableAccountConsistency()); | 715 DCHECK(switches::IsEnableAccountConsistency()); |
| 704 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( | 716 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( |
| 705 avatar_menu->GetActiveProfileIndex()); | 717 avatar_menu->GetActiveProfileIndex()); |
| 706 DCHECK(active_item.signed_in); | 718 DCHECK(active_item.signed_in); |
| 707 } | 719 } |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1803 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1815 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1804 IncognitoModePrefs::DISABLED; | 1816 IncognitoModePrefs::DISABLED; |
| 1805 return incognito_available && !browser_->profile()->IsGuestSession(); | 1817 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1806 } | 1818 } |
| 1807 | 1819 |
| 1808 void ProfileChooserView::PostActionPerformed( | 1820 void ProfileChooserView::PostActionPerformed( |
| 1809 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1821 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1810 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1822 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1811 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1823 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1812 } | 1824 } |
| OLD | NEW |