| 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 UserVector users = UserManager::Get()->GetUsers(); | 104 UserVector users = UserManager::Get()->GetUsers(); |
| 107 for (UserVector::const_iterator it = users.begin(); | 105 for (UserVector::const_iterator it = users.begin(); |
| 108 it < users.end(); ++it) { | 106 it < users.end(); ++it) { |
| 109 const std::string& email = it->email(); | 107 const std::string& email = it->email(); |
| 110 base::StringValue email_value(email); | 108 if (CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, email)) { |
| 111 if (user_list->Find(email_value) == user_list->end()) { | |
| 112 base::DictionaryValue* user_dict = new DictionaryValue; | 109 base::DictionaryValue* user_dict = new DictionaryValue; |
| 113 user_dict->SetString("name", it->GetDisplayName()); | 110 user_dict->SetString("name", it->GetDisplayName()); |
| 114 user_dict->SetString("email", email); | 111 user_dict->SetString("email", email); |
| 115 user_dict->SetBoolean("owner", false); | 112 user_dict->SetBoolean("owner", false); |
| 116 | 113 |
| 117 whitelist_users.Append(user_dict); | 114 whitelist_users.Append(user_dict); |
| 118 } | 115 } |
| 119 } | 116 } |
| 120 | 117 |
| 121 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); | 118 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); |
| 122 } | 119 } |
| 123 | 120 |
| 124 } // namespace chromeos | 121 } // namespace chromeos |
| OLD | NEW |