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" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 94 |
95 void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) { | 95 void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) { |
96 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT), | 96 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT), |
97 arraysize(kPolicySources)); | 97 arraysize(kPolicySources)); |
98 for (size_t i = 0; i < arraysize(kPolicySources); ++i) { | 98 for (size_t i = 0; i < arraysize(kPolicySources); ++i) { |
99 source->AddLocalizedString(kPolicySources[i].key, | 99 source->AddLocalizedString(kPolicySources[i].key, |
100 kPolicySources[i].string_id); | 100 kPolicySources[i].string_id); |
101 } | 101 } |
102 } | 102 } |
103 | 103 |
104 content::WebUIDataSource* CreatePolicyUIHTMLSource() { | 104 void AddCommonLocalizedStringsToSource(content::WebUIDataSource* source) { |
105 content::WebUIDataSource* source = | |
106 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); | |
107 | |
108 // Localized strings. | |
109 source->AddLocalizedString("title", IDS_POLICY_TITLE); | 105 source->AddLocalizedString("title", IDS_POLICY_TITLE); |
110 source->AddLocalizedString("filterPlaceholder", | 106 source->AddLocalizedString("filterPlaceholder", |
111 IDS_POLICY_FILTER_PLACEHOLDER); | 107 IDS_POLICY_FILTER_PLACEHOLDER); |
112 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); | 108 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); |
113 source->AddLocalizedString("status", IDS_POLICY_STATUS); | 109 source->AddLocalizedString("status", IDS_POLICY_STATUS); |
114 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); | 110 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE); |
115 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); | 111 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER); |
116 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); | 112 source->AddLocalizedString("labelDomain", IDS_POLICY_LABEL_DOMAIN); |
117 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); | 113 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME); |
118 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); | 114 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID); |
(...skipping 22 matching lines...) Expand all Loading... |
141 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE); | 137 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE); |
142 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED); | 138 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED); |
143 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY); | 139 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY); |
144 source->AddLocalizedString("ok", IDS_POLICY_OK); | 140 source->AddLocalizedString("ok", IDS_POLICY_OK); |
145 source->AddLocalizedString("unset", IDS_POLICY_UNSET); | 141 source->AddLocalizedString("unset", IDS_POLICY_UNSET); |
146 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); | 142 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); |
147 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); | 143 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); |
148 AddLocalizedPoilcySourceStrings(source); | 144 AddLocalizedPoilcySourceStrings(source); |
149 | 145 |
150 source->SetJsonPath("strings.js"); | 146 source->SetJsonPath("strings.js"); |
| 147 } |
151 | 148 |
| 149 content::WebUIDataSource* CreatePolicyMaterialDesignUIHtmlSource() { |
| 150 content::WebUIDataSource* source = |
| 151 content::WebUIDataSource::Create(chrome::kChromeUIMdPolicyHost); |
| 152 AddCommonLocalizedStringsToSource(source); |
| 153 source->SetDefaultResource(IDR_MD_POLICY_HTML); |
| 154 |
| 155 return source; |
| 156 } |
| 157 |
| 158 |
| 159 content::WebUIDataSource* CreatePolicyUIHtmlSource() { |
| 160 content::WebUIDataSource* source = |
| 161 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); |
| 162 AddCommonLocalizedStringsToSource(source); |
152 // Add required resources. | 163 // Add required resources. |
153 source->AddResourcePath("policy.css", IDR_POLICY_CSS); | 164 source->AddResourcePath("policy.css", IDR_POLICY_CSS); |
154 source->AddResourcePath("policy.js", IDR_POLICY_JS); | 165 source->AddResourcePath("policy.js", IDR_POLICY_JS); |
155 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); | 166 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); |
156 source->SetDefaultResource(IDR_POLICY_HTML); | 167 source->SetDefaultResource(IDR_POLICY_HTML); |
157 | 168 |
158 return source; | 169 return source; |
159 } | 170 } |
160 | 171 |
161 // Formats the association state indicated by |data|. If |data| is NULL, the | 172 // Formats the association state indicated by |data|. If |data| is NULL, the |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 } | 870 } |
860 | 871 |
861 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { | 872 policy::PolicyService* PolicyUIHandler::GetPolicyService() const { |
862 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( | 873 return policy::ProfilePolicyConnectorFactory::GetForBrowserContext( |
863 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); | 874 web_ui()->GetWebContents()->GetBrowserContext())->policy_service(); |
864 } | 875 } |
865 | 876 |
866 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 877 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
867 web_ui->AddMessageHandler(new PolicyUIHandler); | 878 web_ui->AddMessageHandler(new PolicyUIHandler); |
868 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), | 879 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
869 CreatePolicyUIHTMLSource()); | 880 CreatePolicyUIHtmlSource()); |
870 } | 881 } |
871 | 882 |
872 PolicyUI::~PolicyUI() { | 883 PolicyUI::~PolicyUI() { |
873 } | 884 } |
| 885 |
| 886 PolicyMaterialDesignUI::PolicyMaterialDesignUI(content::WebUI* web_ui) : |
| 887 WebUIController(web_ui) { |
| 888 web_ui->AddMessageHandler(new PolicyUIHandler); |
| 889 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
| 890 CreatePolicyMaterialDesignUIHtmlSource()); |
| 891 } |
| 892 |
| 893 PolicyMaterialDesignUI::~PolicyMaterialDesignUI() { |
| 894 } |
OLD | NEW |