OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |