[email protected] | a43c12e | 2012-03-06 21:57:10 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/ui/webui/policy_ui.h" |
| 6 | |
Jinho Bang | 7ab7a4e | 2018-01-15 14:36:07 | [diff] [blame] | 7 | #include <memory> |
| 8 | |
Anton Urusov | eb2d381 | 2017-08-24 20:01:02 | [diff] [blame] | 9 | #include "build/build_config.h" |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 10 | #include "chrome/browser/profiles/profile.h" |
fhorschig | 07c5e062 | 2015-12-03 16:48:57 | [diff] [blame] | 11 | #include "chrome/browser/ui/webui/policy_ui_handler.h" |
Lei Zhang | 6af63c26 | 2019-11-22 02:07:03 | [diff] [blame^] | 12 | #include "chrome/browser/ui/webui/webui_util.h" |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 13 | #include "chrome/common/url_constants.h" |
thestig | 4a2e88e | 2016-08-27 23:23:51 | [diff] [blame] | 14 | #include "chrome/grit/browser_resources.h" |
| 15 | #include "components/strings/grit/components_strings.h" |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 16 | #include "content/public/browser/web_ui.h" |
[email protected] | 8a2166d9 | 2012-12-06 23:58:45 | [diff] [blame] | 17 | |
[email protected] | a8ac9bd2 | 2012-05-02 12:30:37 | [diff] [blame] | 18 | namespace { |
[email protected] | 0ec4898e | 2011-12-30 21:09:24 | [diff] [blame] | 19 | |
fhorschig | 07c5e062 | 2015-12-03 16:48:57 | [diff] [blame] | 20 | content::WebUIDataSource* CreatePolicyUIHtmlSource() { |
| 21 | content::WebUIDataSource* source = |
| 22 | content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); |
| 23 | PolicyUIHandler::AddCommonLocalizedStringsToSource(source); |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 24 | |
Lei Zhang | 6af63c26 | 2019-11-22 02:07:03 | [diff] [blame^] | 25 | static constexpr webui::LocalizedString kStrings[] = { |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 26 | // Localized strings (alphabetical order). |
| 27 | {"exportPoliciesJSON", IDS_EXPORT_POLICIES_JSON}, |
| 28 | {"filterPlaceholder", IDS_POLICY_FILTER_PLACEHOLDER}, |
| 29 | {"hideExpandedStatus", IDS_POLICY_HIDE_EXPANDED_STATUS}, |
Andreea Costinas | 138eb0a | 2019-06-06 11:52:07 | [diff] [blame] | 30 | {"isAffiliatedYes", IDS_POLICY_IS_AFFILIATED_YES}, |
| 31 | {"isAffiliatedNo", IDS_POLICY_IS_AFFILIATED_NO}, |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 32 | {"labelAssetId", IDS_POLICY_LABEL_ASSET_ID}, |
| 33 | {"labelClientId", IDS_POLICY_LABEL_CLIENT_ID}, |
| 34 | {"labelDirectoryApiId", IDS_POLICY_LABEL_DIRECTORY_API_ID}, |
| 35 | {"labelEnterpriseDisplayDomain", |
| 36 | IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN}, |
| 37 | {"labelEnterpriseEnrollmentDomain", |
| 38 | IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN}, |
| 39 | {"labelGaiaId", IDS_POLICY_LABEL_GAIA_ID}, |
Andreea Costinas | 138eb0a | 2019-06-06 11:52:07 | [diff] [blame] | 40 | {"labelIsAffiliated", IDS_POLICY_LABEL_IS_AFFILIATED}, |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 41 | {"labelLocation", IDS_POLICY_LABEL_LOCATION}, |
| 42 | {"labelMachineEnrollmentDomain", |
| 43 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DOMAIN}, |
| 44 | {"labelMachineEnrollmentMachineName", |
| 45 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_MACHINE_NAME}, |
| 46 | {"labelMachineEnrollmentToken", |
| 47 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_TOKEN}, |
| 48 | {"labelMachineEntrollmentDeviceId", |
| 49 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DEVICE_ID}, |
Aya ElAttar | 5a009a9 | 2019-07-08 16:42:30 | [diff] [blame] | 50 | {"labelIsOffHoursActive", IDS_POLICY_LABEL_IS_OFFHOURS_ACTIVE}, |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 51 | {"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES}, |
| 52 | {"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL}, |
| 53 | {"labelStatus", IDS_POLICY_LABEL_STATUS}, |
| 54 | {"labelTimeSinceLastRefresh", IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH}, |
| 55 | {"labelUsername", IDS_POLICY_LABEL_USERNAME}, |
| 56 | {"noPoliciesSet", IDS_POLICY_NO_POLICIES_SET}, |
Aya ElAttar | 5a009a9 | 2019-07-08 16:42:30 | [diff] [blame] | 57 | {"offHoursActive", IDS_POLICY_OFFHOURS_ACTIVE}, |
| 58 | {"offHoursNotActive", IDS_POLICY_OFFHOURS_NOT_ACTIVE}, |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 59 | {"policiesPushOff", IDS_POLICY_PUSH_POLICIES_OFF}, |
| 60 | {"policiesPushOn", IDS_POLICY_PUSH_POLICIES_ON}, |
| 61 | {"policyLearnMore", IDS_POLICY_LEARN_MORE}, |
| 62 | {"reloadPolicies", IDS_POLICY_RELOAD_POLICIES}, |
| 63 | {"showExpandedStatus", IDS_POLICY_SHOW_EXPANDED_STATUS}, |
| 64 | {"showLess", IDS_POLICY_SHOW_LESS}, |
| 65 | {"showMore", IDS_POLICY_SHOW_MORE}, |
| 66 | {"showUnset", IDS_POLICY_SHOW_UNSET}, |
| 67 | {"status", IDS_POLICY_STATUS}, |
| 68 | {"statusDevice", IDS_POLICY_STATUS_DEVICE}, |
| 69 | {"statusMachine", IDS_POLICY_STATUS_MACHINE}, |
| 70 | {"statusUser", IDS_POLICY_STATUS_USER}, |
| 71 | }; |
Lei Zhang | b5463f1 | 2019-11-21 03:05:32 | [diff] [blame] | 72 | AddLocalizedStringsBulk(source, kStrings); |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 73 | |
[email protected] | 3dbd64d | 2013-01-19 23:05:16 | [diff] [blame] | 74 | source->AddResourcePath("policy.css", IDR_POLICY_CSS); |
Anton Urusov | eb2d381 | 2017-08-24 20:01:02 | [diff] [blame] | 75 | source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS); |
[email protected] | 3dbd64d | 2013-01-19 23:05:16 | [diff] [blame] | 76 | source->AddResourcePath("policy.js", IDR_POLICY_JS); |
| 77 | source->SetDefaultResource(IDR_POLICY_HTML); |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 78 | return source; |
| 79 | } |
| 80 | |
[email protected] | 8a2166d9 | 2012-12-06 23:58:45 | [diff] [blame] | 81 | } // namespace |
| 82 | |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 83 | PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
Jinho Bang | 7ab7a4e | 2018-01-15 14:36:07 | [diff] [blame] | 84 | web_ui->AddMessageHandler(std::make_unique<PolicyUIHandler>()); |
[email protected] | c79f3c27 | 2013-02-05 11:51:53 | [diff] [blame] | 85 | content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), |
fhorschig | c9018a4fe | 2015-10-07 08:41:50 | [diff] [blame] | 86 | CreatePolicyUIHtmlSource()); |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | PolicyUI::~PolicyUI() { |
| 90 | } |