OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ |
6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "chrome/browser/policy/configuration_policy_provider.h" | 15 #include "chrome/browser/policy/configuration_policy_provider.h" |
16 #include "chrome/browser/policy/device_management_backend.h" | 16 #include "chrome/browser/policy/device_management_backend.h" |
17 #include "chrome/browser/policy/device_token_fetcher.h" | 17 #include "chrome/browser/policy/device_token_fetcher.h" |
18 | 18 |
19 class Profile; | 19 class Profile; |
20 class TokenService; | 20 class TokenService; |
21 | 21 |
22 namespace policy { | 22 namespace policy { |
23 | 23 |
24 class CloudPolicyCache; | |
24 class DeviceManagementBackend; | 25 class DeviceManagementBackend; |
25 class DeviceManagementPolicyCache; | 26 class DeviceManagementPolicyCache; |
26 | 27 |
27 // Provides policy fetched from the device management server. With the exception | 28 // Provides policy fetched from the device management server. With the exception |
28 // of the Provide method, which can be called on the FILE thread, all public | 29 // of the Provide method, which can be called on the FILE thread, all public |
29 // methods must be called on the UI thread. | 30 // methods must be called on the UI thread. |
30 class DeviceManagementPolicyProvider | 31 class DeviceManagementPolicyProvider |
31 : public ConfigurationPolicyProvider, | 32 : public ConfigurationPolicyProvider, |
32 public DeviceManagementBackend::DevicePolicyResponseDelegate, | 33 public DeviceManagementBackend::DevicePolicyResponseDelegate, |
33 public DeviceTokenFetcher::Observer { | 34 public DeviceTokenFetcher::Observer { |
34 public: | 35 public: |
35 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, | 36 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, |
36 DeviceManagementBackend* backend, | 37 DeviceManagementBackend* backend, |
37 Profile* profile); | 38 Profile* profile, |
39 bool cloud_policy_enabled); | |
Mattias Nissler (ping if slow)
2011/02/02 12:27:55
Is this the way to go? I think we should switch ou
Jakob Kummerow
2011/02/03 14:36:52
Done.
| |
38 | 40 |
39 virtual ~DeviceManagementPolicyProvider(); | 41 virtual ~DeviceManagementPolicyProvider(); |
40 | 42 |
41 // ConfigurationPolicyProvider implementation: | 43 // ConfigurationPolicyProvider implementation: |
42 virtual bool Provide(ConfigurationPolicyStoreInterface* store); | 44 virtual bool Provide(ConfigurationPolicyStoreInterface* store); |
43 virtual bool IsInitializationComplete() const; | 45 virtual bool IsInitializationComplete() const; |
44 | 46 |
45 // DevicePolicyResponseDelegate implementation: | 47 // DevicePolicyResponseDelegate implementation: |
46 virtual void HandlePolicyResponse( | 48 virtual void HandlePolicyResponse( |
47 const em::DevicePolicyResponse& response); | 49 const em::DevicePolicyResponse& response); // deprecated. |
50 virtual void HandleCloudPolicyResponse( | |
51 const em::CloudPolicyResponse& response); | |
48 virtual void OnError(DeviceManagementBackend::ErrorCode code); | 52 virtual void OnError(DeviceManagementBackend::ErrorCode code); |
49 | 53 |
50 // DeviceTokenFetcher::Observer implementation: | 54 // DeviceTokenFetcher::Observer implementation: |
51 virtual void OnTokenSuccess(); | 55 virtual void OnTokenSuccess(); |
52 virtual void OnTokenError(); | 56 virtual void OnTokenError(); |
53 virtual void OnNotManaged(); | 57 virtual void OnNotManaged(); |
54 | 58 |
55 // Sets the refresh rate at which to re-fetch policy information. | 59 // Sets the refresh rate at which to re-fetch policy information. |
56 void SetRefreshRate(int64 refresh_rate_milliseconds); | 60 void SetRefreshRate(int64 refresh_rate_milliseconds); |
57 | 61 |
(...skipping 17 matching lines...) Expand all Loading... | |
75 }; | 79 }; |
76 | 80 |
77 class RefreshTask; | 81 class RefreshTask; |
78 | 82 |
79 friend class DeviceManagementPolicyProviderTest; | 83 friend class DeviceManagementPolicyProviderTest; |
80 | 84 |
81 // More configurable constructor for use by test cases. | 85 // More configurable constructor for use by test cases. |
82 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, | 86 DeviceManagementPolicyProvider(const PolicyDefinitionList* policy_list, |
83 DeviceManagementBackend* backend, | 87 DeviceManagementBackend* backend, |
84 Profile* profile, | 88 Profile* profile, |
89 bool cloud_policy_enabled, | |
85 int64 policy_refresh_rate_ms, | 90 int64 policy_refresh_rate_ms, |
86 int policy_refresh_deviation_factor_percent, | 91 int policy_refresh_deviation_factor_percent, |
87 int64 policy_refresh_deviation_max_ms, | 92 int64 policy_refresh_deviation_max_ms, |
88 int64 policy_refresh_error_delay_ms, | 93 int64 policy_refresh_error_delay_ms, |
89 int64 token_fetch_error_delay_ms, | 94 int64 token_fetch_error_delay_ms, |
90 int64 unmanaged_device_refresh_rate_ms); | 95 int64 unmanaged_device_refresh_rate_ms); |
91 | 96 |
92 // Called by constructors to perform shared initialization. Initialization | 97 // Called by constructors to perform shared initialization. Initialization |
93 // requiring the IOThread must not be performed directly in this method, | 98 // requiring the IOThread must not be performed directly in this method, |
94 // rather must be deferred until the IOThread is fully initialized. This is | 99 // rather must be deferred until the IOThread is fully initialized. This is |
95 // the case in InitializeAfterIOThreadExists. | 100 // the case in InitializeAfterIOThreadExists. |
96 void Initialize(DeviceManagementBackend* backend, | 101 void Initialize(DeviceManagementBackend* backend, |
97 Profile* profile, | 102 Profile* profile, |
103 bool cloud_policy_enabled, | |
98 int64 policy_refresh_rate_ms, | 104 int64 policy_refresh_rate_ms, |
99 int policy_refresh_deviation_factor_percent, | 105 int policy_refresh_deviation_factor_percent, |
100 int64 policy_refresh_deviation_max_ms, | 106 int64 policy_refresh_deviation_max_ms, |
101 int64 policy_refresh_error_delay_ms, | 107 int64 policy_refresh_error_delay_ms, |
102 int64 token_fetch_error_delay_ms, | 108 int64 token_fetch_error_delay_ms, |
103 int64 unmanaged_device_refresh_rate_ms); | 109 int64 unmanaged_device_refresh_rate_ms); |
104 | 110 |
105 // ConfigurationPolicyProvider overrides: | 111 // ConfigurationPolicyProvider overrides: |
106 virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer); | 112 virtual void AddObserver(ConfigurationPolicyProvider::Observer* observer); |
107 virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer); | 113 virtual void RemoveObserver(ConfigurationPolicyProvider::Observer* observer); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 // backend. | 145 // backend. |
140 static std::string GetDeviceManagementURL(); | 146 static std::string GetDeviceManagementURL(); |
141 | 147 |
142 // Returns the path to the sub-directory in the user data directory | 148 // Returns the path to the sub-directory in the user data directory |
143 // in which device management persistent state is stored. | 149 // in which device management persistent state is stored. |
144 static FilePath GetOrCreateDeviceManagementDir( | 150 static FilePath GetOrCreateDeviceManagementDir( |
145 const FilePath& user_data_dir); | 151 const FilePath& user_data_dir); |
146 | 152 |
147 scoped_ptr<DeviceManagementBackend> backend_; | 153 scoped_ptr<DeviceManagementBackend> backend_; |
148 Profile* profile_; // weak | 154 Profile* profile_; // weak |
149 scoped_ptr<DeviceManagementPolicyCache> cache_; | 155 scoped_ptr<DeviceManagementPolicyCache> cache_; // deprecated |
156 scoped_ptr<CloudPolicyCache> cache2_; | |
gfeher
2011/02/02 08:42:45
I suggest calling this cache_ and naming the previ
Mattias Nissler (ping if slow)
2011/02/02 12:27:55
I'm also not too sure about this. Thing is that th
Jakob Kummerow
2011/02/03 14:36:52
Done.
| |
157 bool cloud_policy_enabled_; | |
150 scoped_refptr<DeviceTokenFetcher> token_fetcher_; | 158 scoped_refptr<DeviceTokenFetcher> token_fetcher_; |
151 DeviceTokenFetcher::ObserverRegistrar registrar_; | 159 DeviceTokenFetcher::ObserverRegistrar registrar_; |
152 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; | 160 ObserverList<ConfigurationPolicyProvider::Observer, true> observer_list_; |
153 FilePath storage_dir_; | 161 FilePath storage_dir_; |
154 ProviderState state_; | 162 ProviderState state_; |
155 bool initial_fetch_done_; | 163 bool initial_fetch_done_; |
156 RefreshTask* refresh_task_; | 164 RefreshTask* refresh_task_; |
157 int64 policy_refresh_rate_ms_; | 165 int64 policy_refresh_rate_ms_; |
158 int policy_refresh_deviation_factor_percent_; | 166 int policy_refresh_deviation_factor_percent_; |
159 int64 policy_refresh_deviation_max_ms_; | 167 int64 policy_refresh_deviation_max_ms_; |
160 int64 policy_refresh_error_delay_ms_; | 168 int64 policy_refresh_error_delay_ms_; |
161 int64 effective_policy_refresh_error_delay_ms_; | 169 int64 effective_policy_refresh_error_delay_ms_; |
162 int64 token_fetch_error_delay_ms_; | 170 int64 token_fetch_error_delay_ms_; |
163 int64 effective_token_fetch_error_delay_ms_; | 171 int64 effective_token_fetch_error_delay_ms_; |
164 int64 unmanaged_device_refresh_rate_ms_; | 172 int64 unmanaged_device_refresh_rate_ms_; |
165 | 173 |
166 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); | 174 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); |
167 }; | 175 }; |
168 | 176 |
169 } // namespace policy | 177 } // namespace policy |
170 | 178 |
171 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ | 179 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ |
OLD | NEW |