OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
14 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
15 #include "chrome/browser/policy/cloud/cloud_policy_core.h" | 16 #include "chrome/browser/policy/cloud/cloud_policy_core.h" |
16 #include "chrome/browser/policy/cloud/cloud_policy_store.h" | 17 #include "chrome/browser/policy/cloud/cloud_policy_store.h" |
| 18 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" |
17 #include "chrome/browser/policy/configuration_policy_provider.h" | 19 #include "chrome/browser/policy/configuration_policy_provider.h" |
18 | 20 |
19 namespace base { | 21 namespace base { |
| 22 class FilePath; |
20 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
21 } | 24 } |
22 | 25 |
| 26 namespace net { |
| 27 class URLRequestContextGetter; |
| 28 } |
| 29 |
23 namespace policy { | 30 namespace policy { |
24 | 31 |
25 class PolicyBundle; | |
26 | |
27 // CloudPolicyManager is the main switching central between cloud policy and the | 32 // CloudPolicyManager is the main switching central between cloud policy and the |
28 // upper layers of the policy stack. It wires up a CloudPolicyCore to the | 33 // upper layers of the policy stack. It wires up a CloudPolicyCore to the |
29 // ConfigurationPolicyProvider interface. | 34 // ConfigurationPolicyProvider interface. |
30 // | 35 // |
31 // This class contains the base functionality, there are subclasses that add | 36 // This class contains the base functionality, there are subclasses that add |
32 // functionality specific to user-level and device-level cloud policy, such as | 37 // functionality specific to user-level and device-level cloud policy, such as |
33 // blocking on initial user policy fetch or device enrollment. | 38 // blocking on initial user policy fetch or device enrollment. |
34 class CloudPolicyManager : public ConfigurationPolicyProvider, | 39 class CloudPolicyManager : public ConfigurationPolicyProvider, |
35 public CloudPolicyStore::Observer { | 40 public CloudPolicyStore::Observer, |
| 41 public ComponentCloudPolicyService::Delegate { |
36 public: | 42 public: |
37 // |task_runner| is the runner for policy refresh tasks. | 43 // |task_runner| is the runner for policy refresh tasks. |
| 44 // |file_task_runner| is used for file operations. Currently this must be the |
| 45 // FILE BrowserThread. |
| 46 // |io_task_runner| is used for network IO. Currently this must be the IO |
| 47 // BrowserThread. |
38 CloudPolicyManager( | 48 CloudPolicyManager( |
39 const PolicyNamespaceKey& policy_ns_key, | 49 const PolicyNamespaceKey& policy_ns_key, |
40 CloudPolicyStore* cloud_policy_store, | 50 CloudPolicyStore* cloud_policy_store, |
41 const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 51 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 52 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
| 53 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
42 virtual ~CloudPolicyManager(); | 54 virtual ~CloudPolicyManager(); |
43 | 55 |
44 CloudPolicyCore* core() { return &core_; } | 56 CloudPolicyCore* core() { return &core_; } |
45 const CloudPolicyCore* core() const { return &core_; } | 57 const CloudPolicyCore* core() const { return &core_; } |
46 | 58 |
47 // ConfigurationPolicyProvider: | 59 // ConfigurationPolicyProvider: |
48 virtual void Shutdown() OVERRIDE; | 60 virtual void Shutdown() OVERRIDE; |
49 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | 61 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; |
50 virtual void RefreshPolicies() OVERRIDE; | 62 virtual void RefreshPolicies() OVERRIDE; |
51 | 63 |
52 // CloudPolicyStore::Observer: | 64 // CloudPolicyStore::Observer: |
53 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; | 65 virtual void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) OVERRIDE; |
54 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; | 66 virtual void OnStoreError(CloudPolicyStore* cloud_policy_store) OVERRIDE; |
55 | 67 |
| 68 // ComponentCloudPolicyService::Delegate: |
| 69 virtual void OnComponentCloudPolicyUpdated() OVERRIDE; |
| 70 |
56 protected: | 71 protected: |
57 // Check whether fully initialized and if so, publish policy by calling | 72 // Check whether fully initialized and if so, publish policy by calling |
58 // ConfigurationPolicyStore::UpdatePolicy(). | 73 // ConfigurationPolicyStore::UpdatePolicy(). |
59 void CheckAndPublishPolicy(); | 74 void CheckAndPublishPolicy(); |
60 | 75 |
61 // Called by CheckAndPublishPolicy() to create a bundle with the current | 76 void CreateComponentCloudPolicyService( |
62 // policies. | 77 const base::FilePath& policy_cache_path, |
63 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle(); | 78 const scoped_refptr<net::URLRequestContextGetter>& request_context); |
64 | 79 |
65 // Convenience accessors to core() components. | 80 // Convenience accessors to core() components. |
66 CloudPolicyClient* client() { return core_.client(); } | 81 CloudPolicyClient* client() { return core_.client(); } |
67 const CloudPolicyClient* client() const { return core_.client(); } | 82 const CloudPolicyClient* client() const { return core_.client(); } |
68 CloudPolicyStore* store() { return core_.store(); } | 83 CloudPolicyStore* store() { return core_.store(); } |
69 const CloudPolicyStore* store() const { return core_.store(); } | 84 const CloudPolicyStore* store() const { return core_.store(); } |
70 CloudPolicyService* service() { return core_.service(); } | 85 CloudPolicyService* service() { return core_.service(); } |
71 const CloudPolicyService* service() const { return core_.service(); } | 86 const CloudPolicyService* service() const { return core_.service(); } |
| 87 ComponentCloudPolicyService* component_policy_service() const { |
| 88 return component_policy_service_.get(); |
| 89 } |
72 | 90 |
73 private: | 91 private: |
74 // Completion handler for policy refresh operations. | 92 // Completion handler for policy refresh operations. |
75 void OnRefreshComplete(bool success); | 93 void OnRefreshComplete(bool success); |
76 | 94 |
77 CloudPolicyCore core_; | 95 CloudPolicyCore core_; |
| 96 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; |
78 | 97 |
79 // Whether there's a policy refresh operation pending, in which case all | 98 // Whether there's a policy refresh operation pending, in which case all |
80 // policy update notifications are deferred until after it completes. | 99 // policy update notifications are deferred until after it completes. |
81 bool waiting_for_policy_refresh_; | 100 bool waiting_for_policy_refresh_; |
82 | 101 |
| 102 scoped_refptr<base::SequencedTaskRunner> file_task_runner_; |
| 103 scoped_refptr<base::SequencedTaskRunner> io_task_runner_; |
| 104 |
83 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); | 105 DISALLOW_COPY_AND_ASSIGN(CloudPolicyManager); |
84 }; | 106 }; |
85 | 107 |
86 } // namespace policy | 108 } // namespace policy |
87 | 109 |
88 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ | 110 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_MANAGER_H_ |
OLD | NEW |