user_directory_integrity_manager.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/user_manager/user_directory_integrity_manager.h"
  5. #include "components/prefs/pref_service.h"
  6. namespace user_manager {
  7. namespace {
  8. const char kUserDirectoryIntegrityPref[] = "incomplete_login_user";
  9. } // namespace
  10. UserDirectoryIntegrityManager::UserDirectoryIntegrityManager(
  11. PrefService* local_state)
  12. : local_state_(local_state) {}
  13. UserDirectoryIntegrityManager::~UserDirectoryIntegrityManager() = default;
  14. // static
  15. void UserDirectoryIntegrityManager::RegisterLocalStatePrefs(
  16. PrefRegistrySimple* registry) {
  17. registry->RegisterStringPref(kUserDirectoryIntegrityPref, {});
  18. }
  19. void UserDirectoryIntegrityManager::RecordCreatingNewUser(
  20. const AccountId& account_id) {
  21. local_state_->SetString(kUserDirectoryIntegrityPref,
  22. account_id.GetUserEmail());
  23. local_state_->CommitPendingWrite();
  24. }
  25. void UserDirectoryIntegrityManager::RecordAuthFactorAdded(
  26. const AccountId& account_id) {
  27. local_state_->ClearPref(kUserDirectoryIntegrityPref);
  28. local_state_->CommitPendingWrite();
  29. }
  30. std::string UserDirectoryIntegrityManager::GetIncompleteUser() {
  31. return local_state_->GetString(kUserDirectoryIntegrityPref);
  32. }
  33. } // namespace user_manager