| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/policy/profile_policy_connector.h" | 21 #include "chrome/browser/policy/profile_policy_connector.h" |
| 22 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 22 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 23 #include "chrome/browser/policy/schema_registry_service.h" | 23 #include "chrome/browser/policy/schema_registry_service.h" |
| 24 #include "chrome/browser/policy/schema_registry_service_factory.h" | 24 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 25 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 27 #include "components/policy/core/browser/browser_policy_connector.h" | 28 #include "components/policy/core/browser/browser_policy_connector.h" |
| 28 #include "components/policy/core/browser/cloud/message_util.h" | 29 #include "components/policy/core/browser/cloud/message_util.h" |
| 29 #include "components/policy/core/browser/configuration_policy_handler_list.h" | 30 #include "components/policy/core/browser/configuration_policy_handler_list.h" |
| 30 #include "components/policy/core/browser/policy_error_map.h" | 31 #include "components/policy/core/browser/policy_error_map.h" |
| 31 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 32 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 32 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 33 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 33 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 34 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 34 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" | 35 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" |
| 35 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 36 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT), | 97 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT), |
| 97 arraysize(kPolicySources)); | 98 arraysize(kPolicySources)); |
| 98 for (size_t i = 0; i < arraysize(kPolicySources); ++i) { | 99 for (size_t i = 0; i < arraysize(kPolicySources); ++i) { |
| 99 source->AddLocalizedString(kPolicySources[i].key, | 100 source->AddLocalizedString(kPolicySources[i].key, |
| 100 kPolicySources[i].string_id); | 101 kPolicySources[i].string_id); |
| 101 } | 102 } |
| 102 } | 103 } |
| 103 | 104 |
| 104 content::WebUIDataSource* CreatePolicyUIHTMLSource() { | 105 content::WebUIDataSource* CreatePolicyUIHTMLSource() { |
| 105 content::WebUIDataSource* source = | 106 content::WebUIDataSource* source = |
| 106 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); | 107 content::WebUIDataSource::Create(switches::MdPolicyPageEnabled() ? |
| 108 chrome::kChromeUIPolicyInternalsHost |
| 109 : chrome::kChromeUIPolicyHost); |
| 107 | 110 |
| 108 // Localized strings. | 111 // Localized strings. |
| 109 source->AddLocalizedString("title", IDS_POLICY_TITLE); | 112 source->AddLocalizedString("title", IDS_POLICY_TITLE); |
| 110 source->AddLocalizedString("filterPlaceholder", | 113 source->AddLocalizedString("filterPlaceholder", |
| 111 IDS_POLICY_FILTER_PLACEHOLDER); | 114 IDS_POLICY_FILTER_PLACEHOLDER); |
| 112 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); | 115 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); |
| 113 source->AddLocalizedString("status", IDS_POLICY_STATUS); | 116 source->AddLocalizedString("status", IDS_POLICY_STATUS); |
| 114 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); | 117 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); |
| 115 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); | 118 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); |
| 116 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); | 119 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 } | 867 } |
| 865 | 868 |
| 866 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 869 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 867 web_ui->AddMessageHandler(new PolicyUIHandler); | 870 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 868 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 871 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 869 CreatePolicyUIHTMLSource()); | 872 CreatePolicyUIHTMLSource()); |
| 870 } | 873 } |
| 871 | 874 |
| 872 PolicyUI::~PolicyUI() { | 875 PolicyUI::~PolicyUI() { |
| 873 } | 876 } |
| OLD | NEW |