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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 registry->RegisterListPref(kPendingEasyBootstrapUsers); | 24 registry->RegisterListPref(kPendingEasyBootstrapUsers); |
25 } | 25 } |
26 | 26 |
27 BootstrapManager::BootstrapManager(Delegate* delegate) | 27 BootstrapManager::BootstrapManager(Delegate* delegate) |
28 : delegate_(delegate) { | 28 : delegate_(delegate) { |
29 } | 29 } |
30 | 30 |
31 BootstrapManager::~BootstrapManager() { | 31 BootstrapManager::~BootstrapManager() { |
32 } | 32 } |
33 | 33 |
34 void BootstrapManager::AddPendingBootstrap(const std::string& user_id) { | 34 void BootstrapManager::AddPendingBootstrap(const user_manager::UserID& user_id)
{ |
35 DCHECK(!user_id.empty()); | 35 DCHECK(!user_id.empty()); |
36 PrefService* local_state = g_browser_process->local_state(); | 36 PrefService* local_state = g_browser_process->local_state(); |
37 | 37 |
38 ListPrefUpdate update(local_state, kPendingEasyBootstrapUsers); | 38 ListPrefUpdate update(local_state, kPendingEasyBootstrapUsers); |
39 update->AppendString(user_id); | 39 update->AppendString(user_id.GetUserEmail()); |
40 } | 40 } |
41 | 41 |
42 void BootstrapManager::FinishPendingBootstrap(const std::string& user_id) { | 42 void BootstrapManager::FinishPendingBootstrap(const user_manager::UserID& user_i
d) { |
43 PrefService* local_state = g_browser_process->local_state(); | 43 PrefService* local_state = g_browser_process->local_state(); |
44 | 44 |
45 ListPrefUpdate update(local_state, kPendingEasyBootstrapUsers); | 45 ListPrefUpdate update(local_state, kPendingEasyBootstrapUsers); |
46 for (size_t i = 0; i < update->GetSize(); ++i) { | 46 for (size_t i = 0; i < update->GetSize(); ++i) { |
47 std::string current_user; | 47 std::string current_user; |
48 if (update->GetString(i, ¤t_user) && user_id == current_user) { | 48 if (update->GetString(i, ¤t_user) && user_id.GetUserEmail() == current
_user) { |
49 update->Remove(i, NULL); | 49 update->Remove(i, NULL); |
50 break; | 50 break; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 void BootstrapManager::RemoveAllPendingBootstrap() { | 55 void BootstrapManager::RemoveAllPendingBootstrap() { |
56 PrefService* local_state = g_browser_process->local_state(); | 56 PrefService* local_state = g_browser_process->local_state(); |
57 | 57 |
58 const base::ListValue* users = | 58 const base::ListValue* users = |
59 local_state->GetList(kPendingEasyBootstrapUsers); | 59 local_state->GetList(kPendingEasyBootstrapUsers); |
60 for (size_t i = 0; i < users->GetSize(); ++i) { | 60 for (size_t i = 0; i < users->GetSize(); ++i) { |
61 std::string current_user; | 61 std::string current_user_email; |
62 if (users->GetString(i, ¤t_user)) | 62 if (users->GetString(i, ¤t_user_email)) |
63 delegate_->RemovePendingBootstrapUser(current_user); | 63 delegate_->RemovePendingBootstrapUser(user_manager::UserID::FromUserEmail(
current_user_email)); |
64 } | 64 } |
65 | 65 |
66 local_state->ClearPref(kPendingEasyBootstrapUsers); | 66 local_state->ClearPref(kPendingEasyBootstrapUsers); |
67 local_state->CommitPendingWrite(); | 67 local_state->CommitPendingWrite(); |
68 } | 68 } |
69 | 69 |
70 bool BootstrapManager::HasPendingBootstrap(const std::string& user_id) const { | 70 bool BootstrapManager::HasPendingBootstrap(const user_manager::UserID& user_id)
const { |
71 PrefService* local_state = g_browser_process->local_state(); | 71 PrefService* local_state = g_browser_process->local_state(); |
72 | 72 |
73 const base::ListValue* users = | 73 const base::ListValue* users = |
74 local_state->GetList(kPendingEasyBootstrapUsers); | 74 local_state->GetList(kPendingEasyBootstrapUsers); |
75 for (size_t i = 0; i < users->GetSize(); ++i) { | 75 for (size_t i = 0; i < users->GetSize(); ++i) { |
76 std::string current_user; | 76 std::string current_user_email; |
77 if (users->GetString(i, ¤t_user) && user_id == current_user) | 77 if (users->GetString(i, ¤t_user_email) && user_id.GetUserEmail() == cu
rrent_user_email) |
78 return true; | 78 return true; |
79 } | 79 } |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 } // namespace chromeos | 83 } // namespace chromeos |
OLD | NEW |