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

Side by Side Diff: chrome/browser/ui/webui/policy_ui.cc

Issue 1348903007: Revert of 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 unified diff | Download patch
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 <stddef.h>
8
9 #include "base/bind.h" 7 #include "base/bind.h"
10 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
11 #include "base/callback.h" 9 #include "base/callback.h"
12 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
13 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
14 #include "base/logging.h" 12 #include "base/logging.h"
15 #include "base/macros.h" 13 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
17 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
18 #include "base/time/time.h" 16 #include "base/time/time.h"
19 #include "base/values.h" 17 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/policy/profile_policy_connector.h" 19 #include "chrome/browser/policy/profile_policy_connector.h"
22 #include "chrome/browser/policy/profile_policy_connector_factory.h" 20 #include "chrome/browser/policy/profile_policy_connector_factory.h"
23 #include "chrome/browser/policy/schema_registry_service.h" 21 #include "chrome/browser/policy/schema_registry_service.h"
24 #include "chrome/browser/policy/schema_registry_service_factory.h" 22 #include "chrome/browser/policy/schema_registry_service_factory.h"
25 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 #include "extensions/browser/extension_registry_observer.h" 70 #include "extensions/browser/extension_registry_observer.h"
73 #include "extensions/common/extension.h" 71 #include "extensions/common/extension.h"
74 #include "extensions/common/manifest.h" 72 #include "extensions/common/manifest.h"
75 #include "extensions/common/manifest_constants.h" 73 #include "extensions/common/manifest_constants.h"
76 #endif 74 #endif
77 75
78 namespace em = enterprise_management; 76 namespace em = enterprise_management;
79 77
80 namespace { 78 namespace {
81 79
82 struct PolicySourceMap {
83 const char* key;
84 int string_id;
85 };
86
87 // Strings that map from PolicySource enum to i18n string keys and their IDs.
88 const PolicySourceMap kPolicySources[policy::POLICY_SOURCE_COUNT] = {
89 {"sourceEnterpriseDefault", IDS_POLICY_SOURCE_ENTERPRISE_DEFAULT},
90 {"sourceCloud", IDS_POLICY_SOURCE_CLOUD},
91 {"sourceEnterpriseOverride", IDS_POLICY_SOURCE_ENTERPRISE_OVERRIDE},
92 {"sourcePlatform", IDS_POLICY_SOURCE_PLATFORM}
93 };
94
95 void AddLocalizedPoilcySourceStrings(content::WebUIDataSource* source) {
96 DCHECK_EQ(static_cast<size_t>(policy::POLICY_SOURCE_COUNT),
97 arraysize(kPolicySources));
98 for (size_t i = 0; i < arraysize(kPolicySources); ++i) {
99 source->AddLocalizedString(kPolicySources[i].key,
100 kPolicySources[i].string_id);
101 }
102 }
103
104 content::WebUIDataSource* CreatePolicyUIHTMLSource() { 80 content::WebUIDataSource* CreatePolicyUIHTMLSource() {
105 content::WebUIDataSource* source = 81 content::WebUIDataSource* source =
106 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost); 82 content::WebUIDataSource::Create(chrome::kChromeUIPolicyHost);
107 83
108 // Localized strings. 84 // Localized strings.
109 source->AddLocalizedString("title", IDS_POLICY_TITLE); 85 source->AddLocalizedString("title", IDS_POLICY_TITLE);
110 source->AddLocalizedString("filterPlaceholder", 86 source->AddLocalizedString("filterPlaceholder",
111 IDS_POLICY_FILTER_PLACEHOLDER); 87 IDS_POLICY_FILTER_PLACEHOLDER);
112 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES); 88 source->AddLocalizedString("reloadPolicies", IDS_POLICY_RELOAD_POLICIES);
113 source->AddLocalizedString("status", IDS_POLICY_STATUS); 89 source->AddLocalizedString("status", IDS_POLICY_STATUS);
(...skipping 11 matching lines...) Expand all
125 source->AddLocalizedString("labelRefreshInterval", 101 source->AddLocalizedString("labelRefreshInterval",
126 IDS_POLICY_LABEL_REFRESH_INTERVAL); 102 IDS_POLICY_LABEL_REFRESH_INTERVAL);
127 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS); 103 source->AddLocalizedString("labelStatus", IDS_POLICY_LABEL_STATUS);
128 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET); 104 source->AddLocalizedString("showUnset", IDS_POLICY_SHOW_UNSET);
129 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET); 105 source->AddLocalizedString("noPoliciesSet", IDS_POLICY_NO_POLICIES_SET);
130 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE); 106 source->AddLocalizedString("headerScope", IDS_POLICY_HEADER_SCOPE);
131 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL); 107 source->AddLocalizedString("headerLevel", IDS_POLICY_HEADER_LEVEL);
132 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME); 108 source->AddLocalizedString("headerName", IDS_POLICY_HEADER_NAME);
133 source->AddLocalizedString("headerValue", IDS_POLICY_HEADER_VALUE); 109 source->AddLocalizedString("headerValue", IDS_POLICY_HEADER_VALUE);
134 source->AddLocalizedString("headerStatus", IDS_POLICY_HEADER_STATUS); 110 source->AddLocalizedString("headerStatus", IDS_POLICY_HEADER_STATUS);
135 source->AddLocalizedString("headerSource", IDS_POLICY_HEADER_SOURCE);
136 source->AddLocalizedString("showExpandedValue", 111 source->AddLocalizedString("showExpandedValue",
137 IDS_POLICY_SHOW_EXPANDED_VALUE); 112 IDS_POLICY_SHOW_EXPANDED_VALUE);
138 source->AddLocalizedString("hideExpandedValue", 113 source->AddLocalizedString("hideExpandedValue",
139 IDS_POLICY_HIDE_EXPANDED_VALUE); 114 IDS_POLICY_HIDE_EXPANDED_VALUE);
140 source->AddLocalizedString("scopeUser", IDS_POLICY_SCOPE_USER); 115 source->AddLocalizedString("scopeUser", IDS_POLICY_SCOPE_USER);
141 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE); 116 source->AddLocalizedString("scopeDevice", IDS_POLICY_SCOPE_DEVICE);
142 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED); 117 source->AddLocalizedString("levelRecommended", IDS_POLICY_LEVEL_RECOMMENDED);
143 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY); 118 source->AddLocalizedString("levelMandatory", IDS_POLICY_LEVEL_MANDATORY);
144 source->AddLocalizedString("ok", IDS_POLICY_OK); 119 source->AddLocalizedString("ok", IDS_POLICY_OK);
145 source->AddLocalizedString("unset", IDS_POLICY_UNSET); 120 source->AddLocalizedString("unset", IDS_POLICY_UNSET);
146 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN); 121 source->AddLocalizedString("unknown", IDS_POLICY_UNKNOWN);
147 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED); 122 source->AddLocalizedString("notSpecified", IDS_POLICY_NOT_SPECIFIED);
148 AddLocalizedPoilcySourceStrings(source);
149 123
150 source->SetJsonPath("strings.js"); 124 source->SetJsonPath("strings.js");
151 125
152 // Add required resources. 126 // Add required resources.
153 source->AddResourcePath("policy.css", IDR_POLICY_CSS); 127 source->AddResourcePath("policy.css", IDR_POLICY_CSS);
154 source->AddResourcePath("policy.js", IDR_POLICY_JS); 128 source->AddResourcePath("policy.js", IDR_POLICY_JS);
155 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS); 129 source->AddResourcePath("uber_utils.js", IDR_UBER_UTILS_JS);
156 source->SetDefaultResource(IDR_POLICY_HTML); 130 source->SetDefaultResource(IDR_POLICY_HTML);
157 131
158 return source; 132 return source;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 base::DictionaryValue* value = new base::DictionaryValue; 745 base::DictionaryValue* value = new base::DictionaryValue;
772 value->Set("value", CopyAndConvert(entry->second.value).release()); 746 value->Set("value", CopyAndConvert(entry->second.value).release());
773 if (entry->second.scope == policy::POLICY_SCOPE_USER) 747 if (entry->second.scope == policy::POLICY_SCOPE_USER)
774 value->SetString("scope", "user"); 748 value->SetString("scope", "user");
775 else 749 else
776 value->SetString("scope", "machine"); 750 value->SetString("scope", "machine");
777 if (entry->second.level == policy::POLICY_LEVEL_RECOMMENDED) 751 if (entry->second.level == policy::POLICY_LEVEL_RECOMMENDED)
778 value->SetString("level", "recommended"); 752 value->SetString("level", "recommended");
779 else 753 else
780 value->SetString("level", "mandatory"); 754 value->SetString("level", "mandatory");
781 value->SetString("source", kPolicySources[entry->second.source].key);
782 base::string16 error = errors->GetErrors(entry->first); 755 base::string16 error = errors->GetErrors(entry->first);
783 if (!error.empty()) 756 if (!error.empty())
784 value->SetString("error", error); 757 value->SetString("error", error);
785 values->Set(entry->first, value); 758 values->Set(entry->first, value);
786 } 759 }
787 } 760 }
788 761
789 void PolicyUIHandler::GetChromePolicyValues( 762 void PolicyUIHandler::GetChromePolicyValues(
790 base::DictionaryValue* values) const { 763 base::DictionaryValue* values) const {
791 policy::PolicyService* policy_service = GetPolicyService(); 764 policy::PolicyService* policy_service = GetPolicyService();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 } 837 }
865 838
866 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) { 839 PolicyUI::PolicyUI(content::WebUI* web_ui) : WebUIController(web_ui) {
867 web_ui->AddMessageHandler(new PolicyUIHandler); 840 web_ui->AddMessageHandler(new PolicyUIHandler);
868 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), 841 content::WebUIDataSource::Add(Profile::FromWebUI(web_ui),
869 CreatePolicyUIHTMLSource()); 842 CreatePolicyUIHTMLSource());
870 } 843 }
871 844
872 PolicyUI::~PolicyUI() { 845 PolicyUI::~PolicyUI() {
873 } 846 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/preferences_browsertest.cc ('k') | chrome/browser/ui/webui/policy_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698