| 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_handler.h" | 5 #include "chrome/browser/ui/webui/policy_ui_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 dict->SetString("domain", gaia::ExtractDomainName(username)); | 167 dict->SetString("domain", gaia::ExtractDomainName(username)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Utility function that returns a JSON serialization of the given |dict|. | 170 // Utility function that returns a JSON serialization of the given |dict|. |
| 171 std::unique_ptr<base::StringValue> DictionaryToJSONString( | 171 std::unique_ptr<base::StringValue> DictionaryToJSONString( |
| 172 const base::DictionaryValue& dict) { | 172 const base::DictionaryValue& dict) { |
| 173 std::string json_string; | 173 std::string json_string; |
| 174 base::JSONWriter::WriteWithOptions(dict, | 174 base::JSONWriter::WriteWithOptions(dict, |
| 175 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 175 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 176 &json_string); | 176 &json_string); |
| 177 return base::WrapUnique(new base::StringValue(json_string)); | 177 return base::MakeUnique<base::StringValue>(json_string); |
| 178 } | 178 } |
| 179 | 179 |
| 180 // Returns a copy of |value| with some values converted to a representation that | 180 // Returns a copy of |value| with some values converted to a representation that |
| 181 // i18n_template.js will display in a nicer way. | 181 // i18n_template.js will display in a nicer way. |
| 182 std::unique_ptr<base::Value> CopyAndConvert(const base::Value* value) { | 182 std::unique_ptr<base::Value> CopyAndConvert(const base::Value* value) { |
| 183 const base::DictionaryValue* dict = NULL; | 183 const base::DictionaryValue* dict = NULL; |
| 184 if (value->GetAsDictionary(&dict)) | 184 if (value->GetAsDictionary(&dict)) |
| 185 return DictionaryToJSONString(*dict); | 185 return DictionaryToJSONString(*dict); |
| 186 | 186 |
| 187 std::unique_ptr<base::Value> copy = value->CreateDeepCopy(); | 187 std::unique_ptr<base::Value> copy = value->CreateDeepCopy(); |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 } | 743 } |
| 744 | 744 |
| 745 void PolicyUIHandler::OnRefreshPoliciesDone() const { | 745 void PolicyUIHandler::OnRefreshPoliciesDone() const { |
| 746 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); | 746 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); |
| 747 } | 747 } |
| 748 | 748 |
| 749 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 749 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
| 750 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 750 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
| 751 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 751 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
| 752 } | 752 } |
| OLD | NEW |