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

Side by Side Diff: chrome/browser/ui/webui/policy_ui.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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
OLDNEW
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/policy_ui.h" 5 #include "chrome/browser/ui/webui/policy_ui.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/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 210
211 void ExtractDomainFromUsername(base::DictionaryValue* dict) { 211 void ExtractDomainFromUsername(base::DictionaryValue* dict) {
212 std::string username; 212 std::string username;
213 dict->GetString("username", &username); 213 dict->GetString("username", &username);
214 if (!username.empty()) 214 if (!username.empty())
215 dict->SetString("domain", gaia::ExtractDomainName(username)); 215 dict->SetString("domain", gaia::ExtractDomainName(username));
216 } 216 }
217 217
218 // Utility function that returns a JSON serialization of the given |dict|. 218 // Utility function that returns a JSON serialization of the given |dict|.
219 scoped_ptr<base::StringValue> DictionaryToJSONString( 219 scoped_ptr<base::StringValue> DictionaryToJSONString(
220 const base::DictionaryValue* dict) { 220 const base::DictionaryValue& dict) {
221 std::string json_string; 221 std::string json_string;
222 base::JSONWriter::WriteWithOptions(dict, 222 base::JSONWriter::WriteWithOptions(dict,
223 base::JSONWriter::OPTIONS_PRETTY_PRINT, 223 base::JSONWriter::OPTIONS_PRETTY_PRINT,
224 &json_string); 224 &json_string);
225 return make_scoped_ptr(new base::StringValue(json_string)); 225 return make_scoped_ptr(new base::StringValue(json_string));
226 } 226 }
227 227
228 // Returns a copy of |value| with some values converted to a representation that 228 // Returns a copy of |value| with some values converted to a representation that
229 // i18n_template.js will display in a nicer way. 229 // i18n_template.js will display in a nicer way.
230 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { 230 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) {
231 const base::DictionaryValue* dict = NULL; 231 const base::DictionaryValue* dict = NULL;
232 if (value->GetAsDictionary(&dict)) 232 if (value->GetAsDictionary(&dict))
233 return DictionaryToJSONString(dict); 233 return DictionaryToJSONString(*dict);
234 234
235 scoped_ptr<base::Value> copy(value->DeepCopy()); 235 scoped_ptr<base::Value> copy(value->DeepCopy());
236 base::ListValue* list = NULL; 236 base::ListValue* list = NULL;
237 if (copy->GetAsList(&list)) { 237 if (copy->GetAsList(&list)) {
238 for (size_t i = 0; i < list->GetSize(); ++i) { 238 for (size_t i = 0; i < list->GetSize(); ++i) {
239 if (list->GetDictionary(i, &dict)) 239 if (list->GetDictionary(i, &dict))
240 list->Set(i, DictionaryToJSONString(dict).release()); 240 list->Set(i, DictionaryToJSONString(*dict).release());
241 } 241 }
242 } 242 }
243 243
244 return copy.Pass(); 244 return copy.Pass();
245 } 245 }
246 246
247 } // namespace 247 } // namespace
248 248
249 // An interface for querying the status of cloud policy. 249 // An interface for querying the status of cloud policy.
250 class CloudPolicyStatusProvider { 250 class CloudPolicyStatusProvider {
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 837 }
838 838
839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
840 web_ui->AddMessageHandler(new PolicyUIHandler); 840 web_ui->AddMessageHandler(new PolicyUIHandler);
841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
842 CreatePolicyUIHTMLSource()); 842 CreatePolicyUIHTMLSource());
843 } 843 }
844 844
845 PolicyUI::~PolicyUI() { 845 PolicyUI::~PolicyUI() {
846 } 846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698