| OLD | NEW |
| 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 "chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.h" | 5 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" | 10 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h" |
| 11 #include "components/prefs/pref_registry_simple.h" | 11 #include "components/prefs/pref_registry_simple.h" |
| 12 #include "components/prefs/pref_service.h" | 12 #include "components/prefs/pref_service.h" |
| 13 #include "components/prefs/scoped_user_pref_update.h" | 13 #include "components/prefs/scoped_user_pref_update.h" |
| 14 #include "components/signin/core/account_id/account_id.h" | |
| 15 #include "components/user_manager/known_user.h" | 14 #include "components/user_manager/known_user.h" |
| 16 | 15 |
| 17 namespace chromeos { | 16 namespace chromeos { |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // A pref list of users who have not finished Easy bootstrapping. | 20 // A pref list of users who have not finished Easy bootstrapping. |
| 22 const char kPendingEasyBootstrapUsers[] = "PendingEasyBootstrapUsers"; | 21 const char kPendingEasyBootstrapUsers[] = "PendingEasyBootstrapUsers"; |
| 23 | 22 |
| 24 } // namespace | 23 } // namespace |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void BootstrapManager::RemoveAllPendingBootstrap() { | 59 void BootstrapManager::RemoveAllPendingBootstrap() { |
| 61 PrefService* local_state = g_browser_process->local_state(); | 60 PrefService* local_state = g_browser_process->local_state(); |
| 62 | 61 |
| 63 const base::ListValue* users = | 62 const base::ListValue* users = |
| 64 local_state->GetList(kPendingEasyBootstrapUsers); | 63 local_state->GetList(kPendingEasyBootstrapUsers); |
| 65 for (size_t i = 0; i < users->GetSize(); ++i) { | 64 for (size_t i = 0; i < users->GetSize(); ++i) { |
| 66 std::string current_user_email; | 65 std::string current_user_email; |
| 67 if (users->GetString(i, ¤t_user_email)) { | 66 if (users->GetString(i, ¤t_user_email)) { |
| 68 delegate_->RemovePendingBootstrapUser( | 67 delegate_->RemovePendingBootstrapUser( |
| 69 user_manager::known_user::GetAccountId(current_user_email, | 68 user_manager::known_user::GetAccountId(current_user_email, |
| 70 std::string() /* id */, | 69 std::string() /* gaia_id */)); |
| 71 AccountType::UNKNOWN)); | |
| 72 } | 70 } |
| 73 } | 71 } |
| 74 | 72 |
| 75 local_state->ClearPref(kPendingEasyBootstrapUsers); | 73 local_state->ClearPref(kPendingEasyBootstrapUsers); |
| 76 local_state->CommitPendingWrite(); | 74 local_state->CommitPendingWrite(); |
| 77 } | 75 } |
| 78 | 76 |
| 79 bool BootstrapManager::HasPendingBootstrap(const AccountId& account_id) const { | 77 bool BootstrapManager::HasPendingBootstrap(const AccountId& account_id) const { |
| 80 PrefService* local_state = g_browser_process->local_state(); | 78 PrefService* local_state = g_browser_process->local_state(); |
| 81 | 79 |
| 82 const base::ListValue* users = | 80 const base::ListValue* users = |
| 83 local_state->GetList(kPendingEasyBootstrapUsers); | 81 local_state->GetList(kPendingEasyBootstrapUsers); |
| 84 for (size_t i = 0; i < users->GetSize(); ++i) { | 82 for (size_t i = 0; i < users->GetSize(); ++i) { |
| 85 std::string current_user; | 83 std::string current_user; |
| 86 if (users->GetString(i, ¤t_user) && | 84 if (users->GetString(i, ¤t_user) && |
| 87 account_id.GetUserEmail() == current_user) | 85 account_id.GetUserEmail() == current_user) |
| 88 return true; | 86 return true; |
| 89 } | 87 } |
| 90 return false; | 88 return false; |
| 91 } | 89 } |
| 92 | 90 |
| 93 } // namespace chromeos | 91 } // namespace chromeos |
| OLD | NEW |