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