Chromium Code Reviews| 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" |
| 11 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/browser_process_platform_part.h" | |
|
bartfab (slow)
2015/04/29 17:27:54
Nit: You only need this #if defined(OS_CHROMEOS)
binjin
2015/04/29 17:32:13
Done.
| |
| 19 #include "chrome/browser/policy/profile_policy_connector.h" | 20 #include "chrome/browser/policy/profile_policy_connector.h" |
| 20 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 21 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 21 #include "chrome/browser/policy/schema_registry_service.h" | 22 #include "chrome/browser/policy/schema_registry_service.h" |
| 22 #include "chrome/browser/policy/schema_registry_service_factory.h" | 23 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
| 25 #include "components/policy/core/browser/browser_policy_connector.h" | 26 #include "components/policy/core/browser/browser_policy_connector.h" |
| 26 #include "components/policy/core/browser/cloud/message_util.h" | 27 #include "components/policy/core/browser/cloud/message_util.h" |
| 27 #include "components/policy/core/browser/configuration_policy_handler_list.h" | 28 #include "components/policy/core/browser/configuration_policy_handler_list.h" |
| 28 #include "components/policy/core/browser/policy_error_map.h" | 29 #include "components/policy/core/browser/policy_error_map.h" |
| 29 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 30 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 30 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 31 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 31 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 32 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 32 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
| 33 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 34 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 35 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 35 #include "components/policy/core/common/policy_map.h" | 36 #include "components/policy/core/common/policy_map.h" |
| 36 #include "components/policy/core/common/policy_namespace.h" | 37 #include "components/policy/core/common/policy_namespace.h" |
| 37 #include "components/policy/core/common/policy_service.h" | 38 #include "components/policy/core/common/policy_service.h" |
| 38 #include "components/policy/core/common/policy_types.h" | 39 #include "components/policy/core/common/policy_types.h" |
| 40 #include "components/policy/core/common/remote_commands/remote_commands_service. h" | |
| 39 #include "components/policy/core/common/schema.h" | 41 #include "components/policy/core/common/schema.h" |
| 40 #include "components/policy/core/common/schema_map.h" | 42 #include "components/policy/core/common/schema_map.h" |
| 41 #include "components/policy/core/common/schema_registry.h" | 43 #include "components/policy/core/common/schema_registry.h" |
| 42 #include "content/public/browser/web_contents.h" | 44 #include "content/public/browser/web_contents.h" |
| 43 #include "content/public/browser/web_ui.h" | 45 #include "content/public/browser/web_ui.h" |
| 44 #include "content/public/browser/web_ui_data_source.h" | 46 #include "content/public/browser/web_ui_data_source.h" |
| 45 #include "content/public/browser/web_ui_message_handler.h" | 47 #include "content/public/browser/web_ui_message_handler.h" |
| 46 #include "google_apis/gaia/gaia_auth_util.h" | 48 #include "google_apis/gaia/gaia_auth_util.h" |
| 47 #include "grit/browser_resources.h" | 49 #include "grit/browser_resources.h" |
| 48 #include "grit/components_strings.h" | 50 #include "grit/components_strings.h" |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 web_ui()->CallJavascriptFunction("policy.Page.setStatus", status); | 802 web_ui()->CallJavascriptFunction("policy.Page.setStatus", status); |
| 801 } | 803 } |
| 802 | 804 |
| 803 void PolicyUIHandler::HandleInitialized(const base::ListValue* args) { | 805 void PolicyUIHandler::HandleInitialized(const base::ListValue* args) { |
| 804 SendPolicyNames(); | 806 SendPolicyNames(); |
| 805 SendPolicyValues(); | 807 SendPolicyValues(); |
| 806 SendStatus(); | 808 SendStatus(); |
| 807 } | 809 } |
| 808 | 810 |
| 809 void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) { | 811 void PolicyUIHandler::HandleReloadPolicies(const base::ListValue* args) { |
| 812 #if defined(OS_CHROMEOS) | |
| 813 // Allow user to manually fetch remote commands, in case invalidation | |
| 814 // service is not working properly. | |
| 815 // TODO(binjin): evaluate and possibly remove this after invalidation | |
| 816 // service is landed and tested. http://crbug.com/480982 | |
| 817 policy::BrowserPolicyConnectorChromeOS* connector = | |
| 818 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 819 connector->GetDeviceCloudPolicyManager() | |
| 820 ->core() | |
| 821 ->remote_commands_service() | |
| 822 ->FetchRemoteCommands(); | |
| 823 #endif | |
| 810 GetPolicyService()->RefreshPolicies( | 824 GetPolicyService()->RefreshPolicies( |
| 811 base::Bind(&PolicyUIHandler::OnRefreshPoliciesDone, | 825 base::Bind(&PolicyUIHandler::OnRefreshPoliciesDone, |
| 812 weak_factory_.GetWeakPtr())); | 826 weak_factory_.GetWeakPtr())); |
| 813 } | 827 } |
| 814 | 828 |
| 815 void PolicyUIHandler::OnRefreshPoliciesDone() const { | 829 void PolicyUIHandler::OnRefreshPoliciesDone() const { |
| 816 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone"); | 830 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone"); |
| 817 } | 831 } |
| 818 | 832 |
| 819 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 833 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
| 820 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 834 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
| 821 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 835 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
| 822 } | 836 } |
| 823 | 837 |
| 824 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 838 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 825 web_ui->AddMessageHandler(new PolicyUIHandler); | 839 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 826 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 840 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 827 CreatePolicyUIHTMLSource()); | 841 CreatePolicyUIHTMLSource()); |
| 828 } | 842 } |
| 829 | 843 |
| 830 PolicyUI::~PolicyUI() { | 844 PolicyUI::~PolicyUI() { |
| 831 } | 845 } |
| OLD | NEW |