blob: 02eb8c25c1cc2139379ba31c9cd6f57d862cfbf6 [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
weisert3dab3b92017-01-10 10:31:177#include "base/memory/ptr_util.h"
Anton Urusoveb2d3812017-08-24 20:01:028#include "build/build_config.h"
[email protected]a81712032011-08-31 16:10:049#include "chrome/browser/profiles/profile.h"
fhorschig07c5e0622015-12-03 16:48:5710#include "chrome/browser/ui/webui/policy_ui_handler.h"
[email protected]a81712032011-08-31 16:10:0411#include "chrome/common/url_constants.h"
thestig4a2e88e2016-08-27 23:23:5112#include "chrome/grit/browser_resources.h"
13#include "components/strings/grit/components_strings.h"
[email protected]01ec4ec2012-01-18 04:13:4714#include "content/public/browser/web_ui.h"
[email protected]8a2166d92012-12-06 23:58:4515
[email protected]a8ac9bd22012-05-02 12:30:3716namespace {
[email protected]0ec4898e2011-12-30 21:09:2417
fhorschig07c5e0622015-12-03 16:48:5718content::WebUIDataSource* CreatePolicyUIHtmlSource() {
19 content::WebUIDataSource* source =
20 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
21 PolicyUIHandler::AddCommonLocalizedStringsToSource(source);
[email protected]c79f3c272013-02-05 11:51:5322 source->AddLocalizedString("filterPlaceholder",
23 IDS_POLICY_FILTER_PLACEHOLDER);
24 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES);
Anton Urusovcd9784a2017-08-10 21:00:2125 source->AddLocalizedString("exportPoliciesJSON", IDS_EXPORT_POLICIES_JSON);
georgesakf02848b2016-10-04 14:41:0926 source->AddLocalizedString("chromeForWork", IDS_POLICY_CHROME_FOR_WORK);
[email protected]c79f3c272013-02-05 11:51:5327 source->AddLocalizedString("status", IDS_POLICY_STATUS);
28 source->AddLocalizedString("statusDevice", IDS_POLICY_STATUS_DEVICE);
29 source->AddLocalizedString("statusUser", IDS_POLICY_STATUS_USER);
Ivan Sandrk636b89d2017-07-28 10:42:5730 source->AddLocalizedString("labelEnterpriseEnrollmentDomain",
31 IDS_POLICY_LABEL_ENTERPRISE_ENROLLMENT_DOMAIN);
32 source->AddLocalizedString("labelEnterpriseDisplayDomain",
33 IDS_POLICY_LABEL_ENTERPRISE_DISPLAY_DOMAIN);
[email protected]c79f3c272013-02-05 11:51:5334 source->AddLocalizedString("labelUsername", IDS_POLICY_LABEL_USERNAME);
35 source->AddLocalizedString("labelClientId", IDS_POLICY_LABEL_CLIENT_ID);
pbond36d002d2015-04-15 11:55:4636 source->AddLocalizedString("labelAssetId", IDS_POLICY_LABEL_ASSET_ID);
37 source->AddLocalizedString("labelLocation", IDS_POLICY_LABEL_LOCATION);
38 source->AddLocalizedString("labelDirectoryApiId",
39 IDS_POLICY_LABEL_DIRECTORY_API_ID);
[email protected]c79f3c272013-02-05 11:51:5340 source->AddLocalizedString("labelTimeSinceLastRefresh",
41 IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH);
42 source->AddLocalizedString("labelRefreshInterval",
43 IDS_POLICY_LABEL_REFRESH_INTERVAL);
44 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS);
45 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET);
46 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET);
[email protected]c79f3c272013-02-05 11:51:5347 source->AddLocalizedString("showExpandedValue",
48 IDS_POLICY_SHOW_EXPANDED_VALUE);
49 source->AddLocalizedString("hideExpandedValue",
50 IDS_POLICY_HIDE_EXPANDED_VALUE);
Anton Urusov15f361a12017-09-05 19:43:2951 source->AddLocalizedString("policyLearnMore", IDS_POLICY_LEARN_MORE);
[email protected]a81712032011-08-31 16:10:0452 // Add required resources.
Anton Urusoveb2d3812017-08-24 20:01:0253#if !defined(OS_ANDROID)
54 source->AddResourcePath("policy_common.css", IDR_POLICY_COMMON_CSS);
55#endif
[email protected]3dbd64d2013-01-19 23:05:1656 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
Anton Urusoveb2d3812017-08-24 20:01:0257 source->AddResourcePath("policy_base.js", IDR_POLICY_BASE_JS);
[email protected]3dbd64d2013-01-19 23:05:1658 source->AddResourcePath("policy.js", IDR_POLICY_JS);
[email protected]3dbd64d2013-01-19 23:05:1659 source->SetDefaultResource(IDR_POLICY_HTML);
Reilly Grant775bca1d2017-11-08 01:36:5760 source->UseGzip();
[email protected]a81712032011-08-31 16:10:0461 return source;
62}
63
[email protected]8a2166d92012-12-06 23:58:4564} // namespace
65
[email protected]01ec4ec2012-01-18 04:13:4766PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
weisert3dab3b92017-01-10 10:31:1767 web_ui->AddMessageHandler(base::MakeUnique<PolicyUIHandler>());
[email protected]c79f3c272013-02-05 11:51:5368 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
fhorschigc9018a4fe2015-10-07 08:41:5069 CreatePolicyUIHtmlSource());
[email protected]a81712032011-08-31 16:10:0470}
71
72PolicyUI::~PolicyUI() {
73}