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 18 matching lines...) Expand all Loading... |
29 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 29 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
30 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 30 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
31 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 31 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
32 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 32 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
33 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
34 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
35 #include "components/policy/core/common/policy_map.h" | 35 #include "components/policy/core/common/policy_map.h" |
36 #include "components/policy/core/common/policy_namespace.h" | 36 #include "components/policy/core/common/policy_namespace.h" |
37 #include "components/policy/core/common/policy_service.h" | 37 #include "components/policy/core/common/policy_service.h" |
38 #include "components/policy/core/common/policy_types.h" | 38 #include "components/policy/core/common/policy_types.h" |
| 39 #include "components/policy/core/common/remote_commands/remote_commands_service.
h" |
39 #include "components/policy/core/common/schema.h" | 40 #include "components/policy/core/common/schema.h" |
40 #include "components/policy/core/common/schema_map.h" | 41 #include "components/policy/core/common/schema_map.h" |
41 #include "components/policy/core/common/schema_registry.h" | 42 #include "components/policy/core/common/schema_registry.h" |
42 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
43 #include "content/public/browser/web_ui.h" | 44 #include "content/public/browser/web_ui.h" |
44 #include "content/public/browser/web_ui_data_source.h" | 45 #include "content/public/browser/web_ui_data_source.h" |
45 #include "content/public/browser/web_ui_message_handler.h" | 46 #include "content/public/browser/web_ui_message_handler.h" |
46 #include "google_apis/gaia/gaia_auth_util.h" | 47 #include "google_apis/gaia/gaia_auth_util.h" |
47 #include "grit/browser_resources.h" | 48 #include "grit/browser_resources.h" |
48 #include "grit/components_strings.h" | 49 #include "grit/components_strings.h" |
49 #include "policy/policy_constants.h" | 50 #include "policy/policy_constants.h" |
50 #include "policy/proto/device_management_backend.pb.h" | 51 #include "policy/proto/device_management_backend.pb.h" |
51 #include "ui/base/l10n/l10n_util.h" | 52 #include "ui/base/l10n/l10n_util.h" |
52 #include "ui/base/l10n/time_format.h" | 53 #include "ui/base/l10n/time_format.h" |
53 | 54 |
54 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 56 #include "chrome/browser/browser_process_platform_part.h" |
55 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 57 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
56 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" | 58 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" |
57 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 59 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
58 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 60 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
59 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 61 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
60 #include "components/user_manager/user_manager.h" | 62 #include "components/user_manager/user_manager.h" |
61 #else | 63 #else |
62 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 64 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
63 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 65 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
64 #endif | 66 #endif |
(...skipping 735 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) { |
810 GetPolicyService()->RefreshPolicies( | 812 #if defined(OS_CHROMEOS) |
811 base::Bind(&PolicyUIHandler::OnRefreshPoliciesDone, | 813 // Allow user to manually fetch remote commands, in case invalidation |
812 weak_factory_.GetWeakPtr())); | 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 policy::RemoteCommandsService* remote_commands_service = |
| 820 connector->GetDeviceCloudPolicyManager() |
| 821 ->core() |
| 822 ->remote_commands_service(); |
| 823 if (remote_commands_service) |
| 824 remote_commands_service->FetchRemoteCommands(); |
| 825 #endif |
| 826 GetPolicyService()->RefreshPolicies(base::Bind( |
| 827 &PolicyUIHandler::OnRefreshPoliciesDone, weak_factory_.GetWeakPtr())); |
813 } | 828 } |
814 | 829 |
815 void PolicyUIHandler::OnRefreshPoliciesDone() const { | 830 void PolicyUIHandler::OnRefreshPoliciesDone() const { |
816 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone"); | 831 web_ui()->CallJavascriptFunction("policy.Page.reloadPoliciesDone"); |
817 } | 832 } |
818 | 833 |
819 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 834 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
820 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 835 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
821 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 836 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
822 } | 837 } |
823 | 838 |
824 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
825 web_ui->AddMessageHandler(new PolicyUIHandler); | 840 web_ui->AddMessageHandler(new PolicyUIHandler); |
826 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
827 CreatePolicyUIHTMLSource()); | 842 CreatePolicyUIHTMLSource()); |
828 } | 843 } |
829 | 844 |
830 PolicyUI::~PolicyUI() { | 845 PolicyUI::~PolicyUI() { |
831 } | 846 } |
OLD | NEW |