| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 dict->GetString("username", &username); | 171 dict->GetString("username", &username); |
| 172 if (!username.empty()) | 172 if (!username.empty()) |
| 173 dict->SetString("domain", gaia::ExtractDomainName(username)); | 173 dict->SetString("domain", gaia::ExtractDomainName(username)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 // Utility function that returns a JSON serialization of the given |dict|. | 176 // Utility function that returns a JSON serialization of the given |dict|. |
| 177 scoped_ptr<base::StringValue> DictionaryToJSONString( | 177 scoped_ptr<base::StringValue> DictionaryToJSONString( |
| 178 const base::DictionaryValue* dict) { | 178 const base::DictionaryValue* dict) { |
| 179 std::string json_string; | 179 std::string json_string; |
| 180 base::JSONWriter::WriteWithOptions(dict, | 180 base::JSONWriter::WriteWithOptions(dict, |
| 181 base::JSONWriter::OPTIONS_DO_NOT_ESCAPE | | 181 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 182 base::JSONWriter::OPTIONS_PRETTY_PRINT, | |
| 183 &json_string); | 182 &json_string); |
| 184 return make_scoped_ptr(new base::StringValue(json_string)); | 183 return make_scoped_ptr(new base::StringValue(json_string)); |
| 185 } | 184 } |
| 186 | 185 |
| 187 // Returns a copy of |value| with some values converted to a representation that | 186 // Returns a copy of |value| with some values converted to a representation that |
| 188 // i18n_template.js will display in a nicer way. | 187 // i18n_template.js will display in a nicer way. |
| 189 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { | 188 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { |
| 190 const base::DictionaryValue* dict = NULL; | 189 const base::DictionaryValue* dict = NULL; |
| 191 if (value->GetAsDictionary(&dict)) | 190 if (value->GetAsDictionary(&dict)) |
| 192 return DictionaryToJSONString(dict).PassAs<base::Value>(); | 191 return DictionaryToJSONString(dict).PassAs<base::Value>(); |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 } | 755 } |
| 757 | 756 |
| 758 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 757 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 759 web_ui->AddMessageHandler(new PolicyUIHandler); | 758 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 760 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 759 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 761 CreatePolicyUIHTMLSource()); | 760 CreatePolicyUIHTMLSource()); |
| 762 } | 761 } |
| 763 | 762 |
| 764 PolicyUI::~PolicyUI() { | 763 PolicyUI::~PolicyUI() { |
| 765 } | 764 } |
| OLD | NEW |