OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/options/chromeos/accounts_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 WhitelistUser(service, gaia::CanonicalizeEmail(typed_email)); | 114 WhitelistUser(service, gaia::CanonicalizeEmail(typed_email)); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 void AccountsOptionsHandler::HandleUnwhitelistUser( | 118 void AccountsOptionsHandler::HandleUnwhitelistUser( |
119 const base::ListValue* args) { | 119 const base::ListValue* args) { |
120 std::string email; | 120 std::string email; |
121 if (!args->GetString(0, &email)) { | 121 if (!args->GetString(0, &email)) { |
122 return; | 122 return; |
123 } | 123 } |
| 124 const user_manager::UserID user_id(user_manager::UserID::FromUserEmail(gaia::C
anonicalizeEmail(email))); |
124 | 125 |
125 base::StringValue canonical_email(gaia::CanonicalizeEmail(email)); | 126 base::StringValue canonical_email(user_id.GetUserEmail()); |
126 if (OwnerSettingsServiceChromeOS* service = | 127 if (OwnerSettingsServiceChromeOS* service = |
127 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { | 128 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { |
128 service->RemoveFromList(kAccountsPrefUsers, canonical_email); | 129 service->RemoveFromList(kAccountsPrefUsers, canonical_email); |
129 } | 130 } |
130 user_manager::UserManager::Get()->RemoveUser(email, NULL); | 131 user_manager::UserManager::Get()->RemoveUser(user_id, NULL); |
131 } | 132 } |
132 | 133 |
133 void AccountsOptionsHandler::HandleUpdateWhitelist( | 134 void AccountsOptionsHandler::HandleUpdateWhitelist( |
134 const base::ListValue* args) { | 135 const base::ListValue* args) { |
135 DCHECK(args && args->empty()); | 136 DCHECK(args && args->empty()); |
136 | 137 |
137 // Creates one list to set. This is needed because user white list update is | 138 // Creates one list to set. This is needed because user white list update is |
138 // asynchronous and sequential. Before previous write comes back, cached list | 139 // asynchronous and sequential. Before previous write comes back, cached list |
139 // is stale and should not be used for appending. See http://crbug.com/127215 | 140 // is stale and should not be used for appending. See http://crbug.com/127215 |
140 scoped_ptr<base::ListValue> new_list; | 141 scoped_ptr<base::ListValue> new_list; |
(...skipping 16 matching lines...) Expand all Loading... |
157 new_list->Remove(i, NULL); | 158 new_list->Remove(i, NULL); |
158 --i; | 159 --i; |
159 } | 160 } |
160 } | 161 } |
161 | 162 |
162 const user_manager::UserList& users = | 163 const user_manager::UserList& users = |
163 user_manager::UserManager::Get()->GetUsers(); | 164 user_manager::UserManager::Get()->GetUsers(); |
164 for (user_manager::UserList::const_iterator it = users.begin(); | 165 for (user_manager::UserList::const_iterator it = users.begin(); |
165 it < users.end(); | 166 it < users.end(); |
166 ++it) | 167 ++it) |
167 new_list->AppendIfNotPresent(new base::StringValue((*it)->email())); | 168 new_list->AppendIfNotPresent(new base::StringValue((*it)->GetUserID().GetUse
rEmail())); |
168 | 169 |
169 if (OwnerSettingsServiceChromeOS* service = | 170 if (OwnerSettingsServiceChromeOS* service = |
170 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { | 171 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { |
171 service->Set(kAccountsPrefUsers, *new_list.get()); | 172 service->Set(kAccountsPrefUsers, *new_list.get()); |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 } // namespace options | 176 } // namespace options |
176 } // namespace chromeos | 177 } // namespace chromeos |
OLD | NEW |