Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: components/signin/core/browser/signin_manager.cc

Issue 338993007: Track when and how a profile is signed out via UMA. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove tracking android in separate UMA bucket Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/signin/core/browser/profile_oauth2_token_service.h" 15 #include "components/signin/core/browser/profile_oauth2_token_service.h"
16 #include "components/signin/core/browser/signin_account_id_helper.h" 16 #include "components/signin/core/browser/signin_account_id_helper.h"
17 #include "components/signin/core/browser/signin_client.h" 17 #include "components/signin/core/browser/signin_client.h"
18 #include "components/signin/core/browser/signin_internals_util.h" 18 #include "components/signin/core/browser/signin_internals_util.h"
19 #include "components/signin/core/browser/signin_manager_cookie_helper.h" 19 #include "components/signin/core/browser/signin_manager_cookie_helper.h"
20 #include "components/signin/core/browser/signin_metrics.h"
20 #include "components/signin/core/common/signin_pref_names.h" 21 #include "components/signin/core/common/signin_pref_names.h"
21 #include "google_apis/gaia/gaia_auth_util.h" 22 #include "google_apis/gaia/gaia_auth_util.h"
22 #include "google_apis/gaia/gaia_urls.h" 23 #include "google_apis/gaia/gaia_urls.h"
23 #include "net/base/escape.h" 24 #include "net/base/escape.h"
24 #include "third_party/icu/source/i18n/unicode/regex.h" 25 #include "third_party/icu/source/i18n/unicode/regex.h"
25 26
26 using namespace signin_internals_util; 27 using namespace signin_internals_util;
27 28
28 namespace { 29 namespace {
29 30
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 signin_allowed_.Init(prefs::kSigninAllowed, 229 signin_allowed_.Init(prefs::kSigninAllowed,
229 client_->GetPrefs(), 230 client_->GetPrefs(),
230 base::Bind(&SigninManager::OnSigninAllowedPrefChanged, 231 base::Bind(&SigninManager::OnSigninAllowedPrefChanged,
231 base::Unretained(this))); 232 base::Unretained(this)));
232 233
233 std::string user = 234 std::string user =
234 client_->GetPrefs()->GetString(prefs::kGoogleServicesUsername); 235 client_->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
235 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) { 236 if ((!user.empty() && !IsAllowedUsername(user)) || !IsSigninAllowed()) {
236 // User is signed in, but the username is invalid - the administrator must 237 // User is signed in, but the username is invalid - the administrator must
237 // have changed the policy since the last signin, so sign out the user. 238 // have changed the policy since the last signin, so sign out the user.
239 signin_metrics::LogSignout(
240 signin_metrics::SIGNIN_PREF_CHANGED_DURING_SIGNIN);
238 SignOut(); 241 SignOut();
239 } 242 }
240 243
241 InitTokenService(); 244 InitTokenService();
242 account_id_helper_.reset( 245 account_id_helper_.reset(
243 new SigninAccountIdHelper(client_, token_service_, this)); 246 new SigninAccountIdHelper(client_, token_service_, this));
244 } 247 }
245 248
246 void SigninManager::Shutdown() { 249 void SigninManager::Shutdown() {
247 if (merge_session_helper_) 250 if (merge_session_helper_)
248 merge_session_helper_->CancelAll(); 251 merge_session_helper_->CancelAll();
249 252
250 local_state_pref_registrar_.RemoveAll(); 253 local_state_pref_registrar_.RemoveAll();
251 account_id_helper_.reset(); 254 account_id_helper_.reset();
252 SigninManagerBase::Shutdown(); 255 SigninManagerBase::Shutdown();
253 } 256 }
254 257
255 void SigninManager::OnGoogleServicesUsernamePatternChanged() { 258 void SigninManager::OnGoogleServicesUsernamePatternChanged() {
256 if (!GetAuthenticatedUsername().empty() && 259 if (!GetAuthenticatedUsername().empty() &&
257 !IsAllowedUsername(GetAuthenticatedUsername())) { 260 !IsAllowedUsername(GetAuthenticatedUsername())) {
258 // Signed in user is invalid according to the current policy so sign 261 // Signed in user is invalid according to the current policy so sign
259 // the user out. 262 // the user out.
263 signin_metrics::LogSignout(
264 signin_metrics::GOOGLE_SERVICE_NAME_PATTERN_CHANGED);
260 SignOut(); 265 SignOut();
261 } 266 }
262 } 267 }
263 268
264 bool SigninManager::IsSigninAllowed() const { 269 bool SigninManager::IsSigninAllowed() const {
265 return signin_allowed_.GetValue(); 270 return signin_allowed_.GetValue();
266 } 271 }
267 272
268 void SigninManager::OnSigninAllowedPrefChanged() { 273 void SigninManager::OnSigninAllowedPrefChanged() {
269 if (!IsSigninAllowed()) 274 if (!IsSigninAllowed()) {
275 signin_metrics::LogSignout(signin_metrics::SIGNOUT_PREF_CHANGED);
270 SignOut(); 276 SignOut();
277 }
271 } 278 }
272 279
273 // static 280 // static
274 bool SigninManager::IsUsernameAllowedByPolicy(const std::string& username, 281 bool SigninManager::IsUsernameAllowedByPolicy(const std::string& username,
275 const std::string& policy) { 282 const std::string& policy) {
276 if (policy.empty()) 283 if (policy.empty())
277 return true; 284 return true;
278 285
279 // Patterns like "*@foo.com" are not accepted by our regex engine (since they 286 // Patterns like "*@foo.com" are not accepted by our regex engine (since they
280 // are not valid regular expressions - they should instead be ".*@foo.com"). 287 // are not valid regular expressions - they should instead be ".*@foo.com").
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 368
362 password_.clear(); // Don't need it anymore. 369 password_.clear(); // Don't need it anymore.
363 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again. 370 DisableOneClickSignIn(client_->GetPrefs()); // Don't ever offer again.
364 } 371 }
365 372
366 void SigninManager::ProhibitSignout(bool prohibit_signout) { 373 void SigninManager::ProhibitSignout(bool prohibit_signout) {
367 prohibit_signout_ = prohibit_signout; 374 prohibit_signout_ = prohibit_signout;
368 } 375 }
369 376
370 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } 377 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698