Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/content_settings/cookie_settings.h" | 16 #include "chrome/browser/content_settings/cookie_settings.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/signin/about_signin_internals.h" | 19 #include "chrome/browser/signin/about_signin_internals.h" |
| 20 #include "chrome/browser/signin/about_signin_internals_factory.h" | 20 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 21 #include "chrome/browser/signin/signin_global_error.h" | |
| 21 #include "chrome/browser/signin/signin_internals_util.h" | 22 #include "chrome/browser/signin/signin_internals_util.h" |
| 22 #include "chrome/browser/signin/token_service.h" | 23 #include "chrome/browser/signin/token_service.h" |
| 23 #include "chrome/browser/signin/token_service_factory.h" | 24 #include "chrome/browser/signin/token_service_factory.h" |
| 24 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
| 26 #include "chrome/browser/ui/global_error/global_error_service.h" | |
| 27 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | |
| 25 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
| 26 #include "chrome/common/chrome_switches.h" | 29 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 28 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 29 #include "google_apis/gaia/gaia_auth_fetcher.h" | 32 #include "google_apis/gaia/gaia_auth_fetcher.h" |
| 30 #include "google_apis/gaia/gaia_constants.h" | 33 #include "google_apis/gaia/gaia_constants.h" |
| 31 #include "google_apis/gaia/gaia_urls.h" | 34 #include "google_apis/gaia/gaia_urls.h" |
| 32 #include "net/cookies/cookie_monster.h" | 35 #include "net/cookies/cookie_monster.h" |
| 33 #include "third_party/icu/public/i18n/unicode/regex.h" | 36 #include "third_party/icu/public/i18n/unicode/regex.h" |
| 34 | 37 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 DCHECK(U_SUCCESS(status)); | 95 DCHECK(U_SUCCESS(status)); |
| 93 return !!match; // !! == convert from UBool to bool. | 96 return !!match; // !! == convert from UBool to bool. |
| 94 } | 97 } |
| 95 | 98 |
| 96 SigninManager::SigninManager() | 99 SigninManager::SigninManager() |
| 97 : profile_(NULL), | 100 : profile_(NULL), |
| 98 had_two_factor_error_(false), | 101 had_two_factor_error_(false), |
| 99 type_(SIGNIN_TYPE_NONE) { | 102 type_(SIGNIN_TYPE_NONE) { |
| 100 } | 103 } |
| 101 | 104 |
| 102 SigninManager::~SigninManager() {} | 105 SigninManager::~SigninManager() { |
| 106 DCHECK(!signin_global_error_.get()) << | |
| 107 "SigninManager::Initialize called but not SigninManager::Shutdown"; | |
| 108 } | |
| 109 | |
| 110 void SigninManager::Shutdown() { | |
| 111 if (signin_global_error_.get()) { | |
| 112 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | |
| 113 signin_global_error_.get()); | |
| 114 signin_global_error_.reset(); | |
| 115 } | |
| 116 } | |
|
Roger Tawa OOO till Jul 10th
2013/01/14 16:06:52
I think we should keep the order of function defin
Andrew T Wilson (Slow)
2013/01/15 13:24:56
Done.
| |
| 103 | 117 |
| 104 void SigninManager::Initialize(Profile* profile) { | 118 void SigninManager::Initialize(Profile* profile) { |
| 105 // Should never call Initialize() twice. | 119 // Should never call Initialize() twice. |
| 106 DCHECK(!IsInitialized()); | 120 DCHECK(!IsInitialized()); |
| 107 profile_ = profile; | 121 profile_ = profile; |
| 122 signin_global_error_.reset(new SigninGlobalError(profile)); | |
| 123 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | |
| 124 signin_global_error_.get()); | |
| 108 PrefService* local_state = g_browser_process->local_state(); | 125 PrefService* local_state = g_browser_process->local_state(); |
| 109 // local_state can be null during unit tests. | 126 // local_state can be null during unit tests. |
| 110 if (local_state) { | 127 if (local_state) { |
| 111 local_state_pref_registrar_.Init(local_state); | 128 local_state_pref_registrar_.Init(local_state); |
| 112 local_state_pref_registrar_.Add( | 129 local_state_pref_registrar_.Add( |
| 113 prefs::kGoogleServicesUsernamePattern, | 130 prefs::kGoogleServicesUsernamePattern, |
| 114 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, | 131 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, |
| 115 base::Unretained(this))); | 132 base::Unretained(this))); |
| 116 } | 133 } |
| 117 | 134 |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 626 NotifySigninValueChanged(field, value)); | 643 NotifySigninValueChanged(field, value)); |
| 627 } | 644 } |
| 628 | 645 |
| 629 void SigninManager::NotifyDiagnosticsObservers( | 646 void SigninManager::NotifyDiagnosticsObservers( |
| 630 const TimedSigninStatusField& field, | 647 const TimedSigninStatusField& field, |
| 631 const std::string& value) { | 648 const std::string& value) { |
| 632 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 649 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
| 633 signin_diagnostics_observers_, | 650 signin_diagnostics_observers_, |
| 634 NotifySigninValueChanged(field, value)); | 651 NotifySigninValueChanged(field, value)); |
| 635 } | 652 } |
| OLD | NEW |