| 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_list.h" | 5 #include "components/policy/core/browser/configuration_policy_handler_list.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_value_map.h" | 7 #include "base/prefs/pref_value_map.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "components/policy/core/browser/configuration_policy_handler.h" | 9 #include "components/policy/core/browser/configuration_policy_handler.h" |
| 10 #include "components/policy/core/browser/configuration_policy_handler_parameters
.h" |
| 10 #include "components/policy/core/browser/policy_error_map.h" | 11 #include "components/policy/core/browser/policy_error_map.h" |
| 11 #include "components/policy/core/common/policy_map.h" | 12 #include "components/policy/core/common/policy_map.h" |
| 12 #include "grit/component_strings.h" | 13 #include "grit/component_strings.h" |
| 13 | 14 |
| 14 namespace policy { | 15 namespace policy { |
| 15 ConfigurationPolicyHandlerList::ConfigurationPolicyHandlerList( | 16 ConfigurationPolicyHandlerList::ConfigurationPolicyHandlerList( |
| 17 const PopulatePolicyHandlerParametersCallback& parameters_callback, |
| 16 const GetChromePolicyDetailsCallback& details_callback) | 18 const GetChromePolicyDetailsCallback& details_callback) |
| 17 : details_callback_(details_callback) {} | 19 : parameters_callback_(parameters_callback), |
| 20 details_callback_(details_callback) {} |
| 18 | 21 |
| 19 ConfigurationPolicyHandlerList::~ConfigurationPolicyHandlerList() { | 22 ConfigurationPolicyHandlerList::~ConfigurationPolicyHandlerList() { |
| 20 STLDeleteElements(&handlers_); | 23 STLDeleteElements(&handlers_); |
| 21 } | 24 } |
| 22 | 25 |
| 23 void ConfigurationPolicyHandlerList::AddHandler( | 26 void ConfigurationPolicyHandlerList::AddHandler( |
| 24 scoped_ptr<ConfigurationPolicyHandler> handler) { | 27 scoped_ptr<ConfigurationPolicyHandler> handler) { |
| 25 handlers_.push_back(handler.release()); | 28 handlers_.push_back(handler.release()); |
| 26 } | 29 } |
| 27 | 30 |
| 28 void ConfigurationPolicyHandlerList::ApplyPolicySettings( | 31 void ConfigurationPolicyHandlerList::ApplyPolicySettings( |
| 29 const PolicyMap& policies, | 32 const PolicyMap& policies, |
| 30 PrefValueMap* prefs, | 33 PrefValueMap* prefs, |
| 31 PolicyErrorMap* errors) const { | 34 PolicyErrorMap* errors) const { |
| 32 PolicyErrorMap scoped_errors; | 35 PolicyErrorMap scoped_errors; |
| 33 if (!errors) | 36 if (!errors) |
| 34 errors = &scoped_errors; | 37 errors = &scoped_errors; |
| 35 | 38 |
| 39 policy::PolicyHandlerParameters parameters; |
| 40 parameters_callback_.Run(¶meters); |
| 41 |
| 36 std::vector<ConfigurationPolicyHandler*>::const_iterator handler; | 42 std::vector<ConfigurationPolicyHandler*>::const_iterator handler; |
| 37 for (handler = handlers_.begin(); handler != handlers_.end(); ++handler) { | 43 for (handler = handlers_.begin(); handler != handlers_.end(); ++handler) { |
| 38 if ((*handler)->CheckPolicySettings(policies, errors) && prefs) | 44 if ((*handler)->CheckPolicySettings(policies, errors) && prefs) |
| 39 (*handler)->ApplyPolicySettings(policies, prefs); | 45 (*handler) |
| 46 ->ApplyPolicySettingsWithParameters(policies, parameters, prefs); |
| 40 } | 47 } |
| 41 | 48 |
| 42 for (PolicyMap::const_iterator it = policies.begin(); | 49 for (PolicyMap::const_iterator it = policies.begin(); |
| 43 it != policies.end(); | 50 it != policies.end(); |
| 44 ++it) { | 51 ++it) { |
| 45 const PolicyDetails* details = | 52 const PolicyDetails* details = |
| 46 details_callback_.is_null() ? NULL : details_callback_.Run(it->first); | 53 details_callback_.is_null() ? NULL : details_callback_.Run(it->first); |
| 47 if (details && details->is_deprecated) | 54 if (details && details->is_deprecated) |
| 48 errors->AddError(it->first, IDS_POLICY_DEPRECATED); | 55 errors->AddError(it->first, IDS_POLICY_DEPRECATED); |
| 49 } | 56 } |
| 50 } | 57 } |
| 51 | 58 |
| 52 void ConfigurationPolicyHandlerList::PrepareForDisplaying( | 59 void ConfigurationPolicyHandlerList::PrepareForDisplaying( |
| 53 PolicyMap* policies) const { | 60 PolicyMap* policies) const { |
| 54 std::vector<ConfigurationPolicyHandler*>::const_iterator handler; | 61 std::vector<ConfigurationPolicyHandler*>::const_iterator handler; |
| 55 for (handler = handlers_.begin(); handler != handlers_.end(); ++handler) | 62 for (handler = handlers_.begin(); handler != handlers_.end(); ++handler) |
| 56 (*handler)->PrepareForDisplaying(policies); | 63 (*handler)->PrepareForDisplaying(policies); |
| 57 } | 64 } |
| 58 | 65 |
| 59 } // namespace policy | 66 } // namespace policy |
| OLD | NEW |