| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return true; | 210 return true; |
| 211 } | 211 } |
| 212 | 212 |
| 213 std::unique_ptr<base::Value> StringMappingListPolicyHandler::Map( | 213 std::unique_ptr<base::Value> StringMappingListPolicyHandler::Map( |
| 214 const std::string& entry_value) { | 214 const std::string& entry_value) { |
| 215 // Lazily generate the map of policy strings to mapped values. | 215 // Lazily generate the map of policy strings to mapped values. |
| 216 if (map_.empty()) | 216 if (map_.empty()) |
| 217 map_getter_.Run(&map_); | 217 map_getter_.Run(&map_); |
| 218 | 218 |
| 219 std::unique_ptr<base::Value> return_value; | 219 std::unique_ptr<base::Value> return_value; |
| 220 for (const auto& mapping_entry : map_) { | 220 for (const auto* mapping_entry : map_) { |
| 221 if (mapping_entry->enum_value == entry_value) { | 221 if (mapping_entry->enum_value == entry_value) { |
| 222 return_value = base::WrapUnique(mapping_entry->mapped_value->DeepCopy()); | 222 return_value = base::WrapUnique(mapping_entry->mapped_value->DeepCopy()); |
| 223 break; | 223 break; |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 return return_value; | 226 return return_value; |
| 227 } | 227 } |
| 228 | 228 |
| 229 // IntRangePolicyHandler implementation ---------------------------------------- | 229 // IntRangePolicyHandler implementation ---------------------------------------- |
| 230 | 230 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 bool LegacyPoliciesDeprecatingPolicyHandler::CheckPolicySettings( | 424 bool LegacyPoliciesDeprecatingPolicyHandler::CheckPolicySettings( |
| 425 const PolicyMap& policies, | 425 const PolicyMap& policies, |
| 426 PolicyErrorMap* errors) { | 426 PolicyErrorMap* errors) { |
| 427 if (policies.Get(new_policy_handler_->policy_name())) | 427 if (policies.Get(new_policy_handler_->policy_name())) |
| 428 return new_policy_handler_->CheckPolicySettings(policies, errors); | 428 return new_policy_handler_->CheckPolicySettings(policies, errors); |
| 429 | 429 |
| 430 // The new policy is not set, fall back to legacy ones. | 430 // The new policy is not set, fall back to legacy ones. |
| 431 ScopedVector<ConfigurationPolicyHandler>::iterator handler; | 431 ScopedVector<ConfigurationPolicyHandler>::iterator handler; |
| 432 bool valid_policy_found = false; | 432 bool valid_policy_found = false; |
| 433 for (const auto& handler : legacy_policy_handlers_) { | 433 for (auto* handler : legacy_policy_handlers_) { |
| 434 if (handler->CheckPolicySettings(policies, errors)) | 434 if (handler->CheckPolicySettings(policies, errors)) |
| 435 valid_policy_found = true; | 435 valid_policy_found = true; |
| 436 } | 436 } |
| 437 return valid_policy_found; | 437 return valid_policy_found; |
| 438 } | 438 } |
| 439 | 439 |
| 440 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettingsWithParameters( | 440 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettingsWithParameters( |
| 441 const policy::PolicyMap& policies, | 441 const policy::PolicyMap& policies, |
| 442 const policy::PolicyHandlerParameters& parameters, | 442 const policy::PolicyHandlerParameters& parameters, |
| 443 PrefValueMap* prefs) { | 443 PrefValueMap* prefs) { |
| 444 if (policies.Get(new_policy_handler_->policy_name())) { | 444 if (policies.Get(new_policy_handler_->policy_name())) { |
| 445 new_policy_handler_->ApplyPolicySettingsWithParameters(policies, parameters, | 445 new_policy_handler_->ApplyPolicySettingsWithParameters(policies, parameters, |
| 446 prefs); | 446 prefs); |
| 447 return; | 447 return; |
| 448 } | 448 } |
| 449 | 449 |
| 450 // The new policy is not set, fall back to legacy ones. | 450 // The new policy is not set, fall back to legacy ones. |
| 451 PolicyErrorMap scoped_errors; | 451 PolicyErrorMap scoped_errors; |
| 452 for (const auto& handler : legacy_policy_handlers_) { | 452 for (auto* handler : legacy_policy_handlers_) { |
| 453 if (handler->CheckPolicySettings(policies, &scoped_errors)) | 453 if (handler->CheckPolicySettings(policies, &scoped_errors)) |
| 454 handler->ApplyPolicySettingsWithParameters(policies, parameters, prefs); | 454 handler->ApplyPolicySettingsWithParameters(policies, parameters, prefs); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings( | 458 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings( |
| 459 const policy::PolicyMap& /* policies */, | 459 const policy::PolicyMap& /* policies */, |
| 460 PrefValueMap* /* prefs */) { | 460 PrefValueMap* /* prefs */) { |
| 461 NOTREACHED(); | 461 NOTREACHED(); |
| 462 } | 462 } |
| 463 | 463 |
| 464 } // namespace policy | 464 } // namespace policy |
| OLD | NEW |