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