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

Side by Side Diff: chrome/browser/policy/configuration_policy_handler.cc

Issue 8480003: Surface error messages from ONC parsing in about:policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, break out code gen / unit test changes. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/policy/configuration_policy_handler.h" 5 #include "chrome/browser/policy/configuration_policy_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() { 160 TypeCheckingPolicyHandler::~TypeCheckingPolicyHandler() {
161 } 161 }
162 162
163 ConfigurationPolicyType TypeCheckingPolicyHandler::policy_type() const { 163 ConfigurationPolicyType TypeCheckingPolicyHandler::policy_type() const {
164 return policy_type_; 164 return policy_type_;
165 } 165 }
166 166
167 bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap& policies, 167 bool TypeCheckingPolicyHandler::CheckPolicySettings(const PolicyMap& policies,
168 PolicyErrorMap* errors) { 168 PolicyErrorMap* errors) {
169 const Value* value = policies.Get(policy_type_); 169 const Value* value = NULL;
170 if (value && value_type_ != value->GetType()) { 170 return CheckAndGetValue(policies, errors, &value);
171 }
172
173 bool TypeCheckingPolicyHandler::CheckAndGetValue(const PolicyMap& policies,
174 PolicyErrorMap* errors,
175 const Value** value) {
176 *value = policies.Get(policy_type_);
177 if (*value && !(*value)->IsType(value_type_)) {
171 errors->AddError(policy_type_, 178 errors->AddError(policy_type_,
172 IDS_POLICY_TYPE_ERROR, 179 IDS_POLICY_TYPE_ERROR,
173 ValueTypeToString(value_type_)); 180 ValueTypeToString(value_type_));
174 return false; 181 return false;
175 } 182 }
176 return true; 183 return true;
177 } 184 }
178 185
179
180 // SimplePolicyHandler implementation ------------------------------------------ 186 // SimplePolicyHandler implementation ------------------------------------------
181 187
182 SimplePolicyHandler::SimplePolicyHandler( 188 SimplePolicyHandler::SimplePolicyHandler(
183 ConfigurationPolicyType policy_type, 189 ConfigurationPolicyType policy_type,
184 Value::Type value_type, 190 Value::Type value_type,
185 const char* pref_path) 191 const char* pref_path)
186 : TypeCheckingPolicyHandler(policy_type, value_type), 192 : TypeCheckingPolicyHandler(policy_type, value_type),
187 pref_path_(pref_path) { 193 pref_path_(pref_path) {
188 } 194 }
189 195
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 } 894 }
889 } 895 }
890 896
891 if (setting != CONTENT_SETTING_DEFAULT) { 897 if (setting != CONTENT_SETTING_DEFAULT) {
892 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting, 898 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting,
893 Value::CreateIntegerValue(setting)); 899 Value::CreateIntegerValue(setting));
894 } 900 }
895 } 901 }
896 902
897 } // namespace policy 903 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698