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

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

Issue 17068004: Revert 207755 "Add device policies to control accessibility sett..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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/policy/configuration_policy_handler.h" 5 #include "chrome/browser/policy/configuration_policy_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 const PolicyMap& policies, 285 const PolicyMap& policies,
286 PolicyErrorMap* errors) { 286 PolicyErrorMap* errors) {
287 const base::Value* value; 287 const base::Value* value;
288 return CheckAndGetValue(policies, errors, &value) && 288 return CheckAndGetValue(policies, errors, &value) &&
289 Convert(value, NULL, errors); 289 Convert(value, NULL, errors);
290 } 290 }
291 291
292 void StringToIntEnumListPolicyHandler::ApplyPolicySettings( 292 void StringToIntEnumListPolicyHandler::ApplyPolicySettings(
293 const PolicyMap& policies, 293 const PolicyMap& policies,
294 PrefValueMap* prefs) { 294 PrefValueMap* prefs) {
295 if (!pref_path_)
296 return;
297 const base::Value* value = policies.GetValue(policy_name()); 295 const base::Value* value = policies.GetValue(policy_name());
298 scoped_ptr<base::ListValue> list(new base::ListValue()); 296 scoped_ptr<base::ListValue> list(new base::ListValue());
299 if (value && Convert(value, list.get(), NULL)) 297 if (value && Convert(value, list.get(), NULL))
300 prefs->SetValue(pref_path_, list.release()); 298 prefs->SetValue(pref_path_, list.release());
301 } 299 }
302 300
303 bool StringToIntEnumListPolicyHandler::Convert(const base::Value* input, 301 bool StringToIntEnumListPolicyHandler::Convert(const base::Value* input,
304 base::ListValue* output, 302 base::ListValue* output,
305 PolicyErrorMap* errors) { 303 PolicyErrorMap* errors) {
306 if (!input) 304 if (!input)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 bool clamp) 353 bool clamp)
356 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), 354 : IntRangePolicyHandlerBase(policy_name, min, max, clamp),
357 pref_path_(pref_path) { 355 pref_path_(pref_path) {
358 } 356 }
359 357
360 IntRangePolicyHandler::~IntRangePolicyHandler() { 358 IntRangePolicyHandler::~IntRangePolicyHandler() {
361 } 359 }
362 360
363 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 361 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
364 PrefValueMap* prefs) { 362 PrefValueMap* prefs) {
365 if (!pref_path_)
366 return;
367 const base::Value* value = policies.GetValue(policy_name()); 363 const base::Value* value = policies.GetValue(policy_name());
368 int value_in_range; 364 int value_in_range;
369 if (value && EnsureInRange(value, &value_in_range, NULL)) { 365 if (value && EnsureInRange(value, &value_in_range, NULL)) {
370 prefs->SetValue(pref_path_, 366 prefs->SetValue(pref_path_,
371 base::Value::CreateIntegerValue(value_in_range)); 367 base::Value::CreateIntegerValue(value_in_range));
372 } 368 }
373 } 369 }
374 370
375 // IntPercentageToDoublePolicyHandler implementation --------------------------- 371 // IntPercentageToDoublePolicyHandler implementation ---------------------------
376 372
377 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler( 373 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler(
378 const char* policy_name, 374 const char* policy_name,
379 const char* pref_path, 375 const char* pref_path,
380 int min, 376 int min,
381 int max, 377 int max,
382 bool clamp) 378 bool clamp)
383 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), 379 : IntRangePolicyHandlerBase(policy_name, min, max, clamp),
384 pref_path_(pref_path) { 380 pref_path_(pref_path) {
385 } 381 }
386 382
387 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() { 383 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() {
388 } 384 }
389 385
390 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings( 386 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings(
391 const PolicyMap& policies, 387 const PolicyMap& policies,
392 PrefValueMap* prefs) { 388 PrefValueMap* prefs) {
393 if (!pref_path_)
394 return;
395 const base::Value* value = policies.GetValue(policy_name()); 389 const base::Value* value = policies.GetValue(policy_name());
396 int percentage; 390 int percentage;
397 if (value && EnsureInRange(value, &percentage, NULL)) { 391 if (value && EnsureInRange(value, &percentage, NULL)) {
398 prefs->SetValue(pref_path_, base::Value::CreateDoubleValue( 392 prefs->SetValue(pref_path_, base::Value::CreateDoubleValue(
399 static_cast<double>(percentage) / 100.)); 393 static_cast<double>(percentage) / 100.));
400 } 394 }
401 } 395 }
402 396
403 // ExtensionListPolicyHandler implementation ----------------------------------- 397 // ExtensionListPolicyHandler implementation -----------------------------------
404 398
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 return false; 609 return false;
616 } 610 }
617 } 611 }
618 612
619 return true; 613 return true;
620 } 614 }
621 615
622 void ExtensionURLPatternListPolicyHandler::ApplyPolicySettings( 616 void ExtensionURLPatternListPolicyHandler::ApplyPolicySettings(
623 const PolicyMap& policies, 617 const PolicyMap& policies,
624 PrefValueMap* prefs) { 618 PrefValueMap* prefs) {
625 if (!pref_path_)
626 return;
627 const Value* value = policies.GetValue(policy_name()); 619 const Value* value = policies.GetValue(policy_name());
628 if (value) 620 if (value)
629 prefs->SetValue(pref_path_, value->DeepCopy()); 621 prefs->SetValue(pref_path_, value->DeepCopy());
630 } 622 }
631 623
632 // SimplePolicyHandler implementation ------------------------------------------ 624 // SimplePolicyHandler implementation ------------------------------------------
633 625
634 SimplePolicyHandler::SimplePolicyHandler( 626 SimplePolicyHandler::SimplePolicyHandler(
635 const char* policy_name, 627 const char* policy_name,
636 const char* pref_path, 628 const char* pref_path,
637 Value::Type value_type) 629 Value::Type value_type)
638 : TypeCheckingPolicyHandler(policy_name, value_type), 630 : TypeCheckingPolicyHandler(policy_name, value_type),
639 pref_path_(pref_path) { 631 pref_path_(pref_path) {
640 } 632 }
641 633
642 SimplePolicyHandler::~SimplePolicyHandler() { 634 SimplePolicyHandler::~SimplePolicyHandler() {
643 } 635 }
644 636
645 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 637 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
646 PrefValueMap* prefs) { 638 PrefValueMap* prefs) {
647 if (!pref_path_)
648 return;
649 const Value* value = policies.GetValue(policy_name()); 639 const Value* value = policies.GetValue(policy_name());
650 if (value) 640 if (value)
651 prefs->SetValue(pref_path_, value->DeepCopy()); 641 prefs->SetValue(pref_path_, value->DeepCopy());
652 } 642 }
653 643
654 644
655 // SyncPolicyHandler implementation -------------------------------------------- 645 // SyncPolicyHandler implementation --------------------------------------------
656 646
657 SyncPolicyHandler::SyncPolicyHandler() 647 SyncPolicyHandler::SyncPolicyHandler()
658 : TypeCheckingPolicyHandler(key::kSyncDisabled, 648 : TypeCheckingPolicyHandler(key::kSyncDisabled,
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 errors->AddError(policy_name(), 1575 errors->AddError(policy_name(),
1586 IDS_POLICY_OUT_OF_RANGE_ERROR, 1576 IDS_POLICY_OUT_OF_RANGE_ERROR,
1587 base::IntToString(restore_value)); 1577 base::IntToString(restore_value));
1588 } 1578 }
1589 } 1579 }
1590 } 1580 }
1591 return true; 1581 return true;
1592 } 1582 }
1593 1583
1594 } // namespace policy 1584 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698