| Index: chrome/browser/policy/cloud_policy_provider.h
|
| diff --git a/chrome/browser/policy/cloud_policy_provider.h b/chrome/browser/policy/cloud_policy_provider.h
|
| index a9bc606ba4d26dc689557ae9529c1b4c398d7bfd..b555260d8ac7701101c72d1d6e159f4613a4b905 100644
|
| --- a/chrome/browser/policy/cloud_policy_provider.h
|
| +++ b/chrome/browser/policy/cloud_policy_provider.h
|
| @@ -6,39 +6,82 @@
|
| #define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_
|
| #pragma once
|
|
|
| +#include <set>
|
| +
|
| #include "base/basictypes.h"
|
| +#include "chrome/browser/policy/cloud_policy_cache_base.h"
|
| #include "chrome/browser/policy/configuration_policy_provider.h"
|
| +#include "chrome/browser/policy/policy_map.h"
|
|
|
| namespace policy {
|
|
|
| -class CloudPolicyCacheBase;
|
| -
|
| -// A policy provider having multiple backend caches, combining their relevant
|
| -// PolicyMaps and keeping the result cached. The underlying caches are kept as
|
| -// weak references and can be added dynamically. Also the
|
| -// |CloudPolicyProvider| instance listens to cache-notifications and removes
|
| -// the caches automatically when they go away. The order in which the caches are
|
| -// stored matters! The first cache is applied as is and the following caches
|
| -// only contribute the not-yet applied policies. There are two functions to add
|
| -// a new cache:
|
| -// PrependCache(cache): adds |cache| to the front (i.e. most important cache).
|
| -// AppendCache(cache): adds |cache| to the back (i.e. least important cache).
|
| -class CloudPolicyProvider : public ConfigurationPolicyProvider {
|
| +class BrowserPolicyConnector;
|
| +
|
| +// A policy provider that merges the policies contained in the caches it
|
| +// observes. The caches receive their policies by fetching them from the cloud,
|
| +// through the CloudPolicyController.
|
| +class CloudPolicyProvider : public ConfigurationPolicyProvider,
|
| + public CloudPolicyCacheBase::Observer {
|
| public:
|
| - explicit CloudPolicyProvider(const PolicyDefinitionList* policy_list);
|
| + CloudPolicyProvider(BrowserPolicyConnector* browser_policy_connector,
|
| + const PolicyDefinitionList* policy_list,
|
| + PolicyLevel level);
|
| virtual ~CloudPolicyProvider();
|
|
|
| - // Adds a new instance of CloudPolicyCacheBase to the end of |caches_|.
|
| - // Does not take ownership of |cache| and listens to OnCacheGoingAway to
|
| - // automatically remove it from |caches_|.
|
| - virtual void AppendCache(CloudPolicyCacheBase* cache) = 0;
|
| + // Sets the user policy cache. This must be invoked only once, and |cache|
|
| + // must not be NULL.
|
| + void SetUserPolicyCache(CloudPolicyCacheBase* cache);
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| + // Sets the device policy cache. This must be invoked only once, and |cache|
|
| + // must not be NULL.
|
| + void SetDevicePolicyCache(CloudPolicyCacheBase* cache);
|
| +#endif
|
|
|
| - // Adds a new instance of CloudPolicyCacheBase to the beginning of |caches_|.
|
| - // Does not take ownership of |cache| and listens to OnCacheGoingAway to
|
| - // automatically remove it from |caches_|.
|
| - virtual void PrependCache(CloudPolicyCacheBase* cache) = 0;
|
| + // ConfigurationPolicyProvider implementation.
|
| + virtual bool ProvideInternal(PolicyMap* result) OVERRIDE;
|
| + virtual bool IsInitializationComplete() const OVERRIDE;
|
| + virtual void RefreshPolicies() OVERRIDE;
|
| +
|
| + // CloudPolicyCacheBase::Observer implementation.
|
| + virtual void OnCacheUpdate(CloudPolicyCacheBase* cache) OVERRIDE;
|
| + virtual void OnCacheGoingAway(CloudPolicyCacheBase* cache) OVERRIDE;
|
|
|
| private:
|
| + // Indices of the known caches in |caches_|.
|
| + enum {
|
| + CACHE_USER,
|
| +#if defined(OS_CHROMEOS)
|
| + CACHE_DEVICE,
|
| +#endif
|
| + CACHE_SIZE,
|
| + };
|
| +
|
| + // Merges policies from both caches, and triggers a notification if ready.
|
| + void Merge();
|
| +
|
| + // The device and user policy caches, whose policies are provided by |this|.
|
| + // Both are initially NULL, and the provider only becomes initialized once
|
| + // all the caches are available and ready.
|
| + CloudPolicyCacheBase* caches_[CACHE_SIZE];
|
| +
|
| + // Weak pointer to the connector. Guaranteed to outlive |this|.
|
| + BrowserPolicyConnector* browser_policy_connector_;
|
| +
|
| + // The policy level published by this provider.
|
| + PolicyLevel level_;
|
| +
|
| + // Whether all caches are present and fully initialized.
|
| + bool initialization_complete_;
|
| +
|
| + // Used to determine when updates due to a RefreshPolicies() call have been
|
| + // completed.
|
| + std::set<const CloudPolicyCacheBase*> pending_updates_;
|
| +
|
| + // The currently valid combination of the caches. ProvideInternal() fills
|
| + // |results| with a copy of |combined_|.
|
| + PolicyMap combined_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider);
|
| };
|
|
|
|
|