| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 | 79 |
| 80 | 80 |
| 81 // IntRangePolicyHandlerBase implementation ------------------------------------ | 81 // IntRangePolicyHandlerBase implementation ------------------------------------ |
| 82 | 82 |
| 83 IntRangePolicyHandlerBase::IntRangePolicyHandlerBase( | 83 IntRangePolicyHandlerBase::IntRangePolicyHandlerBase( |
| 84 const char* policy_name, | 84 const char* policy_name, |
| 85 int min, | 85 int min, |
| 86 int max, | 86 int max, |
| 87 bool clamp) | 87 bool clamp) |
| 88 : TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_INTEGER), | 88 : TypeCheckingPolicyHandler(policy_name, base::Value::Type::INTEGER), |
| 89 min_(min), | 89 min_(min), |
| 90 max_(max), | 90 max_(max), |
| 91 clamp_(clamp) { | 91 clamp_(clamp) { |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool IntRangePolicyHandlerBase::CheckPolicySettings(const PolicyMap& policies, | 94 bool IntRangePolicyHandlerBase::CheckPolicySettings(const PolicyMap& policies, |
| 95 PolicyErrorMap* errors) { | 95 PolicyErrorMap* errors) { |
| 96 const base::Value* value; | 96 const base::Value* value; |
| 97 return CheckAndGetValue(policies, errors, &value) && | 97 return CheckAndGetValue(policies, errors, &value) && |
| 98 EnsureInRange(value, NULL, errors); | 98 EnsureInRange(value, NULL, errors); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 const char* policy_value, | 138 const char* policy_value, |
| 139 std::unique_ptr<base::Value> map) | 139 std::unique_ptr<base::Value> map) |
| 140 : enum_value(policy_value), mapped_value(std::move(map)) {} | 140 : enum_value(policy_value), mapped_value(std::move(map)) {} |
| 141 | 141 |
| 142 StringMappingListPolicyHandler::MappingEntry::~MappingEntry() {} | 142 StringMappingListPolicyHandler::MappingEntry::~MappingEntry() {} |
| 143 | 143 |
| 144 StringMappingListPolicyHandler::StringMappingListPolicyHandler( | 144 StringMappingListPolicyHandler::StringMappingListPolicyHandler( |
| 145 const char* policy_name, | 145 const char* policy_name, |
| 146 const char* pref_path, | 146 const char* pref_path, |
| 147 const GenerateMapCallback& callback) | 147 const GenerateMapCallback& callback) |
| 148 : TypeCheckingPolicyHandler(policy_name, base::Value::TYPE_LIST), | 148 : TypeCheckingPolicyHandler(policy_name, base::Value::Type::LIST), |
| 149 pref_path_(pref_path), | 149 pref_path_(pref_path), |
| 150 map_getter_(callback) {} | 150 map_getter_(callback) {} |
| 151 | 151 |
| 152 StringMappingListPolicyHandler::~StringMappingListPolicyHandler() {} | 152 StringMappingListPolicyHandler::~StringMappingListPolicyHandler() {} |
| 153 | 153 |
| 154 bool StringMappingListPolicyHandler::CheckPolicySettings( | 154 bool StringMappingListPolicyHandler::CheckPolicySettings( |
| 155 const PolicyMap& policies, | 155 const PolicyMap& policies, |
| 156 PolicyErrorMap* errors) { | 156 PolicyErrorMap* errors) { |
| 157 const base::Value* value; | 157 const base::Value* value; |
| 158 return CheckAndGetValue(policies, errors, &value) && | 158 return CheckAndGetValue(policies, errors, &value) && |
| (...skipping 22 matching lines...) Expand all Loading... |
| 181 NOTREACHED(); | 181 NOTREACHED(); |
| 182 return false; | 182 return false; |
| 183 } | 183 } |
| 184 | 184 |
| 185 for (auto entry = list_value->begin(); entry != list_value->end(); ++entry) { | 185 for (auto entry = list_value->begin(); entry != list_value->end(); ++entry) { |
| 186 std::string entry_value; | 186 std::string entry_value; |
| 187 if (!(*entry)->GetAsString(&entry_value)) { | 187 if (!(*entry)->GetAsString(&entry_value)) { |
| 188 if (errors) { | 188 if (errors) { |
| 189 errors->AddError(policy_name(), entry - list_value->begin(), | 189 errors->AddError(policy_name(), entry - list_value->begin(), |
| 190 IDS_POLICY_TYPE_ERROR, | 190 IDS_POLICY_TYPE_ERROR, |
| 191 base::Value::GetTypeName(base::Value::TYPE_STRING)); | 191 base::Value::GetTypeName(base::Value::Type::STRING)); |
| 192 } | 192 } |
| 193 continue; | 193 continue; |
| 194 } | 194 } |
| 195 | 195 |
| 196 std::unique_ptr<base::Value> mapped_value = Map(entry_value); | 196 std::unique_ptr<base::Value> mapped_value = Map(entry_value); |
| 197 if (mapped_value) { | 197 if (mapped_value) { |
| 198 if (output) | 198 if (output) |
| 199 output->Append(std::move(mapped_value)); | 199 output->Append(std::move(mapped_value)); |
| 200 } else { | 200 } else { |
| 201 if (errors) { | 201 if (errors) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 452 } |
| 453 } | 453 } |
| 454 | 454 |
| 455 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings( | 455 void LegacyPoliciesDeprecatingPolicyHandler::ApplyPolicySettings( |
| 456 const policy::PolicyMap& /* policies */, | 456 const policy::PolicyMap& /* policies */, |
| 457 PrefValueMap* /* prefs */) { | 457 PrefValueMap* /* prefs */) { |
| 458 NOTREACHED(); | 458 NOTREACHED(); |
| 459 } | 459 } |
| 460 | 460 |
| 461 } // namespace policy | 461 } // namespace policy |
| OLD | NEW |