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

Side by Side 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: Fixed platform-specific tests. 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/policy_ui.h" 5 #include "chrome/browser/ui/webui/policy_ui.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 #include "extensions/browser/extension_registry_observer.h" 70 #include "extensions/browser/extension_registry_observer.h"
71 #include "extensions/common/extension.h" 71 #include "extensions/common/extension.h"
72 #include "extensions/common/manifest.h" 72 #include "extensions/common/manifest.h"
73 #include "extensions/common/manifest_constants.h" 73 #include "extensions/common/manifest_constants.h"
74 #endif 74 #endif
75 75
76 namespace em = enterprise_management; 76 namespace em = enterprise_management;
77 77
78 namespace { 78 namespace {
79 79
80 // Strings that map from PolicySource enum to i18n strings.
81 const char* const kSourceNameStrings[policy::POLICY_SOURCE_COUNT] = {"",
Dan Beam 2015/09/09 21:50:16 eh, this is kinda weird. why do we have to duplic
fhorschig 2015/09/10 11:36:31 Good idea! Was there a special reason to include t
82 "sourceEnterprise", "sourceProgrammatic", "sourcePlatform", "sourceCloud"};
83
80 content::WebUIDataSource* CreatePolicyUIHTMLSource() { 84 content::WebUIDataSource* CreatePolicyUIHTMLSource() {
81 content::WebUIDataSource* source = 85 content::WebUIDataSource* source =
82 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); 86 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
83 87
84 // Localized strings. 88 // Localized strings.
85 source->AddLocalizedString("title", IDS_POLICY_TITLE); 89 source->AddLocalizedString("title", IDS_POLICY_TITLE);
86 source->AddLocalizedString("filterPlaceholder", 90 source->AddLocalizedString("filterPlaceholder",
87 IDS_POLICY_FILTER_PLACEHOLDER); 91 IDS_POLICY_FILTER_PLACEHOLDER);
88 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); 92 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES);
89 source->AddLocalizedString("status", IDS_POLICY_STATUS); 93 source->AddLocalizedString("status", IDS_POLICY_STATUS);
(...skipping 11 matching lines...) Expand all
101 source->AddLocalizedString("labelRefreshInterval", 105 source->AddLocalizedString("labelRefreshInterval",
102 IDS_POLICY_LABEL_REFRESH_INTERVAL); 106 IDS_POLICY_LABEL_REFRESH_INTERVAL);
103 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS); 107 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS);
104 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET); 108 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET);
105 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET); 109 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET);
106 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE); 110 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE);
107 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL); 111 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL);
108 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME); 112 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME);
109 source->AddLocalizedString("headerValue", IDS_POLICY_HEADER_VALUE); 113 source->AddLocalizedString("headerValue", IDS_POLICY_HEADER_VALUE);
110 source->AddLocalizedString("headerStatus", IDS_POLICY_HEADER_STATUS); 114 source->AddLocalizedString("headerStatus", IDS_POLICY_HEADER_STATUS);
115 source->AddLocalizedString("headerSource", IDS_POLICY_HEADER_SOURCE);
111 source->AddLocalizedString("showExpandedValue", 116 source->AddLocalizedString("showExpandedValue",
112 IDS_POLICY_SHOW_EXPANDED_VALUE); 117 IDS_POLICY_SHOW_EXPANDED_VALUE);
113 source->AddLocalizedString("hideExpandedValue", 118 source->AddLocalizedString("hideExpandedValue",
114 IDS_POLICY_HIDE_EXPANDED_VALUE); 119 IDS_POLICY_HIDE_EXPANDED_VALUE);
115 source->AddLocalizedString("scopeUser", IDS_POLICY_SCOPE_USER); 120 source->AddLocalizedString("scopeUser", IDS_POLICY_SCOPE_USER);
116 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE); 121 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE);
117 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED); 122 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED);
118 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY); 123 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY);
124 source->AddLocalizedString("sourceProgrammatic",
125 IDS_POLICY_SOURCE_PROGRAMMATIC);
126 source->AddLocalizedString("sourceEnterprise", IDS_POLICY_SOURCE_ENTERPRISE);
127 source->AddLocalizedString("sourcePlatform", IDS_POLICY_SOURCE_PLATFORM);
128 source->AddLocalizedString("sourceCloud", IDS_POLICY_SOURCE_CLOUD);
Dan Beam 2015/09/09 21:50:16 and use kPolicySources here
fhorschig 2015/09/10 11:36:31 Done.
119 source->AddLocalizedString("ok", IDS_POLICY_OK); 129 source->AddLocalizedString("ok", IDS_POLICY_OK);
120 source->AddLocalizedString("unset", IDS_POLICY_UNSET); 130 source->AddLocalizedString("unset", IDS_POLICY_UNSET);
121 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); 131 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
122 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); 132 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED);
123 133
124 source->SetJsonPath("strings.js"); 134 source->SetJsonPath("strings.js");
125 135
126 // Add required resources. 136 // Add required resources.
127 source->AddResourcePath("policy.css", IDR_POLICY_CSS); 137 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
128 source->AddResourcePath("policy.js", IDR_POLICY_JS); 138 source->AddResourcePath("policy.js", IDR_POLICY_JS);
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 base::DictionaryValue* value = new base::DictionaryValue; 755 base::DictionaryValue* value = new base::DictionaryValue;
746 value->Set("value", CopyAndConvert(entry->second.value).release()); 756 value->Set("value", CopyAndConvert(entry->second.value).release());
747 if (entry->second.scope == policy::POLICY_SCOPE_USER) 757 if (entry->second.scope == policy::POLICY_SCOPE_USER)
748 value->SetString("scope", "user"); 758 value->SetString("scope", "user");
749 else 759 else
750 value->SetString("scope", "machine"); 760 value->SetString("scope", "machine");
751 if (entry->second.level == policy::POLICY_LEVEL_RECOMMENDED) 761 if (entry->second.level == policy::POLICY_LEVEL_RECOMMENDED)
752 value->SetString("level", "recommended"); 762 value->SetString("level", "recommended");
753 else 763 else
754 value->SetString("level", "mandatory"); 764 value->SetString("level", "mandatory");
765 value->SetString("source", kSourceNameStrings[entry->second.source]);
Dan Beam 2015/09/09 21:50:16 and here
fhorschig 2015/09/10 11:36:30 Done.
755 base::string16 error = errors->GetErrors(entry->first); 766 base::string16 error = errors->GetErrors(entry->first);
756 if (!error.empty()) 767 if (!error.empty())
757 value->SetString("error", error); 768 value->SetString("error", error);
758 values->Set(entry->first, value); 769 values->Set(entry->first, value);
759 } 770 }
760 } 771 }
761 772
762 void PolicyUIHandler::GetChromePolicyValues( 773 void PolicyUIHandler::GetChromePolicyValues(
763 base::DictionaryValue* values) const { 774 base::DictionaryValue* values) const {
764 policy::PolicyService* policy_service = GetPolicyService(); 775 policy::PolicyService* policy_service = GetPolicyService();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 } 848 }
838 849
839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 850 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
840 web_ui->AddMessageHandler(new PolicyUIHandler); 851 web_ui->AddMessageHandler(new PolicyUIHandler);
841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 852 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
842 CreatePolicyUIHTMLSource()); 853 CreatePolicyUIHTMLSource());
843 } 854 }
844 855
845 PolicyUI::~PolicyUI() { 856 PolicyUI::~PolicyUI() {
846 } 857 }
OLDNEW
« 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