OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 | 49 |
50 // DeviceTokenFetcher::Observer implementation: | 50 // DeviceTokenFetcher::Observer implementation: |
51 void OnTokenSuccess(); | 51 void OnTokenSuccess(); |
52 void OnTokenError(); | 52 void OnTokenError(); |
53 void OnNotManaged(); | 53 void OnNotManaged(); |
54 | 54 |
55 // True if a policy request has been sent to the device management backend | 55 // True if a policy request has been sent to the device management backend |
56 // server and no response or error has yet been received. | 56 // server and no response or error has yet been received. |
57 bool IsPolicyRequestPending() const { return policy_request_pending_; } | 57 bool IsPolicyRequestPending() const { return policy_request_pending_; } |
58 | 58 |
59 // Returns true if the policy cache is empty and hence no policies are | 59 // Returns true if the device management policy provider is currently waiting |
60 // available. | 60 // for the first attempt to fetch policies to complete. |
markusheintz_
2010/11/25 17:49:44
Should we mention that the method also returns tru
Jakob Kummerow
2010/11/26 09:17:23
Strictly speaking, yes. But the request is issued
| |
61 bool IsPolicyCacheEmpty() const; | |
62 | |
63 // Returns true if the device management policy provider has an empty policy | |
64 // cache and is waiting for a pending policy request to retrive the inital | |
65 // set of policies. If cached policies are available false is returned even in | |
66 // the case of a pending policy request. | |
67 bool WaitingForInitialPolicies() const; | 61 bool WaitingForInitialPolicies() const; |
68 | 62 |
69 // Tells the provider that the passed in token service reference is about to | 63 // Tells the provider that the passed in token service reference is about to |
70 // become invalid. | 64 // become invalid. |
71 void Shutdown(); | 65 void Shutdown(); |
72 | 66 |
73 private: | 67 private: |
74 class InitializeAfterIOThreadExistsTask; | 68 class InitializeAfterIOThreadExistsTask; |
75 class RefreshTask; | 69 class RefreshTask; |
76 | 70 |
(...skipping 16 matching lines...) Expand all Loading... | |
93 // Triggers policy refresh, re-requesting device token and policy information | 87 // Triggers policy refresh, re-requesting device token and policy information |
94 // as necessary. | 88 // as necessary. |
95 void RefreshTaskExecute(); | 89 void RefreshTaskExecute(); |
96 | 90 |
97 // Schedules a new RefreshTask. | 91 // Schedules a new RefreshTask. |
98 void ScheduleRefreshTask(int64 delay_in_milliseconds); | 92 void ScheduleRefreshTask(int64 delay_in_milliseconds); |
99 | 93 |
100 // Calculates when the next RefreshTask shall be executed. | 94 // Calculates when the next RefreshTask shall be executed. |
101 int64 GetRefreshTaskDelay(); | 95 int64 GetRefreshTaskDelay(); |
102 | 96 |
97 void StopWaitingForInitialPolicies(); | |
98 | |
103 #if defined(OS_CHROMEOS) | 99 #if defined(OS_CHROMEOS) |
104 // Sent a CLOUD_POLICY_UPDATE notification. | 100 // Sent a CLOUD_POLICY_UPDATE notification. |
105 void NotifyCloudPolicyUpdate() const; | 101 void NotifyCloudPolicyUpdate() const; |
106 #endif | 102 #endif |
107 | 103 |
104 static FilePath GetUnmanagedDeviceMarkerPath(const FilePath& storage_dir); | |
105 static void CreateUnmanagedDeviceMarker(const FilePath& storage_dir, | |
106 const base::Time& timestamp); | |
107 static void DeleteUnmanagedDeviceMarker(const FilePath& storage_dir); | |
108 bool UnmanagedDeviceMarkerExists(); | |
109 base::Time GetUnmanagedDeviceTimestamp(); | |
110 | |
108 // Provides the URL at which requests are sent to from the device management | 111 // Provides the URL at which requests are sent to from the device management |
109 // backend. | 112 // backend. |
110 static std::string GetDeviceManagementURL(); | 113 static std::string GetDeviceManagementURL(); |
111 | 114 |
112 // Returns the path to the sub-directory in the user data directory | 115 // Returns the path to the sub-directory in the user data directory |
113 // in which device management persistent state is stored. | 116 // in which device management persistent state is stored. |
114 static FilePath GetOrCreateDeviceManagementDir( | 117 static FilePath GetOrCreateDeviceManagementDir( |
115 const FilePath& user_data_dir); | 118 const FilePath& user_data_dir); |
116 | 119 |
117 // Give unit tests the ability to override timeout settings. | 120 // Give unit tests the ability to override timeout settings. |
118 void set_policy_refresh_rate_ms(int64 policy_refresh_rate_ms) { | 121 void set_policy_refresh_rate_ms(int64 policy_refresh_rate_ms) { |
119 policy_refresh_rate_ms_ = policy_refresh_rate_ms; | 122 policy_refresh_rate_ms_ = policy_refresh_rate_ms; |
120 } | 123 } |
121 void set_policy_refresh_max_earlier_ms(int64 policy_refresh_max_earlier_ms) { | 124 void set_policy_refresh_max_earlier_ms(int64 policy_refresh_max_earlier_ms) { |
122 policy_refresh_max_earlier_ms_ = policy_refresh_max_earlier_ms; | 125 policy_refresh_max_earlier_ms_ = policy_refresh_max_earlier_ms; |
123 } | 126 } |
124 void set_policy_refresh_error_delay_ms(int64 policy_refresh_error_delay_ms) { | 127 void set_policy_refresh_error_delay_ms(int64 policy_refresh_error_delay_ms) { |
125 policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms; | 128 policy_refresh_error_delay_ms_ = policy_refresh_error_delay_ms; |
126 } | 129 } |
127 void set_token_fetch_error_delay_ms(int64 token_fetch_error_delay_ms) { | 130 void set_token_fetch_error_delay_ms(int64 token_fetch_error_delay_ms) { |
128 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms; | 131 token_fetch_error_delay_ms_ = token_fetch_error_delay_ms; |
129 } | 132 } |
133 void set_unmanaged_device_refresh_rate_ms( | |
134 int64 unmanaged_device_refresh_rate_ms) { | |
135 unmanaged_device_refresh_rate_ms_ = unmanaged_device_refresh_rate_ms; | |
danno
2010/11/25 16:35:01
Can you use a new private/protected constructor fo
Jakob Kummerow
2010/11/26 09:17:23
Done.
| |
136 } | |
130 | 137 |
131 scoped_ptr<DeviceManagementBackend> backend_; | 138 scoped_ptr<DeviceManagementBackend> backend_; |
132 TokenService* token_service_; // weak | 139 TokenService* token_service_; // weak |
133 scoped_ptr<DeviceManagementPolicyCache> cache_; | 140 scoped_ptr<DeviceManagementPolicyCache> cache_; |
134 scoped_refptr<DeviceTokenFetcher> token_fetcher_; | 141 scoped_refptr<DeviceTokenFetcher> token_fetcher_; |
135 DeviceTokenFetcher::ObserverRegistrar registrar_; | 142 DeviceTokenFetcher::ObserverRegistrar registrar_; |
136 FilePath storage_dir_; | 143 FilePath storage_dir_; |
137 bool policy_request_pending_; | 144 bool policy_request_pending_; |
138 bool refresh_task_pending_; | 145 bool refresh_task_pending_; |
146 bool waiting_for_initial_policies_; | |
139 int64 policy_refresh_rate_ms_; | 147 int64 policy_refresh_rate_ms_; |
140 int64 policy_refresh_max_earlier_ms_; | 148 int64 policy_refresh_max_earlier_ms_; |
141 int64 policy_refresh_error_delay_ms_; | 149 int64 policy_refresh_error_delay_ms_; |
142 int64 token_fetch_error_delay_ms_; | 150 int64 token_fetch_error_delay_ms_; |
151 int64 unmanaged_device_refresh_rate_ms_; | |
143 | 152 |
144 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); | 153 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyProvider); |
145 }; | 154 }; |
146 | 155 |
147 } // namespace policy | 156 } // namespace policy |
148 | 157 |
149 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ | 158 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_POLICY_PROVIDER_H_ |
OLD | NEW |