| 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 "components/signin/core/browser/signin_manager.h" | 5 #include "components/signin/core/browser/signin_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 | 196 |
| 197 if (prohibit_signout_) { | 197 if (prohibit_signout_) { |
| 198 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited"; | 198 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited"; |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 | 201 |
| 202 ClearTransientSigninData(); | 202 ClearTransientSigninData(); |
| 203 | 203 |
| 204 const std::string account_id = GetAuthenticatedAccountId(); |
| 204 const std::string username = GetAuthenticatedUsername(); | 205 const std::string username = GetAuthenticatedUsername(); |
| 205 const base::Time signin_time = | 206 const base::Time signin_time = |
| 206 base::Time::FromInternalValue( | 207 base::Time::FromInternalValue( |
| 207 client_->GetPrefs()->GetInt64(prefs::kSignedInTime)); | 208 client_->GetPrefs()->GetInt64(prefs::kSignedInTime)); |
| 208 clear_authenticated_username(); | 209 clear_authenticated_username(); |
| 209 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); | 210 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
| 210 client_->GetPrefs()->ClearPref(prefs::kSignedInTime); | 211 client_->GetPrefs()->ClearPref(prefs::kSignedInTime); |
| 211 client_->ClearSigninScopedDeviceId(); | 212 client_->ClearSigninScopedDeviceId(); |
| 212 | 213 |
| 213 // Erase (now) stale information from AboutSigninInternals. | 214 // Erase (now) stale information from AboutSigninInternals. |
| 214 NotifyDiagnosticsObservers(USERNAME, ""); | 215 NotifyDiagnosticsObservers(USERNAME, ""); |
| 215 | 216 |
| 216 // Determine the duration the user was logged in and log that to UMA. | 217 // Determine the duration the user was logged in and log that to UMA. |
| 217 if (!signin_time.is_null()) { | 218 if (!signin_time.is_null()) { |
| 218 base::TimeDelta signed_in_duration = base::Time::Now() - signin_time; | 219 base::TimeDelta signed_in_duration = base::Time::Now() - signin_time; |
| 219 UMA_HISTOGRAM_COUNTS("Signin.SignedInDurationBeforeSignout", | 220 UMA_HISTOGRAM_COUNTS("Signin.SignedInDurationBeforeSignout", |
| 220 signed_in_duration.InMinutes()); | 221 signed_in_duration.InMinutes()); |
| 221 } | 222 } |
| 222 | 223 |
| 223 // Revoke all tokens before sending signed_out notification, because there | 224 // Revoke all tokens before sending signed_out notification, because there |
| 224 // may be components that don't listen for token service events when the | 225 // may be components that don't listen for token service events when the |
| 225 // profile is not connected to an account. | 226 // profile is not connected to an account. |
| 226 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, " | 227 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, " |
| 227 << "IsSigninAllowed: " << IsSigninAllowed(); | 228 << "IsSigninAllowed: " << IsSigninAllowed(); |
| 228 token_service_->RevokeAllCredentials(); | 229 token_service_->RevokeAllCredentials(); |
| 229 | 230 |
| 230 FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSignedOut(username)); | 231 FOR_EACH_OBSERVER(Observer, |
| 232 observer_list_, |
| 233 GoogleSignedOut(account_id, username)); |
| 231 } | 234 } |
| 232 | 235 |
| 233 void SigninManager::Initialize(PrefService* local_state) { | 236 void SigninManager::Initialize(PrefService* local_state) { |
| 234 SigninManagerBase::Initialize(local_state); | 237 SigninManagerBase::Initialize(local_state); |
| 235 | 238 |
| 236 // local_state can be null during unit tests. | 239 // local_state can be null during unit tests. |
| 237 if (local_state) { | 240 if (local_state) { |
| 238 local_state_pref_registrar_.Init(local_state); | 241 local_state_pref_registrar_.Init(local_state); |
| 239 local_state_pref_registrar_.Add( | 242 local_state_pref_registrar_.Add( |
| 240 prefs::kGoogleServicesUsernamePattern, | 243 prefs::kGoogleServicesUsernamePattern, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 369 |
| 367 void SigninManager::OnSignedIn(const std::string& username) { | 370 void SigninManager::OnSignedIn(const std::string& username) { |
| 368 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, | 371 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, |
| 369 base::Time::Now().ToInternalValue()); | 372 base::Time::Now().ToInternalValue()); |
| 370 SetAuthenticatedUsername(username); | 373 SetAuthenticatedUsername(username); |
| 371 possibly_invalid_username_.clear(); | 374 possibly_invalid_username_.clear(); |
| 372 | 375 |
| 373 FOR_EACH_OBSERVER( | 376 FOR_EACH_OBSERVER( |
| 374 Observer, | 377 Observer, |
| 375 observer_list_, | 378 observer_list_, |
| 376 GoogleSigninSucceeded(GetAuthenticatedUsername(), password_)); | 379 GoogleSigninSucceeded(GetAuthenticatedAccountId(), |
| 380 GetAuthenticatedUsername(), |
| 381 password_)); |
| 377 | 382 |
| 378 client_->GoogleSigninSucceeded(GetAuthenticatedUsername(), password_); | 383 client_->GoogleSigninSucceeded(GetAuthenticatedAccountId(), |
| 384 GetAuthenticatedUsername(), |
| 385 password_); |
| 379 | 386 |
| 380 signin_metrics::LogSigninProfile(client_->IsFirstRun(), | 387 signin_metrics::LogSigninProfile(client_->IsFirstRun(), |
| 381 client_->GetInstallDate()); | 388 client_->GetInstallDate()); |
| 382 | 389 |
| 383 password_.clear(); // Don't need it anymore. | 390 password_.clear(); // Don't need it anymore. |
| 384 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. | 391 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. |
| 385 } | 392 } |
| 386 | 393 |
| 387 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 394 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
| 388 prohibit_signout_ = prohibit_signout; | 395 prohibit_signout_ = prohibit_signout; |
| 389 } | 396 } |
| 390 | 397 |
| 391 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } | 398 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } |
| OLD | NEW |