| 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/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 SigninManager::~SigninManager() { | 195 SigninManager::~SigninManager() { |
| 196 DCHECK(!signin_global_error_.get()) << | 196 DCHECK(!signin_global_error_.get()) << |
| 197 "SigninManager::Initialize called but not SigninManager::Shutdown"; | 197 "SigninManager::Initialize called but not SigninManager::Shutdown"; |
| 198 } | 198 } |
| 199 | 199 |
| 200 void SigninManager::Initialize(Profile* profile) { | 200 void SigninManager::Initialize(Profile* profile) { |
| 201 // Should never call Initialize() twice. | 201 // Should never call Initialize() twice. |
| 202 DCHECK(!IsInitialized()); | 202 DCHECK(!IsInitialized()); |
| 203 profile_ = profile; | 203 profile_ = profile; |
| 204 signin_global_error_.reset(new SigninGlobalError(profile)); | 204 signin_global_error_.reset(new SigninGlobalError(this, profile)); |
| 205 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | 205 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( |
| 206 signin_global_error_.get()); | 206 signin_global_error_.get()); |
| 207 PrefService* local_state = g_browser_process->local_state(); | 207 PrefService* local_state = g_browser_process->local_state(); |
| 208 // local_state can be null during unit tests. | 208 // local_state can be null during unit tests. |
| 209 if (local_state) { | 209 if (local_state) { |
| 210 local_state_pref_registrar_.Init(local_state); | 210 local_state_pref_registrar_.Init(local_state); |
| 211 local_state_pref_registrar_.Add( | 211 local_state_pref_registrar_.Add( |
| 212 prefs::kGoogleServicesUsernamePattern, | 212 prefs::kGoogleServicesUsernamePattern, |
| 213 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, | 213 base::Bind(&SigninManager::OnGoogleServicesUsernamePatternChanged, |
| 214 base::Unretained(this))); | 214 base::Unretained(this))); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 if (registrar_.IsRegistered(this, | 267 if (registrar_.IsRegistered(this, |
| 268 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 268 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 269 token_service)) { | 269 token_service)) { |
| 270 registrar_.Remove(this, | 270 registrar_.Remove(this, |
| 271 chrome::NOTIFICATION_TOKEN_AVAILABLE, | 271 chrome::NOTIFICATION_TOKEN_AVAILABLE, |
| 272 token_service); | 272 token_service); |
| 273 } | 273 } |
| 274 #endif | 274 #endif |
| 275 } | 275 } |
| 276 | 276 |
| 277 const std::string& SigninManager::GetAuthenticatedUsername() { | 277 const std::string& SigninManager::GetAuthenticatedUsername() const { |
| 278 return authenticated_username_; | 278 return authenticated_username_; |
| 279 } | 279 } |
| 280 | 280 |
| 281 void SigninManager::SetAuthenticatedUsername(const std::string& username) { | 281 void SigninManager::SetAuthenticatedUsername(const std::string& username) { |
| 282 if (!authenticated_username_.empty()) { | 282 if (!authenticated_username_.empty()) { |
| 283 DLOG_IF(ERROR, username != authenticated_username_) << | 283 DLOG_IF(ERROR, username != authenticated_username_) << |
| 284 "Tried to change the authenticated username to something different: " << | 284 "Tried to change the authenticated username to something different: " << |
| 285 "Current: " << authenticated_username_ << ", New: " << username; | 285 "Current: " << authenticated_username_ << ", New: " << username; |
| 286 return; | 286 return; |
| 287 } | 287 } |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 782 NotifySigninValueChanged(field, value)); | 782 NotifySigninValueChanged(field, value)); |
| 783 } | 783 } |
| 784 | 784 |
| 785 void SigninManager::NotifyDiagnosticsObservers( | 785 void SigninManager::NotifyDiagnosticsObservers( |
| 786 const TimedSigninStatusField& field, | 786 const TimedSigninStatusField& field, |
| 787 const std::string& value) { | 787 const std::string& value) { |
| 788 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 788 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
| 789 signin_diagnostics_observers_, | 789 signin_diagnostics_observers_, |
| 790 NotifySigninValueChanged(field, value)); | 790 NotifySigninValueChanged(field, value)); |
| 791 } | 791 } |
| OLD | NEW |