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

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

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

Powered by Google App Engine
This is Rietveld 408576698