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

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: Fix copy&paste mistake found by clang. 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 <cstring>
8 #include <string> 9 #include <string>
9 10
10 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
11 #include "base/json/json_writer.h" 12 #include "base/json/json_writer.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/prefs/pref_value_map.h" 14 #include "base/prefs/pref_value_map.h"
14 #include "base/stl_util.h" 15 #include "base/stl_util.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 const PolicyMap& policies, 286 const PolicyMap& policies,
286 PolicyErrorMap* errors) { 287 PolicyErrorMap* errors) {
287 const base::Value* value; 288 const base::Value* value;
288 return CheckAndGetValue(policies, errors, &value) && 289 return CheckAndGetValue(policies, errors, &value) &&
289 Convert(value, NULL, errors); 290 Convert(value, NULL, errors);
290 } 291 }
291 292
292 void StringToIntEnumListPolicyHandler::ApplyPolicySettings( 293 void StringToIntEnumListPolicyHandler::ApplyPolicySettings(
293 const PolicyMap& policies, 294 const PolicyMap& policies,
294 PrefValueMap* prefs) { 295 PrefValueMap* prefs) {
296 if (!strlen(pref_path_))
Mattias Nissler (ping if slow) 2013/06/12 13:55:16 Why not test for NULL?
bartfab (slow) 2013/06/12 18:57:49 Done.
297 return;
295 const base::Value* value = policies.GetValue(policy_name()); 298 const base::Value* value = policies.GetValue(policy_name());
296 scoped_ptr<base::ListValue> list(new base::ListValue()); 299 scoped_ptr<base::ListValue> list(new base::ListValue());
297 if (value && Convert(value, list.get(), NULL)) 300 if (value && Convert(value, list.get(), NULL))
298 prefs->SetValue(pref_path_, list.release()); 301 prefs->SetValue(pref_path_, list.release());
299 } 302 }
300 303
301 bool StringToIntEnumListPolicyHandler::Convert(const base::Value* input, 304 bool StringToIntEnumListPolicyHandler::Convert(const base::Value* input,
302 base::ListValue* output, 305 base::ListValue* output,
303 PolicyErrorMap* errors) { 306 PolicyErrorMap* errors) {
304 if (!input) 307 if (!input)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 bool clamp) 356 bool clamp)
354 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), 357 : IntRangePolicyHandlerBase(policy_name, min, max, clamp),
355 pref_path_(pref_path) { 358 pref_path_(pref_path) {
356 } 359 }
357 360
358 IntRangePolicyHandler::~IntRangePolicyHandler() { 361 IntRangePolicyHandler::~IntRangePolicyHandler() {
359 } 362 }
360 363
361 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 364 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
362 PrefValueMap* prefs) { 365 PrefValueMap* prefs) {
366 if (!strlen(pref_path_))
367 return;
363 const base::Value* value = policies.GetValue(policy_name()); 368 const base::Value* value = policies.GetValue(policy_name());
364 int value_in_range; 369 int value_in_range;
365 if (value && EnsureInRange(value, &value_in_range, NULL)) { 370 if (value && EnsureInRange(value, &value_in_range, NULL)) {
366 prefs->SetValue(pref_path_, 371 prefs->SetValue(pref_path_,
367 base::Value::CreateIntegerValue(value_in_range)); 372 base::Value::CreateIntegerValue(value_in_range));
368 } 373 }
369 } 374 }
370 375
371 // IntPercentageToDoublePolicyHandler implementation --------------------------- 376 // IntPercentageToDoublePolicyHandler implementation ---------------------------
372 377
373 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler( 378 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler(
374 const char* policy_name, 379 const char* policy_name,
375 const char* pref_path, 380 const char* pref_path,
376 int min, 381 int min,
377 int max, 382 int max,
378 bool clamp) 383 bool clamp)
379 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), 384 : IntRangePolicyHandlerBase(policy_name, min, max, clamp),
380 pref_path_(pref_path) { 385 pref_path_(pref_path) {
381 } 386 }
382 387
383 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() { 388 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() {
384 } 389 }
385 390
386 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings( 391 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings(
387 const PolicyMap& policies, 392 const PolicyMap& policies,
388 PrefValueMap* prefs) { 393 PrefValueMap* prefs) {
394 if (!strlen(pref_path_))
395 return;
389 const base::Value* value = policies.GetValue(policy_name()); 396 const base::Value* value = policies.GetValue(policy_name());
390 int percentage; 397 int percentage;
391 if (value && EnsureInRange(value, &percentage, NULL)) { 398 if (value && EnsureInRange(value, &percentage, NULL)) {
392 prefs->SetValue(pref_path_, base::Value::CreateDoubleValue( 399 prefs->SetValue(pref_path_, base::Value::CreateDoubleValue(
393 static_cast<double>(percentage) / 100.)); 400 static_cast<double>(percentage) / 100.));
394 } 401 }
395 } 402 }
396 403
397 // ExtensionListPolicyHandler implementation ----------------------------------- 404 // ExtensionListPolicyHandler implementation -----------------------------------
398 405
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 return false; 616 return false;
610 } 617 }
611 } 618 }
612 619
613 return true; 620 return true;
614 } 621 }
615 622
616 void ExtensionURLPatternListPolicyHandler::ApplyPolicySettings( 623 void ExtensionURLPatternListPolicyHandler::ApplyPolicySettings(
617 const PolicyMap& policies, 624 const PolicyMap& policies,
618 PrefValueMap* prefs) { 625 PrefValueMap* prefs) {
626 if (!strlen(pref_path_))
627 return;
619 const Value* value = policies.GetValue(policy_name()); 628 const Value* value = policies.GetValue(policy_name());
620 if (value) 629 if (value)
621 prefs->SetValue(pref_path_, value->DeepCopy()); 630 prefs->SetValue(pref_path_, value->DeepCopy());
622 } 631 }
623 632
624 // SimplePolicyHandler implementation ------------------------------------------ 633 // SimplePolicyHandler implementation ------------------------------------------
625 634
626 SimplePolicyHandler::SimplePolicyHandler( 635 SimplePolicyHandler::SimplePolicyHandler(
627 const char* policy_name, 636 const char* policy_name,
628 const char* pref_path, 637 const char* pref_path,
629 Value::Type value_type) 638 Value::Type value_type)
630 : TypeCheckingPolicyHandler(policy_name, value_type), 639 : TypeCheckingPolicyHandler(policy_name, value_type),
631 pref_path_(pref_path) { 640 pref_path_(pref_path) {
632 } 641 }
633 642
634 SimplePolicyHandler::~SimplePolicyHandler() { 643 SimplePolicyHandler::~SimplePolicyHandler() {
635 } 644 }
636 645
637 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, 646 void SimplePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
638 PrefValueMap* prefs) { 647 PrefValueMap* prefs) {
648 if (!strlen(pref_path_))
649 return;
639 const Value* value = policies.GetValue(policy_name()); 650 const Value* value = policies.GetValue(policy_name());
640 if (value) 651 if (value)
641 prefs->SetValue(pref_path_, value->DeepCopy()); 652 prefs->SetValue(pref_path_, value->DeepCopy());
642 } 653 }
643 654
644 655
645 // SyncPolicyHandler implementation -------------------------------------------- 656 // SyncPolicyHandler implementation --------------------------------------------
646 657
647 SyncPolicyHandler::SyncPolicyHandler() 658 SyncPolicyHandler::SyncPolicyHandler()
648 : TypeCheckingPolicyHandler(key::kSyncDisabled, 659 : TypeCheckingPolicyHandler(key::kSyncDisabled,
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 errors->AddError(policy_name(), 1586 errors->AddError(policy_name(),
1576 IDS_POLICY_OUT_OF_RANGE_ERROR, 1587 IDS_POLICY_OUT_OF_RANGE_ERROR,
1577 base::IntToString(restore_value)); 1588 base::IntToString(restore_value));
1578 } 1589 }
1579 } 1590 }
1580 } 1591 }
1581 return true; 1592 return true;
1582 } 1593 }
1583 1594
1584 } // namespace policy 1595 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698