| 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_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_H_ |
| 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 // Attempts to register with the device management service. Results in a | 98 // Attempts to register with the device management service. Results in a |
| 99 // registration change or error notification. | 99 // registration change or error notification. |
| 100 virtual void Register( | 100 virtual void Register( |
| 101 enterprise_management::DeviceRegisterRequest::Type registration_type, | 101 enterprise_management::DeviceRegisterRequest::Type registration_type, |
| 102 const std::string& auth_token, | 102 const std::string& auth_token, |
| 103 const std::string& client_id, | 103 const std::string& client_id, |
| 104 bool is_auto_enrollment, | 104 bool is_auto_enrollment, |
| 105 const std::string& requisition); | 105 const std::string& requisition); |
| 106 | 106 |
| 107 // Sets information about a policy invalidation. Subsequent fetch operations |
| 108 // will use the given info, and callers can use fetched_invalidation_version |
| 109 // to determine which version of policy was fetched. |
| 110 void SetInvalidationInfo(int64 version, const std::string& payload); |
| 111 |
| 107 // Requests a policy fetch. The client being registered is a prerequisite to | 112 // Requests a policy fetch. The client being registered is a prerequisite to |
| 108 // this operation and this call will CHECK if the client is not in registered | 113 // this operation and this call will CHECK if the client is not in registered |
| 109 // state. FetchPolicy() triggers a policy fetch from the cloud. A policy | 114 // state. FetchPolicy() triggers a policy fetch from the cloud. A policy |
| 110 // change notification is reported to the observers and the new policy blob | 115 // change notification is reported to the observers and the new policy blob |
| 111 // can be retrieved once the policy fetch operation completes. In case of | 116 // can be retrieved once the policy fetch operation completes. In case of |
| 112 // multiple requests to fetch policy, new requests will cancel any pending | 117 // multiple requests to fetch policy, new requests will cancel any pending |
| 113 // requests and the latest request will eventually trigger notifications. | 118 // requests and the latest request will eventually trigger notifications. |
| 114 virtual void FetchPolicy(); | 119 virtual void FetchPolicy(); |
| 115 | 120 |
| 116 // Requests OAuth2 auth codes for the device robot account. The client being | 121 // Requests OAuth2 auth codes for the device robot account. The client being |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 const PolicyNamespaceKey& policy_ns_key) const; | 184 const PolicyNamespaceKey& policy_ns_key) const; |
| 180 | 185 |
| 181 DeviceManagementStatus status() const { | 186 DeviceManagementStatus status() const { |
| 182 return status_; | 187 return status_; |
| 183 } | 188 } |
| 184 | 189 |
| 185 const std::string& robot_api_auth_code() const { | 190 const std::string& robot_api_auth_code() const { |
| 186 return robot_api_auth_code_; | 191 return robot_api_auth_code_; |
| 187 } | 192 } |
| 188 | 193 |
| 194 // Returns the invalidation version that was used for the last FetchPolicy. |
| 195 // Observers can call this method from their OnPolicyFetched method to |
| 196 // determine which at which invalidation version the policy was fetched. |
| 197 int64 fetched_invalidation_version() const { |
| 198 return fetched_invalidation_version_; |
| 199 } |
| 200 |
| 189 protected: | 201 protected: |
| 190 // A set of PolicyNamespaceKeys to fetch. | 202 // A set of PolicyNamespaceKeys to fetch. |
| 191 typedef std::set<PolicyNamespaceKey> NamespaceSet; | 203 typedef std::set<PolicyNamespaceKey> NamespaceSet; |
| 192 | 204 |
| 193 // Callback for retries of registration requests. | 205 // Callback for retries of registration requests. |
| 194 void OnRetryRegister(DeviceManagementRequestJob* job); | 206 void OnRetryRegister(DeviceManagementRequestJob* job); |
| 195 | 207 |
| 196 // Callback for registration requests. | 208 // Callback for registration requests. |
| 197 void OnRegisterCompleted( | 209 void OnRegisterCompleted( |
| 198 DeviceManagementStatus status, | 210 DeviceManagementStatus status, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 250 |
| 239 std::string dm_token_; | 251 std::string dm_token_; |
| 240 DeviceMode device_mode_; | 252 DeviceMode device_mode_; |
| 241 std::string client_id_; | 253 std::string client_id_; |
| 242 bool submit_machine_id_; | 254 bool submit_machine_id_; |
| 243 base::Time last_policy_timestamp_; | 255 base::Time last_policy_timestamp_; |
| 244 int public_key_version_; | 256 int public_key_version_; |
| 245 bool public_key_version_valid_; | 257 bool public_key_version_valid_; |
| 246 std::string robot_api_auth_code_; | 258 std::string robot_api_auth_code_; |
| 247 | 259 |
| 260 // Information for the latest policy invalidation received. |
| 261 int64 invalidation_version_; |
| 262 std::string invalidation_payload_; |
| 263 |
| 264 // The invalidation version used for the most recent fetch operation. |
| 265 int64 fetched_invalidation_version_; |
| 266 |
| 248 // Used for issuing requests to the cloud. | 267 // Used for issuing requests to the cloud. |
| 249 DeviceManagementService* service_; | 268 DeviceManagementService* service_; |
| 250 scoped_ptr<DeviceManagementRequestJob> request_job_; | 269 scoped_ptr<DeviceManagementRequestJob> request_job_; |
| 251 | 270 |
| 252 // Status upload data is produced by |status_provider_|. | 271 // Status upload data is produced by |status_provider_|. |
| 253 StatusProvider* status_provider_; | 272 StatusProvider* status_provider_; |
| 254 | 273 |
| 255 // The policy responses returned by the last policy fetch operation. | 274 // The policy responses returned by the last policy fetch operation. |
| 256 ResponseMap responses_; | 275 ResponseMap responses_; |
| 257 DeviceManagementStatus status_; | 276 DeviceManagementStatus status_; |
| 258 | 277 |
| 259 ObserverList<Observer, true> observers_; | 278 ObserverList<Observer, true> observers_; |
| 260 | 279 |
| 261 private: | 280 private: |
| 262 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); | 281 DISALLOW_COPY_AND_ASSIGN(CloudPolicyClient); |
| 263 }; | 282 }; |
| 264 | 283 |
| 265 } // namespace policy | 284 } // namespace policy |
| 266 | 285 |
| 267 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_H_ | 286 #endif // CHROME_BROWSER_POLICY_CLOUD_CLOUD_POLICY_CLIENT_H_ |
| OLD | NEW |