blob: d06ccd10656b4db5394059961dc43b7f6376ab23 [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
5#include "chrome/browser/ui/webui/policy_ui.h"
6
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"
Henrique Limasbc7b1ba2019-05-22 22:35:5511#include "chrome/browser/ui/webui/localized_string.h"
fhorschig07c5e0622015-12-03 16:48:5712#include "chrome/browser/ui/webui/policy_ui_handler.h"
[email protected]a81712032011-08-31 16:10:0413#include "chrome/common/url_constants.h"
thestig4a2e88e2016-08-27 23:23:5114#include "chrome/grit/browser_resources.h"
15#include "components/strings/grit/components_strings.h"
[email protected]01ec4ec2012-01-18 04:13:4716#include "content/public/browser/web_ui.h"
[email protected]8a2166d92012-12-06 23:58:4517
[email protected]a8ac9bd22012-05-02 12:30:3718namespace {
[email protected]0ec4898e2011-12-30 21:09:2419
fhorschig07c5e0622015-12-03 16:48:5720content::WebUIDataSource* CreatePolicyUIHtmlSource() {
21 content::WebUIDataSource* source =
22 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
23 PolicyUIHandler::AddCommonLocalizedStringsToSource(source);
Henrique Limasbc7b1ba2019-05-22 22:35:5524
25 static constexpr LocalizedString kStrings[] = {
26 // Localized strings (alphabetical order).
27 {"exportPoliciesJSON", IDS_EXPORT_POLICIES_JSON},
28 {"filterPlaceholder", IDS_POLICY_FILTER_PLACEHOLDER},
29 {"hideExpandedStatus", IDS_POLICY_HIDE_EXPANDED_STATUS},
30 {"labelAssetId", IDS_POLICY_LABEL_ASSET_ID},
31 {"labelClientId", IDS_POLICY_LABEL_CLIENT_ID},
32 {"labelDirectoryApiId", IDS_POLICY_LABEL_DIRECTORY_API_ID},
33 {"labelEnterpriseDisplayDomain",
34 IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN},
35 {"labelEnterpriseEnrollmentDomain",
36 IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN},
37 {"labelGaiaId", IDS_POLICY_LABEL_GAIA_ID},
38 {"labelLocation", IDS_POLICY_LABEL_LOCATION},
39 {"labelMachineEnrollmentDomain",
40 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DOMAIN},
41 {"labelMachineEnrollmentMachineName",
42 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_MACHINE_NAME},
43 {"labelMachineEnrollmentToken",
44 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_TOKEN},
45 {"labelMachineEntrollmentDeviceId",
46 IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DEVICE_ID},
47 {"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES},
48 {"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL},
49 {"labelStatus", IDS_POLICY_LABEL_STATUS},
50 {"labelTimeSinceLastRefresh", IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH},
51 {"labelUsername", IDS_POLICY_LABEL_USERNAME},
52 {"noPoliciesSet", IDS_POLICY_NO_POLICIES_SET},
53 {"policiesPushOff", IDS_POLICY_PUSH_POLICIES_OFF},
54 {"policiesPushOn", IDS_POLICY_PUSH_POLICIES_ON},
55 {"policyLearnMore", IDS_POLICY_LEARN_MORE},
56 {"reloadPolicies", IDS_POLICY_RELOAD_POLICIES},
57 {"showExpandedStatus", IDS_POLICY_SHOW_EXPANDED_STATUS},
58 {"showLess", IDS_POLICY_SHOW_LESS},
59 {"showMore", IDS_POLICY_SHOW_MORE},
60 {"showUnset", IDS_POLICY_SHOW_UNSET},
61 {"status", IDS_POLICY_STATUS},
62 {"statusDevice", IDS_POLICY_STATUS_DEVICE},
63 {"statusMachine", IDS_POLICY_STATUS_MACHINE},
64 {"statusUser", IDS_POLICY_STATUS_USER},
65 };
66 AddLocalizedStringsBulk(source, kStrings, base::size(kStrings));
67
[email protected]3dbd64d2013-01-19 23:05:1668 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
Anton Urusoveb2d3812017-08-24 20:01:0269 source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS);
[email protected]3dbd64d2013-01-19 23:05:1670 source->AddResourcePath("policy.js", IDR_POLICY_JS);
71 source->SetDefaultResource(IDR_POLICY_HTML);
[email protected]a81712032011-08-31 16:10:0472 return source;
73}
74
[email protected]8a2166d92012-12-06 23:58:4575} // namespace
76
[email protected]01ec4ec2012-01-18 04:13:4777PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Jinho Bang7ab7a4e2018-01-15 14:36:0778 web_ui->AddMessageHandler(std::make_unique<PolicyUIHandler>());
[email protected]c79f3c272013-02-05 11:51:5379 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
fhorschigc9018a4fe2015-10-07 08:41:5080 CreatePolicyUIHtmlSource());
[email protected]a81712032011-08-31 16:10:0481}
82
83PolicyUI::~PolicyUI() {
84}