| 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 "chrome/browser/policy/cloud_policy_provider_impl.h" | 5 #include "chrome/browser/policy/cloud_policy_provider_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "chrome/browser/policy/browser_policy_connector.h" | 9 #include "chrome/browser/policy/browser_policy_connector.h" |
| 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 10 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 11 | 11 |
| 12 namespace policy { | 12 namespace policy { |
| 13 | 13 |
| 14 CloudPolicyProviderImpl::CloudPolicyProviderImpl( | 14 CloudPolicyProviderImpl::CloudPolicyProviderImpl( |
| 15 BrowserPolicyConnector* browser_policy_connector, | 15 BrowserPolicyConnector* browser_policy_connector, |
| 16 const PolicyDefinitionList* policy_list, | 16 const PolicyDefinitionList* policy_list, |
| 17 CloudPolicyCacheBase::PolicyLevel level) | 17 PolicyLevel level) |
| 18 : CloudPolicyProvider(policy_list), | 18 : CloudPolicyProvider(policy_list), |
| 19 browser_policy_connector_(browser_policy_connector), | 19 browser_policy_connector_(browser_policy_connector), |
| 20 level_(level), | 20 level_(level), |
| 21 initialization_complete_(true) {} | 21 initialization_complete_(true) {} |
| 22 | 22 |
| 23 CloudPolicyProviderImpl::~CloudPolicyProviderImpl() { | 23 CloudPolicyProviderImpl::~CloudPolicyProviderImpl() { |
| 24 for (ListType::iterator i = caches_.begin(); i != caches_.end(); ++i) | 24 for (ListType::iterator i = caches_.begin(); i != caches_.end(); ++i) |
| 25 (*i)->RemoveObserver(this); | 25 (*i)->RemoveObserver(this); |
| 26 } | 26 } |
| 27 | 27 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 if (all_caches_ready) | 82 if (all_caches_ready) |
| 83 initialization_complete_ = true; | 83 initialization_complete_ = true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Reconstruct the merged policy map. | 86 // Reconstruct the merged policy map. |
| 87 PolicyMap newly_combined; | 87 PolicyMap newly_combined; |
| 88 PolicyMap cache_policies; | 88 PolicyMap cache_policies; |
| 89 for (ListType::iterator i = caches_.begin(); i != caches_.end(); ++i) { | 89 for (ListType::iterator i = caches_.begin(); i != caches_.end(); ++i) { |
| 90 if (!(*i)->IsReady()) | 90 if (!(*i)->IsReady()) |
| 91 continue; | 91 continue; |
| 92 cache_policies.CopyFrom(*(*i)->policy(level_)); | 92 cache_policies.CopyFrom(*(*i)->policy()); |
| 93 FixDeprecatedPolicies(&cache_policies); | 93 FixDeprecatedPolicies(&cache_policies); |
| 94 newly_combined.MergeFrom(cache_policies); | 94 newly_combined.MergeFrom(cache_policies); |
| 95 } | 95 } |
| 96 | 96 |
| 97 newly_combined.FilterLevel(level_); |
| 98 combined_.Swap(&newly_combined); |
| 99 |
| 97 // Trigger a notification. | 100 // Trigger a notification. |
| 98 combined_.Swap(&newly_combined); | |
| 99 if (pending_update_caches_.empty()) | 101 if (pending_update_caches_.empty()) |
| 100 NotifyPolicyUpdated(); | 102 NotifyPolicyUpdated(); |
| 101 } | 103 } |
| 102 | 104 |
| 103 // static | 105 // static |
| 104 void CloudPolicyProviderImpl::RemoveCache(CloudPolicyCacheBase* cache, | 106 void CloudPolicyProviderImpl::RemoveCache(CloudPolicyCacheBase* cache, |
| 105 ListType* caches) { | 107 ListType* caches) { |
| 106 ListType::iterator it = std::find(caches->begin(), caches->end(), cache); | 108 ListType::iterator it = std::find(caches->begin(), caches->end(), cache); |
| 107 if (it != caches->end()) | 109 if (it != caches->end()) |
| 108 caches->erase(it); | 110 caches->erase(it); |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace policy | 113 } // namespace policy |
| OLD | NEW |