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 "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/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 16 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 16 #include "components/signin/core/browser/signin_account_id_helper.h" | 17 #include "components/signin/core/browser/signin_account_id_helper.h" |
| 17 #include "components/signin/core/browser/signin_client.h" | 18 #include "components/signin/core/browser/signin_client.h" |
| 18 #include "components/signin/core/browser/signin_internals_util.h" | 19 #include "components/signin/core/browser/signin_internals_util.h" |
| 19 #include "components/signin/core/browser/signin_manager_cookie_helper.h" | 20 #include "components/signin/core/browser/signin_manager_cookie_helper.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 } | 195 } |
| 195 | 196 |
| 196 if (prohibit_signout_) { | 197 if (prohibit_signout_) { |
| 197 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited"; | 198 DVLOG(1) << "Ignoring attempt to sign out while signout is prohibited"; |
| 198 return; | 199 return; |
| 199 } | 200 } |
| 200 | 201 |
| 201 ClearTransientSigninData(); | 202 ClearTransientSigninData(); |
| 202 | 203 |
| 203 const std::string username = GetAuthenticatedUsername(); | 204 const std::string username = GetAuthenticatedUsername(); |
| 205 const base::Time signin_time = | |
| 206 base::Time::FromInternalValue( | |
| 207 client_->GetPrefs()->GetInt64(prefs::kSignedInTime)); | |
| 204 clear_authenticated_username(); | 208 clear_authenticated_username(); |
| 205 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); | 209 client_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); |
| 210 client_->GetPrefs()->ClearPref(prefs::kSignedInTime); | |
| 206 client_->ClearSigninScopedDeviceId(); | 211 client_->ClearSigninScopedDeviceId(); |
| 207 | 212 |
| 208 // Erase (now) stale information from AboutSigninInternals. | 213 // Erase (now) stale information from AboutSigninInternals. |
| 209 NotifyDiagnosticsObservers(USERNAME, ""); | 214 NotifyDiagnosticsObservers(USERNAME, ""); |
| 210 | 215 |
| 216 // Determine the duration the user was logged in and log that to UMA. | |
| 217 if (!signin_time.is_null()) { | |
| 218 base::TimeDelta signed_in_duration = base::Time::Now() - signin_time; | |
|
Alexei Svitkine (slow)
2014/08/12 14:41:49
Note: Be aware that if the user's machine time cha
Mike Lerman
2014/08/12 18:07:10
I assume this will indeed be a very small proporti
| |
| 219 UMA_HISTOGRAM_COUNTS("Signin.SignedInDurationBeforeSignout", | |
| 220 signed_in_duration.InMinutes())); | |
|
Roger Tawa OOO till Jul 10th
2014/08/12 14:14:52
Should we be paranoid and check that delta > 0?
Alexei Svitkine (slow)
2014/08/12 14:41:49
I believe it should automatically go in the underf
Mike Lerman
2014/08/12 18:07:10
Acknowledged.
| |
| 221 } | |
| 222 | |
| 211 // Revoke all tokens before sending signed_out notification, because there | 223 // Revoke all tokens before sending signed_out notification, because there |
| 212 // may be components that don't listen for token service events when the | 224 // may be components that don't listen for token service events when the |
| 213 // profile is not connected to an account. | 225 // profile is not connected to an account. |
| 214 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, " | 226 LOG(WARNING) << "Revoking refresh token on server. Reason: sign out, " |
| 215 << "IsSigninAllowed: " << IsSigninAllowed(); | 227 << "IsSigninAllowed: " << IsSigninAllowed(); |
| 216 token_service_->RevokeAllCredentials(); | 228 token_service_->RevokeAllCredentials(); |
| 217 | 229 |
| 218 FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSignedOut(username)); | 230 FOR_EACH_OBSERVER(Observer, observer_list_, GoogleSignedOut(username)); |
| 219 } | 231 } |
| 220 | 232 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 | 377 |
| 366 password_.clear(); // Don't need it anymore. | 378 password_.clear(); // Don't need it anymore. |
| 367 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. | 379 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. |
| 368 } | 380 } |
| 369 | 381 |
| 370 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 382 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
| 371 prohibit_signout_ = prohibit_signout; | 383 prohibit_signout_ = prohibit_signout; |
| 372 } | 384 } |
| 373 | 385 |
| 374 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } | 386 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } |
| OLD | NEW |