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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 void AccountsOptionsHandler::HandleUnwhitelistUser( | 109 void AccountsOptionsHandler::HandleUnwhitelistUser( |
110 const base::ListValue* args) { | 110 const base::ListValue* args) { |
111 std::string email; | 111 std::string email; |
112 if (!args->GetString(0, &email)) { | 112 if (!args->GetString(0, &email)) { |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 base::StringValue canonical_email(gaia::CanonicalizeEmail(email)); | 116 base::StringValue canonical_email(gaia::CanonicalizeEmail(email)); |
117 CrosSettings::Get()->RemoveFromList(kAccountsPrefUsers, &canonical_email); | 117 CrosSettings::Get()->RemoveFromList(kAccountsPrefUsers, &canonical_email); |
118 UserManager::Get()->RemoveUser(email, NULL); | 118 GetUserManager()->RemoveUser(email, NULL); |
119 } | 119 } |
120 | 120 |
121 void AccountsOptionsHandler::HandleWhitelistExistingUsers( | 121 void AccountsOptionsHandler::HandleWhitelistExistingUsers( |
122 const base::ListValue* args) { | 122 const base::ListValue* args) { |
123 DCHECK(args && args->empty()); | 123 DCHECK(args && args->empty()); |
124 | 124 |
125 // Creates one list to set. This is needed because user white list update is | 125 // Creates one list to set. This is needed because user white list update is |
126 // asynchronous and sequential. Before previous write comes back, cached list | 126 // asynchronous and sequential. Before previous write comes back, cached list |
127 // is stale and should not be used for appending. See http://crbug.com/127215 | 127 // is stale and should not be used for appending. See http://crbug.com/127215 |
128 scoped_ptr<base::ListValue> new_list; | 128 scoped_ptr<base::ListValue> new_list; |
129 | 129 |
130 CrosSettings* cros_settings = CrosSettings::Get(); | 130 CrosSettings* cros_settings = CrosSettings::Get(); |
131 const base::ListValue* existing = NULL; | 131 const base::ListValue* existing = NULL; |
132 if (cros_settings->GetList(kAccountsPrefUsers, &existing) && existing) | 132 if (cros_settings->GetList(kAccountsPrefUsers, &existing) && existing) |
133 new_list.reset(existing->DeepCopy()); | 133 new_list.reset(existing->DeepCopy()); |
134 else | 134 else |
135 new_list.reset(new base::ListValue); | 135 new_list.reset(new base::ListValue); |
136 | 136 |
137 const UserList& users = UserManager::Get()->GetUsers(); | 137 const UserList& users = GetUserManager()->GetUsers(); |
138 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) | 138 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) |
139 new_list->AppendIfNotPresent(new base::StringValue((*it)->email())); | 139 new_list->AppendIfNotPresent(new base::StringValue((*it)->email())); |
140 | 140 |
141 cros_settings->Set(kAccountsPrefUsers, *new_list.get()); | 141 cros_settings->Set(kAccountsPrefUsers, *new_list.get()); |
142 } | 142 } |
143 | 143 |
144 } // namespace options | 144 } // namespace options |
145 } // namespace chromeos | 145 } // namespace chromeos |
OLD | NEW |