| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 // TODO(pastarmovj): Those will change to CrosSettings ops in phase 2. | 96 // TODO(pastarmovj): Those will change to CrosSettings ops in phase 2. |
| 97 UserCrosSettingsProvider::UnwhitelistUser(Authenticator::Canonicalize(email)); | 97 UserCrosSettingsProvider::UnwhitelistUser(Authenticator::Canonicalize(email)); |
| 98 UserManager::Get()->RemoveUser(email, NULL); | 98 UserManager::Get()->RemoveUser(email, NULL); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void AccountsOptionsHandler::WhitelistExistingUsers( | 101 void AccountsOptionsHandler::WhitelistExistingUsers( |
| 102 const base::ListValue* args) { | 102 const base::ListValue* args) { |
| 103 base::ListValue whitelist_users; | 103 base::ListValue whitelist_users; |
| 104 const base::ListValue *user_list; | |
| 105 CrosSettings::Get()->GetList(kAccountsPrefUsers, &user_list); | |
| 106 const UserList& users = UserManager::Get()->GetUsers(); | 104 const UserList& users = UserManager::Get()->GetUsers(); |
| 107 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) { | 105 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) { |
| 108 const std::string& email = (*it)->email(); | 106 const std::string& email = (*it)->email(); |
| 109 base::StringValue email_value(email); | 107 if (CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, email)) { |
| 110 if (user_list->Find(email_value) == user_list->end()) { | |
| 111 base::DictionaryValue* user_dict = new DictionaryValue; | 108 base::DictionaryValue* user_dict = new DictionaryValue; |
| 112 user_dict->SetString("name", (*it)->GetDisplayName()); | 109 user_dict->SetString("name", (*it)->GetDisplayName()); |
| 113 user_dict->SetString("email", email); | 110 user_dict->SetString("email", email); |
| 114 user_dict->SetBoolean("owner", false); | 111 user_dict->SetBoolean("owner", false); |
| 115 | 112 |
| 116 whitelist_users.Append(user_dict); | 113 whitelist_users.Append(user_dict); |
| 117 } | 114 } |
| 118 } | 115 } |
| 119 | 116 |
| 120 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); | 117 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); |
| 121 } | 118 } |
| 122 | 119 |
| 123 } // namespace chromeos | 120 } // namespace chromeos |
| OLD | NEW |