blob: bc3705256686c34232636b06b7e74d9a15e6cabd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_
#define CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_
#include <set>
#include "base/basictypes.h"
#include "chrome/browser/policy/cloud_policy_cache_base.h"
#include "chrome/browser/policy/configuration_policy_provider.h"
namespace policy {
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(BrowserPolicyConnector* connector);
virtual ~CloudPolicyProvider();
// 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
// ConfigurationPolicyProvider implementation.
virtual void Shutdown() 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_;
// 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_;
DISALLOW_COPY_AND_ASSIGN(CloudPolicyProvider);
};
} // namespace policy
#endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_PROVIDER_H_
|