OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_MANAGER_H_ | |
6 #define CHROME_BROWSER_POLICY_CLOUD_POLICY_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/prefs/public/pref_member.h" | |
13 #include "chrome/browser/policy/cloud_policy_constants.h" | |
14 #include "chrome/browser/policy/cloud_policy_core.h" | |
15 #include "chrome/browser/policy/cloud_policy_store.h" | |
16 #include "chrome/browser/policy/configuration_policy_provider.h" | |
17 | |
18 namespace policy { | |
19 | |
20 class PolicyBundle; | |
21 | |
22 // CloudPolicyManager is the main switching central between cloud policy and the | |
23 // upper layers of the policy stack. It wires up a CloudPolicyCore to the | |
24 // ConfigurationPolicyProvider interface. | |
25 // | |
26 // This class contains the base functionality, there are subclasses that add | |
27 // functionality specific to user-level and device-level cloud policy, such as | |
28 // blocking on initial user policy fetch or device enrollment. | |
29 class CloudPolicyManager : public ConfigurationPolicyProvider, | |
30 public CloudPolicyStore::Observer { | |
31 public: | |
32 CloudPolicyManager(const PolicyNamespaceKey& policy_ns_key, | |
33 CloudPolicyStore* cloud_policy_store); | |
34 virtual ~CloudPolicyManager(); | |
35 | |
36 CloudPolicyCore* core() { return &core_; } | |
37 const CloudPolicyCore* core() const { return &core_; } | |
38 | |
39 // ConfigurationPolicyProvider: | |
40 virtual void Shutdown() OVERRIDE; | |
41 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | |
42 virtual void RefreshPolicies() OVERRIDE; | |
43 | |
44 // CloudPolicyStore::Observer: | |
45 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; | |
46 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; | |
47 | |
48 protected: | |
49 // Check whether fully initialized and if so, publish policy by calling | |
50 // ConfigurationPolicyStore::UpdatePolicy(). | |
51 void CheckAndPublishPolicy(); | |
52 | |
53 // Called by CheckAndPublishPolicy() to create a bundle with the current | |
54 // policies. | |
55 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle(); | |
56 | |
57 // Convenience accessors to core() components. | |
58 CloudPolicyClient* client() { return core_.client(); } | |
59 const CloudPolicyClient* client() const { return core_.client(); } | |
60 CloudPolicyStore* store() { return core_.store(); } | |
61 const CloudPolicyStore* store() const { return core_.store(); } | |
62 CloudPolicyService* service() { return core_.service(); } | |
63 const CloudPolicyService* service() const { return core_.service(); } | |
64 | |
65 private: | |
66 // Completion handler for policy refresh operations. | |
67 void OnRefreshComplete(bool success); | |
68 | |
69 CloudPolicyCore core_; | |
70 | |
71 // Whether there's a policy refresh operation pending, in which case all | |
72 // policy update notifications are deferred until after it completes. | |
73 bool waiting_for_policy_refresh_; | |
74 | |
75 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); | |
76 }; | |
77 | |
78 } // namespace policy | |
79 | |
80 #endif // CHROME_BROWSER_POLICY_CLOUD_POLICY_MANAGER_H_ | |
OLD | NEW |