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