OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/observer_list.h" |
| 10 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| 11 #include "chrome/browser/policy/cloud_policy_provider.h" |
| 12 #include "chrome/browser/policy/policy_map.h" |
| 13 |
| 14 namespace policy { |
| 15 |
| 16 class CloudPolicyProviderImpl : public CloudPolicyProvider, |
| 17 public CloudPolicyCacheBase::Observer { |
| 18 public: |
| 19 CloudPolicyProviderImpl(const PolicyDefinitionList* policy_list, |
| 20 CloudPolicyCacheBase::PolicyLevel level); |
| 21 virtual ~CloudPolicyProviderImpl(); |
| 22 |
| 23 // ConfigurationPolicyProvider implementation. |
| 24 virtual bool Provide(ConfigurationPolicyStoreInterface* store) OVERRIDE; |
| 25 virtual bool IsInitializationComplete() const OVERRIDE; |
| 26 virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer) |
| 27 OVERRIDE; |
| 28 virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer) |
| 29 OVERRIDE; |
| 30 |
| 31 // CloudPolicyCacheBase::Observer implementation. |
| 32 virtual void OnCacheUpdate(CloudPolicyCacheBase* cache) OVERRIDE; |
| 33 virtual void OnCacheGoingAway(CloudPolicyCacheBase* cache) OVERRIDE; |
| 34 virtual void AppendCache(CloudPolicyCacheBase* cache) OVERRIDE; |
| 35 virtual void PrependCache(CloudPolicyCacheBase* cache) OVERRIDE; |
| 36 |
| 37 private: |
| 38 friend class CloudPolicyProviderTest; |
| 39 |
| 40 // Combines two PolicyMap and stores the result in out_map. The policies in |
| 41 // |base| take precedence over the policies in |overlay|. Proxy policies are |
| 42 // only applied in groups, that is if at least one proxy policy is present in |
| 43 // |base| then no proxy related policy of |overlay| will be applied. |
| 44 static void CombineTwoPolicyMaps(const PolicyMap& base, |
| 45 const PolicyMap& overlay, |
| 46 PolicyMap* out_map); |
| 47 |
| 48 // Recompute |combined_| from |caches_| and trigger an OnUpdatePolicy if |
| 49 // something changed. This is called whenever a change in one of the caches |
| 50 // is observed. For i=0..n-1: |caches_[i]| will contribute all its policies |
| 51 // except those already provided by |caches_[0]|..|caches_[i-1]|. Proxy |
| 52 // related policies are handled as a special case: they are only applied in |
| 53 // groups. |
| 54 void RecombineCachesAndMaybeTriggerUpdate(); |
| 55 |
| 56 // The underlying policy caches. |
| 57 typedef std::vector<CloudPolicyCacheBase*> ListType; |
| 58 ListType caches_; |
| 59 |
| 60 // Policy level this provider will handle. |
| 61 CloudPolicyCacheBase::PolicyLevel level_; |
| 62 |
| 63 // Provider observers that are registered with this provider. |
| 64 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; |
| 65 |
| 66 // The currently valid combination of all the maps in |caches_|. Will be |
| 67 // applied as is on call of Provide. |
| 68 PolicyMap combined_; |
| 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(CloudPolicyProviderImpl); |
| 71 }; |
| 72 |
| 73 } // namespace policy |
| 74 |
| 75 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_ |
OLD | NEW |