Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Unified Diff: chrome/browser/ui/webui/policy_ui.cc

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/policy.js ('k') | chrome/browser/ui/webui/policy_ui_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/policy_ui.cc
diff --git a/chrome/browser/ui/webui/policy_ui.cc b/chrome/browser/ui/webui/policy_ui.cc
index 03d43485804641fe4dced0da2ec12c88bcb51905..8cfcaa0bbb6c2693d581b7e59df4011593f95bae 100644
--- a/chrome/browser/ui/webui/policy_ui.cc
+++ b/chrome/browser/ui/webui/policy_ui.cc
@@ -77,6 +77,27 @@ namespace em = enterprise_management;
namespace {
+struct PolicySourceMap {
+ const char* key;
+ int string_id;
+};
+
+// Strings that map from PolicySource enum to i18n string keys and their IDs.
+const PolicySourceMap kPolicySources[] = {
+ {"", -1}, // policy::POLICY_SOURCE_UNKNOWN
Dan Beam 2015/09/10 17:39:28 i originally included a soure member in PolicySour
fhorschig 2015/09/11 12:22:33 Acknowledged.
+ {"sourceEnterprise", IDS_POLICY_SOURCE_ENTERPRISE},
+ {"sourceProgrammatic", IDS_POLICY_SOURCE_PROGRAMMATIC},
+ {"sourcePlatform", IDS_POLICY_SOURCE_PLATFORM},
+ {"sourceCloud", IDS_POLICY_SOURCE_CLOUD}
+};
+
+void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) {
+ for (int i = 1; i < policy::POLICY_SOURCE_COUNT; ++i) {
+ source->AddLocalizedString(kPolicySources[i].key,
+ kPolicySources[i].string_id);
+ }
+}
+
content::WebUIDataSource* CreatePolicyUIHTMLSource() {
content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
@@ -108,6 +129,7 @@ content::WebUIDataSource* CreatePolicyUIHTMLSource() {
source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME);
source->AddLocalizedString("headerValue", IDS_POLICY_HEADER_VALUE);
source->AddLocalizedString("headerStatus", IDS_POLICY_HEADER_STATUS);
+ source->AddLocalizedString("headerSource", IDS_POLICY_HEADER_SOURCE);
source->AddLocalizedString("showExpandedValue",
IDS_POLICY_SHOW_EXPANDED_VALUE);
source->AddLocalizedString("hideExpandedValue",
@@ -120,6 +142,7 @@ content::WebUIDataSource* CreatePolicyUIHTMLSource() {
source->AddLocalizedString("unset", IDS_POLICY_UNSET);
source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED);
+ AddLocalizedPoilcySourceStrings(source);
source->SetJsonPath("strings.js");
@@ -752,6 +775,7 @@ void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map,
value->SetString("level", "recommended");
else
value->SetString("level", "mandatory");
+ value->SetString("source", kPolicySources[entry->second.source].key);
Dan Beam 2015/09/10 17:39:28 ... but this could be worse
fhorschig 2015/09/11 12:22:33 Acknowledged.
base::string16 error = errors->GetErrors(entry->first);
if (!error.empty())
value->SetString("error", error);
« no previous file with comments | « chrome/browser/resources/policy.js ('k') | chrome/browser/ui/webui/policy_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698