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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 213 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
214 &json_string); | 214 &json_string); |
215 return make_scoped_ptr(new base::StringValue(json_string)); | 215 return make_scoped_ptr(new base::StringValue(json_string)); |
216 } | 216 } |
217 | 217 |
218 // Returns a copy of |value| with some values converted to a representation that | 218 // Returns a copy of |value| with some values converted to a representation that |
219 // i18n_template.js will display in a nicer way. | 219 // i18n_template.js will display in a nicer way. |
220 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { | 220 scoped_ptr<base::Value> CopyAndConvert(const base::Value* value) { |
221 const base::DictionaryValue* dict = NULL; | 221 const base::DictionaryValue* dict = NULL; |
222 if (value->GetAsDictionary(&dict)) | 222 if (value->GetAsDictionary(&dict)) |
223 return DictionaryToJSONString(dict).PassAs<base::Value>(); | 223 return DictionaryToJSONString(dict); |
224 | 224 |
225 scoped_ptr<base::Value> copy(value->DeepCopy()); | 225 scoped_ptr<base::Value> copy(value->DeepCopy()); |
226 base::ListValue* list = NULL; | 226 base::ListValue* list = NULL; |
227 if (copy->GetAsList(&list)) { | 227 if (copy->GetAsList(&list)) { |
228 for (size_t i = 0; i < list->GetSize(); ++i) { | 228 for (size_t i = 0; i < list->GetSize(); ++i) { |
229 if (list->GetDictionary(i, &dict)) | 229 if (list->GetDictionary(i, &dict)) |
230 list->Set(i, DictionaryToJSONString(dict).release()); | 230 list->Set(i, DictionaryToJSONString(dict).release()); |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 } | 788 } |
789 | 789 |
790 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 790 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
791 web_ui->AddMessageHandler(new PolicyUIHandler); | 791 web_ui->AddMessageHandler(new PolicyUIHandler); |
792 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 792 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
793 CreatePolicyUIHTMLSource()); | 793 CreatePolicyUIHTMLSource()); |
794 } | 794 } |
795 | 795 |
796 PolicyUI::~PolicyUI() { | 796 PolicyUI::~PolicyUI() { |
797 } | 797 } |
OLD | NEW |