blob: d487c6cc708a9b099b87f8af40c62354516af774 [file] [log] [blame]
[email protected]a43c12e2012-03-06 21:57:101// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]a81712032011-08-31 16:10:042// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
dpapad538e0162020-12-17 23:06:235#include "chrome/browser/ui/webui/policy/policy_ui.h"
[email protected]a81712032011-08-31 16:10:046
Jinho Bang7ab7a4e2018-01-15 14:36:077#include <memory>
8
Anton Urusoveb2d3812017-08-24 20:01:029#include "build/build_config.h"
[email protected]a81712032011-08-31 16:10:0410#include "chrome/browser/profiles/profile.h"
dpapad538e0162020-12-17 23:06:2311#include "chrome/browser/ui/webui/policy/policy_ui_handler.h"
Lei Zhang6af63c262019-11-22 02:07:0312#include "chrome/browser/ui/webui/webui_util.h"
[email protected]a81712032011-08-31 16:10:0413#include "chrome/common/url_constants.h"
Samuel Huang1b99a062020-01-08 22:20:3414#include "components/grit/dev_ui_components_resources.h"
thestig4a2e88e2016-08-27 23:23:5115#include "components/strings/grit/components_strings.h"
[email protected]01ec4ec2012-01-18 04:13:4716#include "content/public/browser/web_ui.h"
Rohit Raoe38fb482020-01-19 21:35:1417#include "ui/base/webui/web_ui_util.h"
[email protected]8a2166d92012-12-06 23:58:4518
[email protected]a8ac9bd22012-05-02 12:30:3719namespace {
[email protected]0ec4898e2011-12-30 21:09:2420
fhorschig07c5e0622015-12-03 16:48:5721content::WebUIDataSource* CreatePolicyUIHtmlSource() {
22 content::WebUIDataSource* source =
23 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
24 PolicyUIHandler::AddCommonLocalizedStringsToSource(source);
Henrique Limasbc7b1ba2019-05-22 22:35:5525
Lei Zhang6af63c262019-11-22 02:07:0326 static constexpr webui::LocalizedString kStrings[] = {
Yann Dago7a25b6f2020-05-14 01:09:2427 // Localized strings (alphabetical order).
Jérôme Gingras4b90f6fc2020-05-28 18:48:5728 {"copyPoliciesJSON", IDS_COPY_POLICIES_JSON},
Yann Dago7a25b6f2020-05-14 01:09:2429 {"exportPoliciesJSON", IDS_EXPORT_POLICIES_JSON},
30 {"filterPlaceholder", IDS_POLICY_FILTER_PLACEHOLDER},
31 {"hideExpandedStatus", IDS_POLICY_HIDE_EXPANDED_STATUS},
32 {"isAffiliatedYes", IDS_POLICY_IS_AFFILIATED_YES},
33 {"isAffiliatedNo", IDS_POLICY_IS_AFFILIATED_NO},
34 {"labelAssetId", IDS_POLICY_LABEL_ASSET_ID},
35 {"labelClientId", IDS_POLICY_LABEL_CLIENT_ID},
36 {"labelDirectoryApiId", IDS_POLICY_LABEL_DIRECTORY_API_ID},
37 {"labelEnterpriseDisplayDomain",
38 IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN},
39 {"labelEnterpriseEnrollmentDomain",
40 IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN},
41 {"labelGaiaId", IDS_POLICY_LABEL_GAIA_ID},
42 {"labelIsAffiliated", IDS_POLICY_LABEL_IS_AFFILIATED},
43 {"labelLocation", IDS_POLICY_LABEL_LOCATION},
44 {"labelMachineEnrollmentDomain",
45 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DOMAIN},
46 {"labelMachineEnrollmentMachineName",
47 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_MACHINE_NAME},
48 {"labelMachineEnrollmentToken", IDS_POLICY_LABEL_MACHINE_ENROLLMENT_TOKEN},
49 {"labelMachineEntrollmentDeviceId",
50 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DEVICE_ID},
51 {"labelIsOffHoursActive", IDS_POLICY_LABEL_IS_OFFHOURS_ACTIVE},
52 {"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES},
53 {"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL},
54 {"labelStatus", IDS_POLICY_LABEL_STATUS},
55 {"labelTimeSinceLastRefresh", IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH},
56 {"labelUsername", IDS_POLICY_LABEL_USERNAME},
57 {"labelVersion", IDS_POLICY_LABEL_VERSION},
58 {"noPoliciesSet", IDS_POLICY_NO_POLICIES_SET},
59 {"offHoursActive", IDS_POLICY_OFFHOURS_ACTIVE},
60 {"offHoursNotActive", IDS_POLICY_OFFHOURS_NOT_ACTIVE},
Jérôme Gingras272c1f7d2020-05-27 16:35:5061 {"policyCopyValue", IDS_POLICY_COPY_VALUE},
Yann Dago7a25b6f2020-05-14 01:09:2462 {"policiesPushOff", IDS_POLICY_PUSH_POLICIES_OFF},
63 {"policiesPushOn", IDS_POLICY_PUSH_POLICIES_ON},
64 {"policyLearnMore", IDS_POLICY_LEARN_MORE},
65 {"reloadPolicies", IDS_POLICY_RELOAD_POLICIES},
66 {"showExpandedStatus", IDS_POLICY_SHOW_EXPANDED_STATUS},
67 {"showLess", IDS_POLICY_SHOW_LESS},
68 {"showMore", IDS_POLICY_SHOW_MORE},
69 {"showUnset", IDS_POLICY_SHOW_UNSET},
70 {"signinProfile", IDS_POLICY_SIGNIN_PROFILE},
71 {"status", IDS_POLICY_STATUS},
72 {"statusDevice", IDS_POLICY_STATUS_DEVICE},
73 {"statusMachine", IDS_POLICY_STATUS_MACHINE},
74#if defined(OS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING)
75 {"statusUpdater", IDS_POLICY_STATUS_UPDATER},
76#endif
77 {"statusUser", IDS_POLICY_STATUS_USER},
Henrique Limasbc7b1ba2019-05-22 22:35:5578 };
Lei Zhangb5463f12019-11-21 03:05:3279 AddLocalizedStringsBulk(source, kStrings);
Henrique Limasbc7b1ba2019-05-22 22:35:5580
[email protected]3dbd64d2013-01-19 23:05:1681 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
Anton Urusoveb2d3812017-08-24 20:01:0282 source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS);
[email protected]3dbd64d2013-01-19 23:05:1683 source->AddResourcePath("policy.js", IDR_POLICY_JS);
84 source->SetDefaultResource(IDR_POLICY_HTML);
[email protected]a81712032011-08-31 16:10:0485 return source;
86}
87
[email protected]8a2166d92012-12-06 23:58:4588} // namespace
89
[email protected]01ec4ec2012-01-18 04:13:4790PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Jinho Bang7ab7a4e2018-01-15 14:36:0791 web_ui->AddMessageHandler(std::make_unique<PolicyUIHandler>());
[email protected]c79f3c272013-02-05 11:51:5392 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
fhorschigc9018a4fe2015-10-07 08:41:5093 CreatePolicyUIHtmlSource());
[email protected]a81712032011-08-31 16:10:0494}
95
Jérôme Gingras272c1f7d2020-05-27 16:35:5096PolicyUI::~PolicyUI() = default;