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

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: Fixed browsertest and removed unnecessary string for default values. Created 5 years, 4 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
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..91b609c64040e3acdee7bcaeb62066b47aa1db4e 100644
--- a/chrome/browser/ui/webui/policy_ui.cc
+++ b/chrome/browser/ui/webui/policy_ui.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "base/prefs/pref_service.h"
Thiemo Nagel 2015/09/01 17:40:36 What is this required for?
fhorschig 2015/09/04 06:53:53 Deprecated. Removed.
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -108,6 +109,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",
@@ -116,6 +118,9 @@ content::WebUIDataSource* CreatePolicyUIHTMLSource() {
source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE);
source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED);
source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY);
+ source->AddLocalizedString("sourceEnterprise", IDS_POLICY_SOURCE_ENTERPRISE);
+ source->AddLocalizedString("sourcePlatform", IDS_POLICY_SOURCE_PLATFORM);
+ source->AddLocalizedString("sourceCloud", IDS_POLICY_SOURCE_CLOUD);
source->AddLocalizedString("ok", IDS_POLICY_OK);
source->AddLocalizedString("unset", IDS_POLICY_UNSET);
source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
@@ -402,6 +407,9 @@ class PolicyUIHandler : public content::WebUIMessageHandler,
policy::PolicyErrorMap* errors,
base::DictionaryValue* values) const;
+ // Asks the profile's Pref_Service for the store that finally set the policy.
+ std::string GetSourceName(const policy::PolicySource& source) const;
+
void GetChromePolicyValues(base::DictionaryValue* values) const;
void HandleInitialized(const base::ListValue* args);
@@ -752,6 +760,7 @@ void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map,
value->SetString("level", "recommended");
else
value->SetString("level", "mandatory");
+ value->SetString("source", GetSourceName(entry->second.source));
base::string16 error = errors->GetErrors(entry->first);
if (!error.empty())
value->SetString("error", error);
@@ -759,6 +768,20 @@ void PolicyUIHandler::GetPolicyValues(const policy::PolicyMap& map,
}
}
+std::string PolicyUIHandler::GetSourceName(
+ const policy::PolicySource& source) const {
+ switch (source) {
+ case policy::POLICY_SOURCE_ENTERPRISE_DEFAULT:
+ return "sourceEnterprise";
+ case policy::POLICY_SOURCE_CLOUD:
+ return "sourceCloud";
+ case policy::POLICY_SOURCE_PLATFORM:
+ return "sourcePlatform";
+ default:
+ return "";
+ }
+}
+
void PolicyUIHandler::GetChromePolicyValues(
base::DictionaryValue* values) const {
policy::PolicyService* policy_service = GetPolicyService();

Powered by Google App Engine
This is Rietveld 408576698