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_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_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/memory/scoped_ptr.h" |
14 #include "chrome/browser/policy/cloud/cloud_policy_client.h" | 14 #include "chrome/browser/policy/cloud/cloud_policy_client.h" |
15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 15 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
16 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" | 16 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
17 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 17 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
18 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" | 18 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" |
19 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 19 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
20 #include "google_apis/gaia/gaia_auth_consumer.h" | 20 #include "google_apis/gaia/gaia_auth_consumer.h" |
21 | 21 |
22 class PrefService; | 22 class PrefService; |
| 23 class Profile; |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
26 } | 27 } |
27 | 28 |
28 namespace policy { | 29 namespace policy { |
29 | 30 |
30 class DeviceManagementService; | 31 class DeviceManagementService; |
31 class ResourceCache; | 32 class ResourceCache; |
32 class PolicyOAuth2TokenFetcher; | 33 class PolicyOAuth2TokenFetcher; |
33 | 34 |
34 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy | 35 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy |
35 // on Chrome OS. | 36 // on Chrome OS. |
36 class UserCloudPolicyManagerChromeOS | 37 class UserCloudPolicyManagerChromeOS |
37 : public CloudPolicyManager, | 38 : public CloudPolicyManager, |
38 public CloudPolicyClient::Observer, | 39 public CloudPolicyClient::Observer, |
39 public CloudPolicyService::Observer, | 40 public CloudPolicyService::Observer, |
40 public ComponentCloudPolicyService::Delegate, | 41 public ComponentCloudPolicyService::Delegate, |
41 public BrowserContextKeyedService { | 42 public BrowserContextKeyedService { |
42 public: | 43 public: |
43 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return | 44 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return |
44 // false as long as there hasn't been a successful policy fetch. | 45 // false as long as there hasn't been a successful policy fetch. |
45 UserCloudPolicyManagerChromeOS( | 46 UserCloudPolicyManagerChromeOS( |
| 47 Profile* profile, |
46 scoped_ptr<CloudPolicyStore> store, | 48 scoped_ptr<CloudPolicyStore> store, |
47 scoped_ptr<ResourceCache> resource_cache, | 49 scoped_ptr<ResourceCache> resource_cache, |
48 bool wait_for_policy_fetch); | 50 bool wait_for_policy_fetch); |
49 virtual ~UserCloudPolicyManagerChromeOS(); | 51 virtual ~UserCloudPolicyManagerChromeOS(); |
50 | 52 |
51 // Initializes the cloud connection. |local_state| and | 53 // Initializes the cloud connection. |local_state| and |
52 // |device_management_service| must stay valid until this object is deleted. | 54 // |device_management_service| must stay valid until this object is deleted. |
53 void Connect(PrefService* local_state, | 55 void Connect(PrefService* local_state, |
54 DeviceManagementService* device_management_service, | 56 DeviceManagementService* device_management_service, |
55 scoped_refptr<net::URLRequestContextGetter> request_context, | 57 scoped_refptr<net::URLRequestContextGetter> request_context, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // successful. | 104 // successful. |
103 void OnInitialPolicyFetchComplete(bool success); | 105 void OnInitialPolicyFetchComplete(bool success); |
104 | 106 |
105 // Cancels waiting for the policy fetch and flags the | 107 // Cancels waiting for the policy fetch and flags the |
106 // ConfigurationPolicyProvider ready (assuming all other initialization tasks | 108 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
107 // have completed). | 109 // have completed). |
108 void CancelWaitForPolicyFetch(); | 110 void CancelWaitForPolicyFetch(); |
109 | 111 |
110 void StartRefreshScheduler(); | 112 void StartRefreshScheduler(); |
111 | 113 |
| 114 // The profile this instance belongs to. |
| 115 Profile* profile_; |
| 116 |
112 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. | 117 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. |
113 scoped_ptr<CloudPolicyStore> store_; | 118 scoped_ptr<CloudPolicyStore> store_; |
114 | 119 |
115 // Handles fetching and storing cloud policy for components. It uses the | 120 // Handles fetching and storing cloud policy for components. It uses the |
116 // |store_|, so destroy it first. | 121 // |store_|, so destroy it first. |
117 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; | 122 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; |
118 | 123 |
119 // Whether to wait for a policy fetch to complete before reporting | 124 // Whether to wait for a policy fetch to complete before reporting |
120 // IsInitializationComplete(). | 125 // IsInitializationComplete(). |
121 bool wait_for_policy_fetch_; | 126 bool wait_for_policy_fetch_; |
122 | 127 |
123 // The pref service to pass to the refresh scheduler on initialization. | 128 // The pref service to pass to the refresh scheduler on initialization. |
124 PrefService* local_state_; | 129 PrefService* local_state_; |
125 | 130 |
126 // Used to fetch the policy OAuth token, when necessary. This object holds | 131 // Used to fetch the policy OAuth token, when necessary. This object holds |
127 // a callback with an unretained reference to the manager, when it exists. | 132 // a callback with an unretained reference to the manager, when it exists. |
128 scoped_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; | 133 scoped_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; |
129 | 134 |
130 // The OAuth2 login tokens fetched by the |token_fetcher_|, which can be | 135 // The OAuth2 login tokens fetched by the |token_fetcher_|, which can be |
131 // retrieved using oauth2_tokens(). | 136 // retrieved using oauth2_tokens(). |
132 GaiaAuthConsumer::ClientOAuthResult oauth2_login_tokens_; | 137 GaiaAuthConsumer::ClientOAuthResult oauth2_login_tokens_; |
133 | 138 |
134 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); | 139 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); |
135 }; | 140 }; |
136 | 141 |
137 } // namespace policy | 142 } // namespace policy |
138 | 143 |
139 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 144 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
OLD | NEW |