| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/configuration_policy_provider.h" | 5 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/policy/policy_map.h" | 8 #include "chrome/browser/policy/policy_map.h" |
| 9 | 9 |
| 10 namespace policy { | 10 namespace policy { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 return true; | 22 return true; |
| 23 } | 23 } |
| 24 | 24 |
| 25 void ConfigurationPolicyProvider::ApplyPolicyValueTree( | 25 void ConfigurationPolicyProvider::ApplyPolicyValueTree( |
| 26 const DictionaryValue* policies, | 26 const DictionaryValue* policies, |
| 27 ConfigurationPolicyStoreInterface* store) { | 27 ConfigurationPolicyStoreInterface* store) { |
| 28 const PolicyDefinitionList* policy_list(policy_definition_list()); | 28 const PolicyDefinitionList* policy_list(policy_definition_list()); |
| 29 for (const PolicyDefinitionList::Entry* i = policy_list->begin; | 29 for (const PolicyDefinitionList::Entry* i = policy_list->begin; |
| 30 i != policy_list->end; ++i) { | 30 i != policy_list->end; ++i) { |
| 31 Value* value; | 31 Value* value; |
| 32 if (policies->Get(i->name, &value) && value->IsType(i->value_type)) | 32 if (policies->Get(i->name, &value) && value->GetType() == i->value_type) |
| 33 store->Apply(i->policy_type, value->DeepCopy()); | 33 store->Apply(i->policy_type, value->DeepCopy()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // TODO(mnissler): Handle preference overrides once |ConfigurationPolicyStore| | 36 // TODO(mnissler): Handle preference overrides once |ConfigurationPolicyStore| |
| 37 // supports it. | 37 // supports it. |
| 38 } | 38 } |
| 39 | 39 |
| 40 void ConfigurationPolicyProvider::ApplyPolicyMap( | 40 void ConfigurationPolicyProvider::ApplyPolicyMap( |
| 41 const PolicyMap* policies, | 41 const PolicyMap* policies, |
| 42 ConfigurationPolicyStoreInterface* store) { | 42 ConfigurationPolicyStoreInterface* store) { |
| 43 const PolicyDefinitionList* policy_list(policy_definition_list()); | 43 const PolicyDefinitionList* policy_list(policy_definition_list()); |
| 44 for (const PolicyDefinitionList::Entry* i = policy_list->begin; | 44 for (const PolicyDefinitionList::Entry* i = policy_list->begin; |
| 45 i != policy_list->end; ++i) { | 45 i != policy_list->end; ++i) { |
| 46 const Value* value = policies->Get(i->policy_type); | 46 const Value* value = policies->Get(i->policy_type); |
| 47 if (value && value->IsType(i->value_type)) | 47 if (value && value->GetType() == i->value_type) |
| 48 store->Apply(i->policy_type, value->DeepCopy()); | 48 store->Apply(i->policy_type, value->DeepCopy()); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Class ConfigurationPolicyObserverRegistrar. | 52 // Class ConfigurationPolicyObserverRegistrar. |
| 53 | 53 |
| 54 ConfigurationPolicyObserverRegistrar::ConfigurationPolicyObserverRegistrar() | 54 ConfigurationPolicyObserverRegistrar::ConfigurationPolicyObserverRegistrar() |
| 55 : provider_(NULL), | 55 : provider_(NULL), |
| 56 observer_(NULL) {} | 56 observer_(NULL) {} |
| 57 | 57 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 72 observer_->OnUpdatePolicy(); | 72 observer_->OnUpdatePolicy(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 void ConfigurationPolicyObserverRegistrar::OnProviderGoingAway() { | 75 void ConfigurationPolicyObserverRegistrar::OnProviderGoingAway() { |
| 76 observer_->OnProviderGoingAway(); | 76 observer_->OnProviderGoingAway(); |
| 77 provider_->RemoveObserver(this); | 77 provider_->RemoveObserver(this); |
| 78 provider_ = NULL; | 78 provider_ = NULL; |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace policy | 81 } // namespace policy |
| OLD | NEW |