| 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 <vector> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 9 #include "base/hash_tables.h" | 11 #include "base/hash_tables.h" |
| 10 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 11 #include "base/time.h" | 13 #include "base/time.h" |
| 12 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/policy/browser_policy_connector.h" | 16 #include "chrome/browser/policy/browser_policy_connector.h" |
| 15 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 17 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 16 #include "chrome/browser/policy/cloud_policy_data_store.h" | 18 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 base::Bind(&PolicyUIHandler::OnRefreshDone, | 187 base::Bind(&PolicyUIHandler::OnRefreshDone, |
| 186 weak_factory_.GetWeakPtr())); | 188 weak_factory_.GetWeakPtr())); |
| 187 } | 189 } |
| 188 | 190 |
| 189 void PolicyUIHandler::OnRefreshDone() { | 191 void PolicyUIHandler::OnRefreshDone() { |
| 190 web_ui()->CallJavascriptFunction("Policy.refreshDone"); | 192 web_ui()->CallJavascriptFunction("Policy.refreshDone"); |
| 191 } | 193 } |
| 192 | 194 |
| 193 void PolicyUIHandler::SendDataToUI() { | 195 void PolicyUIHandler::SendDataToUI() { |
| 194 policy::PolicyService* service = g_browser_process->policy_service(); | 196 policy::PolicyService* service = g_browser_process->policy_service(); |
| 195 const policy::PolicyMap* policies = | |
| 196 service->GetPolicies(policy::POLICY_DOMAIN_CHROME, ""); | |
| 197 bool any_policies_set = false; | 197 bool any_policies_set = false; |
| 198 base::ListValue* list; | 198 base::ListValue* list = |
| 199 if (policies) | 199 GetPolicyStatusList( |
| 200 list = GetPolicyStatusList(*policies, &any_policies_set).release(); | 200 service->GetPolicies(policy::POLICY_DOMAIN_CHROME, std::string()), |
| 201 else | 201 &any_policies_set).release(); |
| 202 list = new base::ListValue(); | |
| 203 | |
| 204 base::DictionaryValue results; | 202 base::DictionaryValue results; |
| 205 results.Set("policies", list); | 203 results.Set("policies", list); |
| 206 results.SetBoolean("anyPoliciesSet", any_policies_set); | 204 results.SetBoolean("anyPoliciesSet", any_policies_set); |
| 207 base::DictionaryValue* dict = GetStatusData(); | 205 base::DictionaryValue* dict = GetStatusData(); |
| 208 results.Set("status", dict); | 206 results.Set("status", dict); |
| 209 web_ui()->CallJavascriptFunction("Policy.returnData", results); | 207 web_ui()->CallJavascriptFunction("Policy.returnData", results); |
| 210 } | 208 } |
| 211 | 209 |
| 212 // static | 210 // static |
| 213 string16 PolicyUIHandler::GetPolicyScopeString(policy::PolicyScope scope) { | 211 string16 PolicyUIHandler::GetPolicyScopeString(policy::PolicyScope scope) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 369 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 372 web_ui->AddMessageHandler(new PolicyUIHandler); | 370 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 373 | 371 |
| 374 // Set up the chrome://policy/ source. | 372 // Set up the chrome://policy/ source. |
| 375 Profile* profile = Profile::FromWebUI(web_ui); | 373 Profile* profile = Profile::FromWebUI(web_ui); |
| 376 ChromeURLDataManager::AddDataSource(profile, CreatePolicyUIHTMLSource()); | 374 ChromeURLDataManager::AddDataSource(profile, CreatePolicyUIHTMLSource()); |
| 377 } | 375 } |
| 378 | 376 |
| 379 PolicyUI::~PolicyUI() { | 377 PolicyUI::~PolicyUI() { |
| 380 } | 378 } |
| OLD | NEW |