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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 localized_strings->SetString("whitelist_is_managed", | 77 localized_strings->SetString("whitelist_is_managed", |
78 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? | 78 g_browser_process->browser_policy_connector()->IsEnterpriseManaged() ? |
79 ASCIIToUTF16("true") : ASCIIToUTF16("false")); | 79 ASCIIToUTF16("true") : ASCIIToUTF16("false")); |
80 } | 80 } |
81 | 81 |
82 void AccountsOptionsHandler::WhitelistUser(const base::ListValue* args) { | 82 void AccountsOptionsHandler::WhitelistUser(const base::ListValue* args) { |
83 std::string email; | 83 std::string email; |
84 if (!args->GetString(0, &email)) { | 84 if (!args->GetString(0, &email)) { |
85 return; | 85 return; |
86 } | 86 } |
87 // TODO(pastarmovj): Those will change to CrosSettings ops in phase 2. | 87 |
88 UserCrosSettingsProvider::WhitelistUser(Authenticator::Canonicalize(email)); | 88 scoped_ptr<base::StringValue> canonical_email( |
| 89 base::Value::CreateStringValue(Authenticator::Canonicalize(email))); |
| 90 CrosSettings::Get()->AppendToList(kAccountsPrefUsers, canonical_email.get()); |
89 } | 91 } |
90 | 92 |
91 void AccountsOptionsHandler::UnwhitelistUser(const base::ListValue* args) { | 93 void AccountsOptionsHandler::UnwhitelistUser(const base::ListValue* args) { |
92 std::string email; | 94 std::string email; |
93 if (!args->GetString(0, &email)) { | 95 if (!args->GetString(0, &email)) { |
94 return; | 96 return; |
95 } | 97 } |
96 // TODO(pastarmovj): Those will change to CrosSettings ops in phase 2. | 98 |
97 UserCrosSettingsProvider::UnwhitelistUser(Authenticator::Canonicalize(email)); | 99 scoped_ptr<base::StringValue> canonical_email( |
| 100 base::Value::CreateStringValue(Authenticator::Canonicalize(email))); |
| 101 CrosSettings::Get()->RemoveFromList(kAccountsPrefUsers, |
| 102 canonical_email.get()); |
98 UserManager::Get()->RemoveUser(email, NULL); | 103 UserManager::Get()->RemoveUser(email, NULL); |
99 } | 104 } |
100 | 105 |
101 void AccountsOptionsHandler::WhitelistExistingUsers( | 106 void AccountsOptionsHandler::WhitelistExistingUsers( |
102 const base::ListValue* args) { | 107 const base::ListValue* args) { |
103 base::ListValue whitelist_users; | 108 base::ListValue whitelist_users; |
104 const UserList& users = UserManager::Get()->GetUsers(); | 109 const UserList& users = UserManager::Get()->GetUsers(); |
105 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) { | 110 for (UserList::const_iterator it = users.begin(); it < users.end(); ++it) { |
106 const std::string& email = (*it)->email(); | 111 const std::string& email = (*it)->email(); |
107 if (!CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, email)) { | 112 if (!CrosSettings::Get()->FindEmailInList(kAccountsPrefUsers, email)) { |
108 base::DictionaryValue* user_dict = new DictionaryValue; | 113 base::DictionaryValue* user_dict = new DictionaryValue; |
109 user_dict->SetString("name", (*it)->GetDisplayName()); | 114 user_dict->SetString("name", (*it)->GetDisplayName()); |
110 user_dict->SetString("email", email); | 115 user_dict->SetString("email", email); |
111 user_dict->SetBoolean("owner", false); | 116 user_dict->SetBoolean("owner", false); |
112 | 117 |
113 whitelist_users.Append(user_dict); | 118 whitelist_users.Append(user_dict); |
114 } | 119 } |
115 } | 120 } |
116 | 121 |
117 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); | 122 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); |
118 } | 123 } |
119 | 124 |
120 } // namespace chromeos | 125 } // namespace chromeos |
OLD | NEW |