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

Side by Side Diff: components/user_manager/known_user.cc

Issue 2711113003: Track whether a given user session has completed initialization, and use (Closed)
Patch Set: Review feedback Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/user_manager/known_user.h" 5 #include "components/user_manager/known_user.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 // Key of GAPS cookie. 47 // Key of GAPS cookie.
48 const char kGAPSCookie[] = "gaps_cookie"; 48 const char kGAPSCookie[] = "gaps_cookie";
49 49
50 // Key of the reason for re-auth. 50 // Key of the reason for re-auth.
51 const char kReauthReasonKey[] = "reauth_reason"; 51 const char kReauthReasonKey[] = "reauth_reason";
52 52
53 // Key for the GaiaId migration status. 53 // Key for the GaiaId migration status.
54 const char kGaiaIdMigration[] = "gaia_id_migration"; 54 const char kGaiaIdMigration[] = "gaia_id_migration";
55 55
56 // Key of the boolean flag telling if user session has finished init yet.
57 const char kProfileEverInitialized[] = "profile_ever_initialized";
58
56 PrefService* GetLocalState() { 59 PrefService* GetLocalState() {
57 if (!UserManager::IsInitialized()) 60 if (!UserManager::IsInitialized())
58 return nullptr; 61 return nullptr;
59 62
60 return UserManager::Get()->GetLocalState(); 63 return UserManager::Get()->GetLocalState();
61 } 64 }
62 65
63 // Checks if values in |dict| correspond with |account_id| identity. 66 // Checks if values in |dict| correspond with |account_id| identity.
64 bool UserMatches(const AccountId& account_id, 67 bool UserMatches(const AccountId& account_id,
65 const base::DictionaryValue& dict) { 68 const base::DictionaryValue& dict) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 SetBooleanPref(account_id, kUsingSAMLKey, using_saml); 447 SetBooleanPref(account_id, kUsingSAMLKey, using_saml);
445 } 448 }
446 449
447 bool IsUsingSAML(const AccountId& account_id) { 450 bool IsUsingSAML(const AccountId& account_id) {
448 bool using_saml; 451 bool using_saml;
449 if (GetBooleanPref(account_id, kUsingSAMLKey, &using_saml)) 452 if (GetBooleanPref(account_id, kUsingSAMLKey, &using_saml))
450 return using_saml; 453 return using_saml;
451 return false; 454 return false;
452 } 455 }
453 456
457 bool WasProfileEverInitialized(const AccountId& account_id) {
458 bool profile_ever_initialized;
459 if (GetBooleanPref(account_id, kProfileEverInitialized,
460 &profile_ever_initialized))
461 return profile_ever_initialized;
462
463 // Sessions created before we started setting the session_initialized flag
464 // should default to "initialized = true".
465 LOG(WARNING) << "Treating unmigrated user as profile_ever_initialized=true";
466 return true;
467 }
468
469 void SetProfileEverInitialized(const AccountId& account_id, bool initialized) {
470 SetBooleanPref(account_id, kProfileEverInitialized, initialized);
471 }
472
454 void UpdateReauthReason(const AccountId& account_id, const int reauth_reason) { 473 void UpdateReauthReason(const AccountId& account_id, const int reauth_reason) {
455 SetIntegerPref(account_id, kReauthReasonKey, reauth_reason); 474 SetIntegerPref(account_id, kReauthReasonKey, reauth_reason);
456 } 475 }
457 476
458 bool FindReauthReason(const AccountId& account_id, int* out_value) { 477 bool FindReauthReason(const AccountId& account_id, int* out_value) {
459 return GetIntegerPref(account_id, kReauthReasonKey, out_value); 478 return GetIntegerPref(account_id, kReauthReasonKey, out_value);
460 } 479 }
461 480
462 void RemovePrefs(const AccountId& account_id) { 481 void RemovePrefs(const AccountId& account_id) {
463 PrefService* local_state = GetLocalState(); 482 PrefService* local_state = GetLocalState();
(...skipping 13 matching lines...) Expand all
477 } 496 }
478 } 497 }
479 } 498 }
480 499
481 void RegisterPrefs(PrefRegistrySimple* registry) { 500 void RegisterPrefs(PrefRegistrySimple* registry) {
482 registry->RegisterListPref(kKnownUsers); 501 registry->RegisterListPref(kKnownUsers);
483 } 502 }
484 503
485 } // namespace known_user 504 } // namespace known_user
486 } // namespace user_manager 505 } // namespace user_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698