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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 // Adds specified user to the whitelist. Returns false if that user is already | 38 // Adds specified user to the whitelist. Returns false if that user is already |
39 // in the whitelist. | 39 // in the whitelist. |
40 bool WhitelistUser(OwnerSettingsServiceChromeOS* service, | 40 bool WhitelistUser(OwnerSettingsServiceChromeOS* service, |
41 const std::string& username) { | 41 const std::string& username) { |
42 if (CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, username, NULL)) | 42 if (CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, username, NULL)) |
43 return false; | 43 return false; |
44 if (service) { | 44 if (service) { |
45 base::StringValue username_value(username); | 45 base::Value username_value(username); |
46 service->AppendToList(kAccountsPrefUsers, username_value); | 46 service->AppendToList(kAccountsPrefUsers, username_value); |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 namespace options { | 53 namespace options { |
54 | 54 |
55 AccountsOptionsHandler::AccountsOptionsHandler() { | 55 AccountsOptionsHandler::AccountsOptionsHandler() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 void AccountsOptionsHandler::HandleUnwhitelistUser( | 121 void AccountsOptionsHandler::HandleUnwhitelistUser( |
122 const base::ListValue* args) { | 122 const base::ListValue* args) { |
123 std::string email; | 123 std::string email; |
124 if (!args->GetString(0, &email)) { | 124 if (!args->GetString(0, &email)) { |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::DELETE_PROFILE_SETTINGS); | 128 ProfileMetrics::LogProfileDeleteUser(ProfileMetrics::DELETE_PROFILE_SETTINGS); |
129 | 129 |
130 base::StringValue canonical_email(gaia::CanonicalizeEmail(email)); | 130 base::Value canonical_email(gaia::CanonicalizeEmail(email)); |
131 if (OwnerSettingsServiceChromeOS* service = | 131 if (OwnerSettingsServiceChromeOS* service = |
132 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { | 132 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { |
133 service->RemoveFromList(kAccountsPrefUsers, canonical_email); | 133 service->RemoveFromList(kAccountsPrefUsers, canonical_email); |
134 } | 134 } |
135 user_manager::UserManager::Get()->RemoveUser(AccountId::FromUserEmail(email), | 135 user_manager::UserManager::Get()->RemoveUser(AccountId::FromUserEmail(email), |
136 nullptr); | 136 nullptr); |
137 } | 137 } |
138 | 138 |
139 void AccountsOptionsHandler::HandleUpdateWhitelist( | 139 void AccountsOptionsHandler::HandleUpdateWhitelist( |
140 const base::ListValue* args) { | 140 const base::ListValue* args) { |
(...skipping 20 matching lines...) Expand all Loading... |
161 if (gaia::ExtractDomainName(whitelisted_user) == | 161 if (gaia::ExtractDomainName(whitelisted_user) == |
162 user_manager::kSupervisedUserDomain) { | 162 user_manager::kSupervisedUserDomain) { |
163 new_list->Remove(i, NULL); | 163 new_list->Remove(i, NULL); |
164 --i; | 164 --i; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 const user_manager::UserList& users = | 168 const user_manager::UserList& users = |
169 user_manager::UserManager::Get()->GetUsers(); | 169 user_manager::UserManager::Get()->GetUsers(); |
170 for (const auto* user : users) { | 170 for (const auto* user : users) { |
171 new_list->AppendIfNotPresent(base::MakeUnique<base::StringValue>( | 171 new_list->AppendIfNotPresent( |
172 user->GetAccountId().GetUserEmail())); | 172 base::MakeUnique<base::Value>(user->GetAccountId().GetUserEmail())); |
173 } | 173 } |
174 | 174 |
175 if (OwnerSettingsServiceChromeOS* service = | 175 if (OwnerSettingsServiceChromeOS* service = |
176 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { | 176 OwnerSettingsServiceChromeOS::FromWebUI(web_ui())) { |
177 service->Set(kAccountsPrefUsers, *new_list.get()); | 177 service->Set(kAccountsPrefUsers, *new_list.get()); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 } // namespace options | 181 } // namespace options |
182 } // namespace chromeos | 182 } // namespace chromeos |
OLD | NEW |