Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc

Issue 8163011: PART3: Removed whitelist special ops. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on the new PART2. (I think it should be 100% the same but I'd rather upload it) Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 base::StringValue canonical_email(Authenticator::Canonicalize(email));
89 CrosSettings::Get()->AppendToList(kAccountsPrefUsers, canonical_email);
89 } 90 }
90 91
91 void AccountsOptionsHandler::UnwhitelistUser(const base::ListValue* args) { 92 void AccountsOptionsHandler::UnwhitelistUser(const base::ListValue* args) {
92 std::string email; 93 std::string email;
93 if (!args->GetString(0, &email)) { 94 if (!args->GetString(0, &email)) {
94 return; 95 return;
95 } 96 }
96 // TODO(pastarmovj): Those will change to CrosSettings ops in phase 2. 97
97 UserCrosSettingsProvider::UnwhitelistUser(Authenticator::Canonicalize(email)); 98 base::StringValue canonical_email(Authenticator::Canonicalize(email));
99 CrosSettings::Get()->RemoveFromList(kAccountsPrefUsers, canonical_email);
98 UserManager::Get()->RemoveUser(email, NULL); 100 UserManager::Get()->RemoveUser(email, NULL);
99 } 101 }
100 102
101 void AccountsOptionsHandler::WhitelistExistingUsers( 103 void AccountsOptionsHandler::WhitelistExistingUsers(
102 const base::ListValue* args) { 104 const base::ListValue* args) {
103 base::ListValue whitelist_users; 105 base::ListValue whitelist_users;
104 const base::ListValue *user_list; 106 const base::ListValue *user_list;
105 CrosSettings::Get()->GetList(kAccountsPrefUsers, &user_list); 107 CrosSettings::Get()->GetList(kAccountsPrefUsers, &user_list);
106 UserVector users = UserManager::Get()->GetUsers(); 108 UserVector users = UserManager::Get()->GetUsers();
107 for (UserVector::const_iterator it = users.begin(); 109 for (UserVector::const_iterator it = users.begin();
108 it < users.end(); ++it) { 110 it < users.end(); ++it) {
109 const std::string& email = it->email(); 111 const std::string& email = it->email();
110 base::StringValue email_value(email); 112 base::StringValue email_value(email);
111 if (user_list->Find(email_value) == user_list->end()) { 113 if (user_list->Find(email_value) == user_list->end()) {
112 base::DictionaryValue* user_dict = new DictionaryValue; 114 base::DictionaryValue* user_dict = new DictionaryValue;
113 user_dict->SetString("name", it->GetDisplayName()); 115 user_dict->SetString("name", it->GetDisplayName());
114 user_dict->SetString("email", email); 116 user_dict->SetString("email", email);
115 user_dict->SetBoolean("owner", false); 117 user_dict->SetBoolean("owner", false);
116 118
117 whitelist_users.Append(user_dict); 119 whitelist_users.Append(user_dict);
118 } 120 }
119 } 121 }
120 122
121 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); 123 web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users);
122 } 124 }
123 125
124 } // namespace chromeos 126 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698