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

Side by Side Diff: components/policy/core/browser/configuration_policy_handler.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 "components/policy/core/browser/configuration_policy_handler.h" 5 #include "components/policy/core/browser/configuration_policy_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 316 }
317 317
318 318
319 // SchemaValidatingPolicyHandler implementation -------------------------------- 319 // SchemaValidatingPolicyHandler implementation --------------------------------
320 320
321 SchemaValidatingPolicyHandler::SchemaValidatingPolicyHandler( 321 SchemaValidatingPolicyHandler::SchemaValidatingPolicyHandler(
322 const char* policy_name, 322 const char* policy_name,
323 Schema schema, 323 Schema schema,
324 SchemaOnErrorStrategy strategy) 324 SchemaOnErrorStrategy strategy)
325 : policy_name_(policy_name), schema_(schema), strategy_(strategy) { 325 : policy_name_(policy_name), schema_(schema), strategy_(strategy) {
326 DCHECK(schema_.valid()); 326 // TODO(mfomitchev): fix this
327 // DCHECK(schema_.valid());
327 } 328 }
328 329
329 SchemaValidatingPolicyHandler::~SchemaValidatingPolicyHandler() { 330 SchemaValidatingPolicyHandler::~SchemaValidatingPolicyHandler() {
330 } 331 }
331 332
332 const char* SchemaValidatingPolicyHandler::policy_name() const { 333 const char* SchemaValidatingPolicyHandler::policy_name() const {
333 return policy_name_; 334 return policy_name_;
334 } 335 }
335 336
336 bool SchemaValidatingPolicyHandler::CheckPolicySettings( 337 bool SchemaValidatingPolicyHandler::CheckPolicySettings(
337 const PolicyMap& policies, 338 const PolicyMap& policies,
338 PolicyErrorMap* errors) { 339 PolicyErrorMap* errors) {
340 if (!schema_.valid()) {
341 LOG(ERROR) << "auraclank: Invalid policy " << policy_name_;
342 return true;
343 }
339 const base::Value* value = policies.GetValue(policy_name()); 344 const base::Value* value = policies.GetValue(policy_name());
340 if (!value) 345 if (!value)
341 return true; 346 return true;
342 347
343 std::string error_path; 348 std::string error_path;
344 std::string error; 349 std::string error;
345 bool result = schema_.Validate(*value, strategy_, &error_path, &error); 350 bool result = schema_.Validate(*value, strategy_, &error_path, &error);
346 351
347 if (errors && !error.empty()) { 352 if (errors && !error.empty()) {
348 if (error_path.empty()) 353 if (error_path.empty())
349 error_path = "(ROOT)"; 354 error_path = "(ROOT)";
350 errors->AddError(policy_name_, error_path, error); 355 errors->AddError(policy_name_, error_path, error);
351 } 356 }
352 357
353 return result; 358 return result;
354 } 359 }
355 360
356 bool SchemaValidatingPolicyHandler::CheckAndGetValue( 361 bool SchemaValidatingPolicyHandler::CheckAndGetValue(
357 const PolicyMap& policies, 362 const PolicyMap& policies,
358 PolicyErrorMap* errors, 363 PolicyErrorMap* errors,
359 scoped_ptr<base::Value>* output) { 364 scoped_ptr<base::Value>* output) {
365 if (!schema_.valid()) {
366 LOG(ERROR) << "auraclank: Invalid policy " << policy_name_;
367 return true;
368 }
360 const base::Value* value = policies.GetValue(policy_name()); 369 const base::Value* value = policies.GetValue(policy_name());
361 if (!value) 370 if (!value)
362 return true; 371 return true;
363 372
364 output->reset(value->DeepCopy()); 373 output->reset(value->DeepCopy());
365 std::string error_path; 374 std::string error_path;
366 std::string error; 375 std::string error;
367 bool result = 376 bool result =
368 schema_.Normalize(output->get(), strategy_, &error_path, &error, NULL); 377 schema_.Normalize(output->get(), strategy_, &error_path, &error, NULL);
369 378
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 } 490 }
482 } 491 }
483 } 492 }
484 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings( 493 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings(
485 const policy::PolicyMap& /* policies */, 494 const policy::PolicyMap& /* policies */,
486 PrefValueMap* /* prefs */) { 495 PrefValueMap* /* prefs */) {
487 NOTREACHED(); 496 NOTREACHED();
488 } 497 }
489 498
490 } // namespace policy 499 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698