| OLD | NEW |
| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 | 260 |
| 261 IntRangePolicyHandler::~IntRangePolicyHandler() { | 261 IntRangePolicyHandler::~IntRangePolicyHandler() { |
| 262 } | 262 } |
| 263 | 263 |
| 264 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, | 264 void IntRangePolicyHandler::ApplyPolicySettings(const PolicyMap& policies, |
| 265 PrefValueMap* prefs) { | 265 PrefValueMap* prefs) { |
| 266 if (!pref_path_) | 266 if (!pref_path_) |
| 267 return; | 267 return; |
| 268 const base::Value* value = policies.GetValue(policy_name()); | 268 const base::Value* value = policies.GetValue(policy_name()); |
| 269 int value_in_range; | 269 int value_in_range; |
| 270 if (value && EnsureInRange(value, &value_in_range, NULL)) { | 270 if (value && EnsureInRange(value, &value_in_range, NULL)) |
| 271 prefs->SetValue(pref_path_, | 271 prefs->SetInteger(pref_path_, value_in_range); |
| 272 new base::FundamentalValue(value_in_range)); | |
| 273 } | |
| 274 } | 272 } |
| 275 | 273 |
| 276 | 274 |
| 277 // IntPercentageToDoublePolicyHandler implementation --------------------------- | 275 // IntPercentageToDoublePolicyHandler implementation --------------------------- |
| 278 | 276 |
| 279 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler( | 277 IntPercentageToDoublePolicyHandler::IntPercentageToDoublePolicyHandler( |
| 280 const char* policy_name, | 278 const char* policy_name, |
| 281 const char* pref_path, | 279 const char* pref_path, |
| 282 int min, | 280 int min, |
| 283 int max, | 281 int max, |
| 284 bool clamp) | 282 bool clamp) |
| 285 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), | 283 : IntRangePolicyHandlerBase(policy_name, min, max, clamp), |
| 286 pref_path_(pref_path) { | 284 pref_path_(pref_path) { |
| 287 } | 285 } |
| 288 | 286 |
| 289 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() { | 287 IntPercentageToDoublePolicyHandler::~IntPercentageToDoublePolicyHandler() { |
| 290 } | 288 } |
| 291 | 289 |
| 292 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings( | 290 void IntPercentageToDoublePolicyHandler::ApplyPolicySettings( |
| 293 const PolicyMap& policies, | 291 const PolicyMap& policies, |
| 294 PrefValueMap* prefs) { | 292 PrefValueMap* prefs) { |
| 295 if (!pref_path_) | 293 if (!pref_path_) |
| 296 return; | 294 return; |
| 297 const base::Value* value = policies.GetValue(policy_name()); | 295 const base::Value* value = policies.GetValue(policy_name()); |
| 298 int percentage; | 296 int percentage; |
| 299 if (value && EnsureInRange(value, &percentage, NULL)) { | 297 if (value && EnsureInRange(value, &percentage, NULL)) |
| 300 prefs->SetValue(pref_path_, base::Value::CreateDoubleValue( | 298 prefs->SetDouble(pref_path_, static_cast<double>(percentage) / 100.); |
| 301 static_cast<double>(percentage) / 100.)); | |
| 302 } | |
| 303 } | 299 } |
| 304 | 300 |
| 305 | 301 |
| 306 // SimplePolicyHandler implementation ------------------------------------------ | 302 // SimplePolicyHandler implementation ------------------------------------------ |
| 307 | 303 |
| 308 SimplePolicyHandler::SimplePolicyHandler( | 304 SimplePolicyHandler::SimplePolicyHandler( |
| 309 const char* policy_name, | 305 const char* policy_name, |
| 310 const char* pref_path, | 306 const char* pref_path, |
| 311 base::Value::Type value_type) | 307 base::Value::Type value_type) |
| 312 : TypeCheckingPolicyHandler(policy_name, value_type), | 308 : TypeCheckingPolicyHandler(policy_name, value_type), |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 for (handler = legacy_policy_handlers_.begin(); | 478 for (handler = legacy_policy_handlers_.begin(); |
| 483 handler != legacy_policy_handlers_.end(); | 479 handler != legacy_policy_handlers_.end(); |
| 484 ++handler) { | 480 ++handler) { |
| 485 if ((*handler)->CheckPolicySettings(policies, &scoped_errors)) | 481 if ((*handler)->CheckPolicySettings(policies, &scoped_errors)) |
| 486 (*handler)->ApplyPolicySettings(policies, prefs); | 482 (*handler)->ApplyPolicySettings(policies, prefs); |
| 487 } | 483 } |
| 488 } | 484 } |
| 489 } | 485 } |
| 490 | 486 |
| 491 } // namespace policy | 487 } // namespace policy |
| OLD | NEW |