| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search_engines/default_search_policy_handler.h" | 5 #include "components/search_engines/default_search_policy_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 dict->SetString(DefaultSearchManager::kShortName, host); | 294 dict->SetString(DefaultSearchManager::kShortName, host); |
| 295 if (keyword.empty()) | 295 if (keyword.empty()) |
| 296 dict->SetString(DefaultSearchManager::kKeyword, host); | 296 dict->SetString(DefaultSearchManager::kKeyword, host); |
| 297 | 297 |
| 298 DefaultSearchManager::AddPrefValueToMap(std::move(dict), prefs); | 298 DefaultSearchManager::AddPrefValueToMap(std::move(dict), prefs); |
| 299 } | 299 } |
| 300 | 300 |
| 301 bool DefaultSearchPolicyHandler::CheckIndividualPolicies( | 301 bool DefaultSearchPolicyHandler::CheckIndividualPolicies( |
| 302 const PolicyMap& policies, | 302 const PolicyMap& policies, |
| 303 PolicyErrorMap* errors) { | 303 PolicyErrorMap* errors) { |
| 304 bool all_ok = true; |
| 304 for (const auto& handler : handlers_) { | 305 for (const auto& handler : handlers_) { |
| 305 if (!handler->CheckPolicySettings(policies, errors)) | 306 // It's important to call CheckPolicySettings() on all handlers and not just |
| 306 return false; | 307 // exit on the first error, so we report all policy errors. |
| 308 all_ok &= handler->CheckPolicySettings(policies, errors); |
| 307 } | 309 } |
| 308 return true; | 310 return all_ok; |
| 309 } | 311 } |
| 310 | 312 |
| 311 bool DefaultSearchPolicyHandler::HasDefaultSearchPolicy( | 313 bool DefaultSearchPolicyHandler::HasDefaultSearchPolicy( |
| 312 const PolicyMap& policies, | 314 const PolicyMap& policies, |
| 313 const char* policy_name) { | 315 const char* policy_name) { |
| 314 return policies.Get(policy_name) != NULL; | 316 return policies.Get(policy_name) != NULL; |
| 315 } | 317 } |
| 316 | 318 |
| 317 bool DefaultSearchPolicyHandler::AnyDefaultSearchPoliciesSpecified( | 319 bool DefaultSearchPolicyHandler::AnyDefaultSearchPoliciesSpecified( |
| 318 const PolicyMap& policies) { | 320 const PolicyMap& policies) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 void DefaultSearchPolicyHandler::EnsureListPrefExists( | 359 void DefaultSearchPolicyHandler::EnsureListPrefExists( |
| 358 PrefValueMap* prefs, | 360 PrefValueMap* prefs, |
| 359 const std::string& path) { | 361 const std::string& path) { |
| 360 base::Value* value; | 362 base::Value* value; |
| 361 base::ListValue* list_value; | 363 base::ListValue* list_value; |
| 362 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) | 364 if (!prefs->GetValue(path, &value) || !value->GetAsList(&list_value)) |
| 363 prefs->SetValue(path, base::MakeUnique<base::ListValue>()); | 365 prefs->SetValue(path, base::MakeUnique<base::ListValue>()); |
| 364 } | 366 } |
| 365 | 367 |
| 366 } // namespace policy | 368 } // namespace policy |
| OLD | NEW |