Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 1 | |
Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 2 | // Copyright 2012 The Chromium Authors |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | |
dpapad | 538e016 | 2020-12-17 23:06:23 | [diff] [blame] | 6 | #include "chrome/browser/ui/webui/policy/policy_ui.h" |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 7 | |
Jinho Bang | 7ab7a4e | 2018-01-15 14:36:07 | [diff] [blame] | 8 | #include <memory> |
| 9 | |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 10 | #include "base/json/json_writer.h" |
| 11 | #include "base/strings/stringprintf.h" |
| 12 | #include "base/system/sys_info.h" |
Anton Urusov | eb2d381 | 2017-08-24 20:01:02 | [diff] [blame] | 13 | #include "build/build_config.h" |
Owen Min | a4157615 | 2022-10-20 23:27:37 | [diff] [blame] | 14 | #include "build/chromeos_buildflags.h" |
Elena Scobici | 1d50eea3 | 2023-07-17 20:32:06 | [diff] [blame^] | 15 | #include "chrome/browser/enterprise/browser_management/management_service_factory.h" |
Elena Scobici | 518d19c | 2023-06-28 15:01:38 | [diff] [blame] | 16 | #include "chrome/browser/policy/value_provider/chrome_policies_value_provider.h" |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 17 | #include "chrome/browser/profiles/profile.h" |
dpapad | 538e016 | 2020-12-17 23:06:23 | [diff] [blame] | 18 | #include "chrome/browser/ui/webui/policy/policy_ui_handler.h" |
Lei Zhang | 6af63c26 | 2019-11-22 02:07:03 | [diff] [blame] | 19 | #include "chrome/browser/ui/webui/webui_util.h" |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 20 | #include "chrome/common/url_constants.h" |
Salma Elmahallawy | a44f044 | 2023-01-26 22:00:15 | [diff] [blame] | 21 | #include "chrome/grit/chromium_strings.h" |
dpapad | 5a98fb2 | 2023-01-12 18:51:34 | [diff] [blame] | 22 | #include "components/grit/policy_resources.h" |
| 23 | #include "components/grit/policy_resources_map.h" |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 24 | #include "components/policy/core/common/features.h" |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 25 | #include "components/policy/core/common/policy_logger.h" |
Jayee | 07bb468c | 2023-06-01 18:25:31 | [diff] [blame] | 26 | #include "components/policy/core/common/policy_pref_names.h" |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 27 | #include "components/policy/core/common/policy_utils.h" |
Jayee | 07bb468c | 2023-06-01 18:25:31 | [diff] [blame] | 28 | #include "components/prefs/pref_registry_simple.h" |
thestig | 4a2e88e | 2016-08-27 23:23:51 | [diff] [blame] | 29 | #include "components/strings/grit/components_strings.h" |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 30 | #include "components/version_info/version_info.h" |
| 31 | #include "components/version_ui/version_handler_helper.h" |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 32 | #include "content/public/browser/web_ui.h" |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 33 | #include "content/public/browser/web_ui_controller.h" |
| 34 | #include "content/public/browser/web_ui_message_handler.h" |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 35 | #include "content/public/common/user_agent.h" |
Rebekah Potter | f6b2f26 | 2022-05-27 21:43:19 | [diff] [blame] | 36 | #include "services/network/public/mojom/content_security_policy.mojom.h" |
Rohit Rao | e38fb48 | 2020-01-19 21:35:14 | [diff] [blame] | 37 | #include "ui/base/webui/web_ui_util.h" |
[email protected] | 8a2166d9 | 2012-12-06 23:58:45 | [diff] [blame] | 38 | |
[email protected] | a8ac9bd2 | 2012-05-02 12:30:37 | [diff] [blame] | 39 | namespace { |
David Jean | 93315a8f9 | 2023-06-16 08:03:22 | [diff] [blame] | 40 | |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 41 | // Returns the operating system information to be displayed on |
| 42 | // chrome://policy/logs page. |
| 43 | std::string GetOsInfo() { |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 44 | #if BUILDFLAG(IS_ANDROID) |
| 45 | // The base format for the OS version and build. |
Salma Elmahallawy | a44f044 | 2023-01-26 22:00:15 | [diff] [blame] | 46 | constexpr char kOSVersionAndBuildFormat[] = "Android %s %s"; |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 47 | return base::StringPrintf( |
| 48 | kOSVersionAndBuildFormat, |
Salma Elmahallawy | a44f044 | 2023-01-26 22:00:15 | [diff] [blame] | 49 | (base::SysInfo::OperatingSystemVersion()).c_str(), |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 50 | (content::GetAndroidOSInfo(content::IncludeAndroidBuildNumber::Include, |
| 51 | content::IncludeAndroidModel::Include)) |
Salma Elmahallawy | a44f044 | 2023-01-26 22:00:15 | [diff] [blame] | 52 | .c_str()); |
Salma Elmahallawy | a78c7673 | 2023-06-29 15:39:40 | [diff] [blame] | 53 | #else |
| 54 | return base::StringPrintf("%s %s", |
| 55 | base::SysInfo::OperatingSystemName().c_str(), |
| 56 | base::SysInfo::OperatingSystemVersion().c_str()); |
| 57 | #endif // BUILDFLAG (IS_ANDROID) |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | // Returns the version information to be displayed on the chrome://policy/logs |
| 61 | // page. |
Roman Sorokin | 9f655dca | 2023-02-01 14:09:32 | [diff] [blame] | 62 | base::Value::Dict GetVersionInfo() { |
| 63 | base::Value::Dict version_info; |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 64 | |
Roman Sorokin | 9f655dca | 2023-02-01 14:09:32 | [diff] [blame] | 65 | version_info.Set("revision", version_info::GetLastChange()); |
| 66 | version_info.Set("version", version_info::GetVersionNumber()); |
| 67 | version_info.Set("deviceOs", GetOsInfo()); |
| 68 | version_info.Set("variations", version_ui::GetVariationsList()); |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 69 | |
| 70 | return version_info; |
| 71 | } |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 72 | |
Rebekah Potter | 463261e | 2022-12-20 20:49:01 | [diff] [blame] | 73 | void CreateAndAddPolicyUIHtmlSource(Profile* profile) { |
| 74 | content::WebUIDataSource* source = content::WebUIDataSource::CreateAndAdd( |
| 75 | profile, chrome::kChromeUIPolicyHost); |
fhorschig | 07c5e062 | 2015-12-03 16:48:57 | [diff] [blame] | 76 | PolicyUIHandler::AddCommonLocalizedStringsToSource(source); |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 77 | |
Lei Zhang | 6af63c26 | 2019-11-22 02:07:03 | [diff] [blame] | 78 | static constexpr webui::LocalizedString kStrings[] = { |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 79 | // Localized strings (alphabetical order). |
Jérôme Gingras | 4b90f6fc | 2020-05-28 18:48:57 | [diff] [blame] | 80 | {"copyPoliciesJSON", IDS_COPY_POLICIES_JSON}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 81 | {"exportPoliciesJSON", IDS_EXPORT_POLICIES_JSON}, |
| 82 | {"filterPlaceholder", IDS_POLICY_FILTER_PLACEHOLDER}, |
| 83 | {"hideExpandedStatus", IDS_POLICY_HIDE_EXPANDED_STATUS}, |
| 84 | {"isAffiliatedYes", IDS_POLICY_IS_AFFILIATED_YES}, |
| 85 | {"isAffiliatedNo", IDS_POLICY_IS_AFFILIATED_NO}, |
| 86 | {"labelAssetId", IDS_POLICY_LABEL_ASSET_ID}, |
| 87 | {"labelClientId", IDS_POLICY_LABEL_CLIENT_ID}, |
| 88 | {"labelDirectoryApiId", IDS_POLICY_LABEL_DIRECTORY_API_ID}, |
Prateek R. Patil | eb8c8a2b | 2022-11-16 18:29:22 | [diff] [blame] | 89 | {"labelError", IDS_POLICY_LABEL_ERROR}, |
Yann Dago | 4937e13 | 2023-01-23 14:19:26 | [diff] [blame] | 90 | {"labelWarning", IDS_POLICY_HEADER_WARNING}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 91 | {"labelGaiaId", IDS_POLICY_LABEL_GAIA_ID}, |
| 92 | {"labelIsAffiliated", IDS_POLICY_LABEL_IS_AFFILIATED}, |
Owen Min | a4157615 | 2022-10-20 23:27:37 | [diff] [blame] | 93 | {"labelLastCloudReportSentTimestamp", |
| 94 | IDS_POLICY_LABEL_LAST_CLOUD_REPORT_SENT_TIMESTAMP}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 95 | {"labelLocation", IDS_POLICY_LABEL_LOCATION}, |
| 96 | {"labelMachineEnrollmentDomain", |
| 97 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DOMAIN}, |
| 98 | {"labelMachineEnrollmentMachineName", |
| 99 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_MACHINE_NAME}, |
| 100 | {"labelMachineEnrollmentToken", IDS_POLICY_LABEL_MACHINE_ENROLLMENT_TOKEN}, |
| 101 | {"labelMachineEntrollmentDeviceId", |
| 102 | IDS_POLICY_LABEL_MACHINE_ENROLLMENT_DEVICE_ID}, |
| 103 | {"labelIsOffHoursActive", IDS_POLICY_LABEL_IS_OFFHOURS_ACTIVE}, |
| 104 | {"labelPoliciesPush", IDS_POLICY_LABEL_PUSH_POLICIES}, |
Igor Ruvinov | 129ad8c | 2021-11-05 19:35:40 | [diff] [blame] | 105 | {"labelPrecedence", IDS_POLICY_LABEL_PRECEDENCE}, |
hmare | 6f303e43e | 2022-11-17 19:43:46 | [diff] [blame] | 106 | {"labelProfileId", IDS_POLICY_LABEL_PROFILE_ID}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 107 | {"labelRefreshInterval", IDS_POLICY_LABEL_REFRESH_INTERVAL}, |
| 108 | {"labelStatus", IDS_POLICY_LABEL_STATUS}, |
Sergiy Belozorov | ff0a940 | 2022-03-08 17:58:24 | [diff] [blame] | 109 | {"labelTimeSinceLastFetchAttempt", |
| 110 | IDS_POLICY_LABEL_TIME_SINCE_LAST_FETCH_ATTEMPT}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 111 | {"labelTimeSinceLastRefresh", IDS_POLICY_LABEL_TIME_SINCE_LAST_REFRESH}, |
| 112 | {"labelUsername", IDS_POLICY_LABEL_USERNAME}, |
Jana Grill | 81c20295 | 2021-02-08 11:57:38 | [diff] [blame] | 113 | {"labelManagedBy", IDS_POLICY_LABEL_MANAGED_BY}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 114 | {"labelVersion", IDS_POLICY_LABEL_VERSION}, |
| 115 | {"noPoliciesSet", IDS_POLICY_NO_POLICIES_SET}, |
| 116 | {"offHoursActive", IDS_POLICY_OFFHOURS_ACTIVE}, |
| 117 | {"offHoursNotActive", IDS_POLICY_OFFHOURS_NOT_ACTIVE}, |
Jérôme Gingras | 272c1f7d | 2020-05-27 16:35:50 | [diff] [blame] | 118 | {"policyCopyValue", IDS_POLICY_COPY_VALUE}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 119 | {"policiesPushOff", IDS_POLICY_PUSH_POLICIES_OFF}, |
| 120 | {"policiesPushOn", IDS_POLICY_PUSH_POLICIES_ON}, |
| 121 | {"policyLearnMore", IDS_POLICY_LEARN_MORE}, |
| 122 | {"reloadPolicies", IDS_POLICY_RELOAD_POLICIES}, |
| 123 | {"showExpandedStatus", IDS_POLICY_SHOW_EXPANDED_STATUS}, |
| 124 | {"showLess", IDS_POLICY_SHOW_LESS}, |
| 125 | {"showMore", IDS_POLICY_SHOW_MORE}, |
| 126 | {"showUnset", IDS_POLICY_SHOW_UNSET}, |
| 127 | {"signinProfile", IDS_POLICY_SIGNIN_PROFILE}, |
| 128 | {"status", IDS_POLICY_STATUS}, |
Prateek R. Patil | eb8c8a2b | 2022-11-16 18:29:22 | [diff] [blame] | 129 | {"statusErrorManagedNoPolicy", IDS_POLICY_STATUS_ERROR_MANAGED_NO_POLICY}, |
Yann Dago | 4937e13 | 2023-01-23 14:19:26 | [diff] [blame] | 130 | {"statusFlexOrgNoPolicy", IDS_POLICY_STATUS_FLEX_ORG_NO_POLICY}, |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 131 | {"statusDevice", IDS_POLICY_STATUS_DEVICE}, |
| 132 | {"statusMachine", IDS_POLICY_STATUS_MACHINE}, |
Xiaohan Wang | e9439fd | 2022-01-18 21:00:31 | [diff] [blame] | 133 | #if BUILDFLAG(IS_WIN) && BUILDFLAG(GOOGLE_CHROME_BRANDING) |
Yann Dago | 7a25b6f | 2020-05-14 01:09:24 | [diff] [blame] | 134 | {"statusUpdater", IDS_POLICY_STATUS_UPDATER}, |
| 135 | #endif |
| 136 | {"statusUser", IDS_POLICY_STATUS_USER}, |
Owen Min | a4157615 | 2022-10-20 23:27:37 | [diff] [blame] | 137 | #if !BUILDFLAG(IS_CHROMEOS) |
| 138 | {"uploadReport", IDS_UPLOAD_REPORT}, |
| 139 | #endif // !BUILDFLAG(IS_CHROMEOS) |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 140 | }; |
dpapad | f61285c | 2021-02-09 21:56:39 | [diff] [blame] | 141 | source->AddLocalizedStrings(kStrings); |
Henrique Limas | bc7b1ba | 2019-05-22 22:35:55 | [diff] [blame] | 142 | |
Salma Elmahallawy | a44f044 | 2023-01-26 22:00:15 | [diff] [blame] | 143 | // Localized strings for chrome://policy/logs. |
| 144 | static constexpr webui::LocalizedString kPolicyLogsStrings[] = { |
| 145 | {"browserName", IDS_PRODUCT_NAME}, |
| 146 | {"exportLogsJSON", IDS_EXPORT_POLICY_LOGS_JSON}, |
| 147 | {"logsTitle", IDS_POLICY_LOGS_TITLE}, |
| 148 | {"os", IDS_VERSION_UI_OS}, |
| 149 | {"refreshLogs", IDS_REFRESH_POLICY_LOGS}, |
| 150 | {"revision", IDS_VERSION_UI_REVISION}, |
| 151 | {"versionInfoLabel", IDS_VERSION_INFO}, |
| 152 | {"variations", IDS_VERSION_UI_VARIATIONS}, |
| 153 | }; |
| 154 | source->AddLocalizedStrings(kPolicyLogsStrings); |
| 155 | |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 156 | source->AddBoolean( |
| 157 | "loggingEnabled", |
| 158 | policy::PolicyLogger::GetInstance()->IsPolicyLoggingEnabled()); |
| 159 | |
| 160 | if (policy::PolicyLogger::GetInstance()->IsPolicyLoggingEnabled()) { |
| 161 | std::string variations_json_value; |
| 162 | base::JSONWriter::Write(GetVersionInfo(), &variations_json_value); |
| 163 | |
| 164 | source->AddString("versionInfo", variations_json_value); |
| 165 | } |
| 166 | |
| 167 | source->AddResourcePath("logs/", IDR_POLICY_LOGS_POLICY_LOGS_HTML); |
| 168 | source->AddResourcePath("logs", IDR_POLICY_LOGS_POLICY_LOGS_HTML); |
Salma Elmahallawy | 0d7b1c4 | 2023-01-24 01:03:51 | [diff] [blame] | 169 | |
Elena Scobici | 1d50eea3 | 2023-07-17 20:32:06 | [diff] [blame^] | 170 | // Test page should only load if testing is enabled and the profile is not |
| 171 | // managed by cloud. |
| 172 | if (policy::utils::IsPolicyTestingEnabled(profile->GetPrefs()) && |
| 173 | !policy::ManagementServiceFactory::GetForProfile(profile) |
| 174 | ->HasManagementAuthority( |
| 175 | policy::EnterpriseManagementAuthority::CLOUD)) { |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 176 | // Localized strings for chrome://policy/test. |
| 177 | static constexpr webui::LocalizedString kPolicyTestStrings[] = { |
| 178 | {"testTitle", IDS_POLICY_TEST_TITLE}, |
Elena Scobici | 518d19c | 2023-06-28 15:01:38 | [diff] [blame] | 179 | {"testRestart", IDS_POLICY_REBOOT_BUTTON}, |
| 180 | {"testApply", IDS_POLICY_TEST_APPLY}, |
| 181 | {"testImport", IDS_POLICY_TEST_IMPORT}, |
| 182 | {"testDesc", IDS_POLICY_TEST_DESC}, |
Elena Scobici | 3f4dc66 | 2023-07-17 20:27:29 | [diff] [blame] | 183 | {"testRevertAppliedPolicies", IDS_POLICY_TEST_REVERT}, |
| 184 | {"testClearPolicies", IDS_CLEAR}, |
Elena Scobici | 518d19c | 2023-06-28 15:01:38 | [diff] [blame] | 185 | {"testTableName", IDS_POLICY_HEADER_NAME}, |
| 186 | {"testTableSource", IDS_POLICY_HEADER_SOURCE}, |
| 187 | {"testTableTarget", IDS_POLICY_TEST_TABLE_TARGET}, |
| 188 | {"testTableLevel", IDS_POLICY_HEADER_LEVEL}, |
| 189 | {"testTableValue", IDS_POLICY_LABEL_VALUE}, |
| 190 | {"testTableRemove", IDS_REMOVE}, |
| 191 | {"testAdd", IDS_POLICY_TEST_ADD}, |
| 192 | {"testNameSelect", IDS_POLICY_SELECT_NAME}, |
| 193 | {"testSourceSelect", IDS_POLICY_SELECT_SOURCE}, |
| 194 | {"testTargetSelect", IDS_POLICY_SELECT_TARGET}, |
| 195 | {"testLevelSelect", IDS_POLICY_SELECT_LEVEL}, |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 196 | }; |
Elena Scobici | 518d19c | 2023-06-28 15:01:38 | [diff] [blame] | 197 | |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 198 | source->AddLocalizedStrings(kPolicyTestStrings); |
| 199 | source->AddResourcePath("test/", IDR_POLICY_TEST_POLICY_TEST_HTML); |
| 200 | source->AddResourcePath("test", IDR_POLICY_TEST_POLICY_TEST_HTML); |
Elena Scobici | 518d19c | 2023-06-28 15:01:38 | [diff] [blame] | 201 | |
| 202 | // Create a string policy_name_str of comma-separated policy names |
| 203 | ChromePoliciesValueProvider value_provider(profile); |
| 204 | base::Value::List policy_names = |
| 205 | (*value_provider.GetNames().FindDict("chrome")) |
| 206 | .FindList("policyNames") |
| 207 | ->Clone(); |
| 208 | std::string policy_name_str = ""; |
| 209 | for (auto& policy_name : policy_names) { |
| 210 | policy_name_str += policy_name.GetString() + ","; |
| 211 | } |
| 212 | policy_name_str.pop_back(); // remove last divider |
| 213 | source->AddString("policyNames", policy_name_str); |
| 214 | |
| 215 | // Strings for policy levels, scopes and sources |
| 216 | static constexpr webui::LocalizedString kPolicyTestTypes[] = { |
| 217 | {"scopeUser", IDS_POLICY_SCOPE_USER}, |
| 218 | {"scopeAllUsers", IDS_POLICY_SCOPE_ALL_USERS}, |
| 219 | {"scopeDevice", IDS_POLICY_SCOPE_DEVICE}, |
| 220 | {"levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED}, |
| 221 | {"levelMandatory", IDS_POLICY_LEVEL_MANDATORY}, |
| 222 | {"sourceEnterpriseDefault", IDS_POLICY_SOURCE_ENTERPRISE_DEFAULT}, |
| 223 | {"sourceDefault", IDS_POLICY_SOURCE_DEFAULT}, |
| 224 | {"sourceCommandLine", IDS_POLICY_SOURCE_COMMAND_LINE}, |
| 225 | {"sourceCloud", IDS_POLICY_SOURCE_CLOUD}, |
| 226 | {"sourceMerged", IDS_POLICY_SOURCE_MERGED}, |
| 227 | {"sourceCloudFromAsh", IDS_POLICY_SOURCE_CLOUD_FROM_ASH}, |
| 228 | {"sourceRestrictedManagedGuestSessionOverride", |
| 229 | IDS_POLICY_SOURCE_RESTRICTED_MANAGED_GUEST_SESSION_OVERRIDE}, |
| 230 | {"sourceActiveDirectory", IDS_POLICY_SOURCE_ACTIVE_DIRECTORY}, |
| 231 | {"sourcePlatform", IDS_POLICY_SOURCE_PLATFORM}, |
| 232 | {"sourceDeviceLocalAccountOverride", |
| 233 | IDS_POLICY_SOURCE_DEVICE_LOCAL_ACCOUNT_OVERRIDE}, |
| 234 | }; |
| 235 | |
| 236 | source->AddLocalizedStrings(kPolicyTestTypes); |
Elena Scobici | db1e74e | 2023-06-08 22:52:24 | [diff] [blame] | 237 | } |
| 238 | |
dpapad | 5a98fb2 | 2023-01-12 18:51:34 | [diff] [blame] | 239 | webui::SetupWebUIDataSource( |
| 240 | source, base::make_span(kPolicyResources, kPolicyResourcesSize), |
| 241 | IDR_POLICY_POLICY_HTML); |
Rebekah Potter | f6b2f26 | 2022-05-27 21:43:19 | [diff] [blame] | 242 | |
Yann Dago | 4937e13 | 2023-01-23 14:19:26 | [diff] [blame] | 243 | webui::EnableTrustedTypesCSP(source); |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | 8a2166d9 | 2012-12-06 23:58:45 | [diff] [blame] | 246 | } // namespace |
| 247 | |
[email protected] | 01ec4ec | 2012-01-18 04:13:47 | [diff] [blame] | 248 | PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
Jinho Bang | 7ab7a4e | 2018-01-15 14:36:07 | [diff] [blame] | 249 | web_ui->AddMessageHandler(std::make_unique<PolicyUIHandler>()); |
Rebekah Potter | 463261e | 2022-12-20 20:49:01 | [diff] [blame] | 250 | CreateAndAddPolicyUIHtmlSource(Profile::FromWebUI(web_ui)); |
[email protected] | a8171203 | 2011-08-31 16:10:04 | [diff] [blame] | 251 | } |
| 252 | |
Jérôme Gingras | 272c1f7d | 2020-05-27 16:35:50 | [diff] [blame] | 253 | PolicyUI::~PolicyUI() = default; |
Jayee | 07bb468c | 2023-06-01 18:25:31 | [diff] [blame] | 254 | |
| 255 | // static |
| 256 | void PolicyUI::RegisterProfilePrefs(PrefRegistrySimple* registry) { |
| 257 | registry->RegisterBooleanPref(policy::policy_prefs::kPolicyTestPageEnabled, |
| 258 | true); |
| 259 | } |