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" | |
| 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 // Detecting proxy-policies since they need special handling when combining | |
| 43 // policy maps. | |
| 44 static ConfigurationPolicyType proxy_policies[]; | |
| 45 static bool is_proxy_policy(ConfigurationPolicyType policy); | |
| 46 static unsigned int proxy_policy_count(); | |
|
Mattias Nissler (ping if slow)
2011/06/24 09:16:46
do you still need this?
gfeher
2011/06/24 15:32:44
Done.
| |
| 47 // Combines two PolicyMap and stores the result in out_map. The policies in | |
| 48 // |base| take precedence over the policies in |overlay|. Proxy policies are | |
| 49 // only applied in groups, that is if at least one proxy policy is present in | |
| 50 // |base| then no proxy related policy of |overlay| will be applied. | |
| 51 static void CombineTwoPolicyMaps(const PolicyMap& base, | |
| 52 const PolicyMap& overlay, | |
| 53 PolicyMap* out_map); | |
| 54 | |
| 55 // Recompute |combined_| from |caches_| and trigger an OnUpdatePolicy if | |
| 56 // something changed. This is called whenever a change in one of the caches | |
| 57 // is observed. For i=0..n-1: |caches_[i]| will contribute all its policies | |
| 58 // except those already provided by |caches_[0]|..|caches_[i-1]|. Proxy | |
| 59 // related policies are handled as a special case: they are only applied in | |
| 60 // groups. | |
| 61 void RecombineCachesAndMaybeTriggerUpdate(); | |
| 62 | |
| 63 // The underlying policy caches. | |
| 64 typedef std::vector<CloudPolicyCacheBase*> ListType; | |
| 65 ListType caches_; | |
| 66 | |
| 67 // Policy level this provider will handle. | |
| 68 CloudPolicyCacheBase::PolicyLevel level_; | |
| 69 | |
| 70 // Provider observers that are registered with this provider. | |
| 71 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; | |
| 72 | |
| 73 // The currently valid combination of all the maps in |caches_|. Will be | |
| 74 // applied as is on call of Provide. | |
| 75 PolicyMap combined_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(CloudPolicyProviderImpl); | |
| 78 }; | |
| 79 | |
| 80 } // namespace policy | |
| 81 | |
| 82 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_IMPL_H_ | |
| OLD | NEW |