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

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

Issue 100823007: Stop doing unnecessary UTF-8 to UTF-16 conversions in JSONWriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS page encodings Created 7 years 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
« no previous file with comments | « chrome/browser/ui/webui/about_ui.cc ('k') | chrome/renderer/searchbox/searchbox_extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 dict->GetString("username", &username); 172 dict->GetString("username", &username);
173 if (!username.empty()) 173 if (!username.empty())
174 dict->SetString("domain", gaia::ExtractDomainName(username)); 174 dict->SetString("domain", gaia::ExtractDomainName(username));
175 } 175 }
176 176
177 // Utility function that returns a JSON serialization of the given |dict|. 177 // Utility function that returns a JSON serialization of the given |dict|.
178 scoped_ptr<base::StringValue> DictionaryToJSONString( 178 scoped_ptr<base::StringValue> DictionaryToJSONString(
179 const base::DictionaryValue* dict) { 179 const base::DictionaryValue* dict) {
180 std::string json_string; 180 std::string json_string;
181 base::JSONWriter::WriteWithOptions(dict, 181 base::JSONWriter::WriteWithOptions(dict,
182 base::JSONWriter::OPTIONS_DO_NOT_ESCAPE | 182 base::JSONWriter::OPTIONS_PRETTY_PRINT,
183 base::JSONWriter::OPTIONS_PRETTY_PRINT,
184 &json_string); 183 &json_string);
185 return make_scoped_ptr(new base::StringValue(json_string)); 184 return make_scoped_ptr(new base::StringValue(json_string));
186 } 185 }
187 186
188 // Returns a copy of |value| with some values converted to a representation that 187 // Returns a copy of |value| with some values converted to a representation that
189 // i18n_template.js will display in a nicer way. 188 // i18n_template.js will display in a nicer way.
190 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { 189 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) {
191 const base::DictionaryValue* dict = NULL; 190 const base::DictionaryValue* dict = NULL;
192 if (value->GetAsDictionary(&dict)) 191 if (value->GetAsDictionary(&dict))
193 return DictionaryToJSONString(dict).PassAs<base::Value>(); 192 return DictionaryToJSONString(dict).PassAs<base::Value>();
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 756 }
758 757
759 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 758 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
760 web_ui->AddMessageHandler(new PolicyUIHandler); 759 web_ui->AddMessageHandler(new PolicyUIHandler);
761 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 760 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
762 CreatePolicyUIHTMLSource()); 761 CreatePolicyUIHTMLSource());
763 } 762 }
764 763
765 PolicyUI::~PolicyUI() { 764 PolicyUI::~PolicyUI() {
766 } 765 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/about_ui.cc ('k') | chrome/renderer/searchbox/searchbox_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698