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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 void ExtractDomainFromUsername(base::DictionaryValue* dict) { | 168 void ExtractDomainFromUsername(base::DictionaryValue* dict) { |
169 std::string username; | 169 std::string username; |
170 dict->GetString("username", &username); | 170 dict->GetString("username", &username); |
171 if (!username.empty()) | 171 if (!username.empty()) |
172 dict->SetString("domain", gaia::ExtractDomainName(username)); | 172 dict->SetString("domain", gaia::ExtractDomainName(username)); |
173 } | 173 } |
174 | 174 |
175 // Utility function that returns a JSON serialization of the given |dict|. | 175 // Utility function that returns a JSON serialization of the given |dict|. |
176 std::unique_ptr<base::StringValue> DictionaryToJSONString( | 176 std::unique_ptr<base::Value> DictionaryToJSONString( |
177 const base::DictionaryValue& dict) { | 177 const base::DictionaryValue& dict) { |
178 std::string json_string; | 178 std::string json_string; |
179 base::JSONWriter::WriteWithOptions(dict, | 179 base::JSONWriter::WriteWithOptions(dict, |
180 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 180 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
181 &json_string); | 181 &json_string); |
182 return base::MakeUnique<base::StringValue>(json_string); | 182 return base::MakeUnique<base::Value>(json_string); |
183 } | 183 } |
184 | 184 |
185 // Returns a copy of |value| with some values converted to a representation that | 185 // Returns a copy of |value| with some values converted to a representation that |
186 // i18n_template.js will display in a nicer way. | 186 // i18n_template.js will display in a nicer way. |
187 std::unique_ptr<base::Value> CopyAndConvert(const base::Value* value) { | 187 std::unique_ptr<base::Value> CopyAndConvert(const base::Value* value) { |
188 const base::DictionaryValue* dict = NULL; | 188 const base::DictionaryValue* dict = NULL; |
189 if (value->GetAsDictionary(&dict)) | 189 if (value->GetAsDictionary(&dict)) |
190 return DictionaryToJSONString(*dict); | 190 return DictionaryToJSONString(*dict); |
191 | 191 |
192 std::unique_ptr<base::Value> copy = value->CreateDeepCopy(); | 192 std::unique_ptr<base::Value> copy = value->CreateDeepCopy(); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 } | 815 } |
816 | 816 |
817 void PolicyUIHandler::OnRefreshPoliciesDone() const { | 817 void PolicyUIHandler::OnRefreshPoliciesDone() const { |
818 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); | 818 web_ui()->CallJavascriptFunctionUnsafe("policy.Page.reloadPoliciesDone"); |
819 } | 819 } |
820 | 820 |
821 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 821 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
822 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 822 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
823 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 823 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
824 } | 824 } |
OLD | NEW |