| 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 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 5 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } // namespace | 48 } // namespace |
| 49 | 49 |
| 50 CloudPolicyClient::Observer::~Observer() {} | 50 CloudPolicyClient::Observer::~Observer() {} |
| 51 | 51 |
| 52 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched( | 52 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched( |
| 53 CloudPolicyClient* client) {} | 53 CloudPolicyClient* client) {} |
| 54 | 54 |
| 55 CloudPolicyClient::CloudPolicyClient( | 55 CloudPolicyClient::CloudPolicyClient( |
| 56 const std::string& machine_id, | 56 const std::string& machine_id, |
| 57 const std::string& machine_model, | 57 const std::string& machine_model, |
| 58 const std::string& verification_key_hash, | |
| 59 DeviceManagementService* service, | 58 DeviceManagementService* service, |
| 60 scoped_refptr<net::URLRequestContextGetter> request_context, | 59 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 61 SigningService* signing_service) | 60 SigningService* signing_service) |
| 62 : machine_id_(machine_id), | 61 : machine_id_(machine_id), |
| 63 machine_model_(machine_model), | 62 machine_model_(machine_model), |
| 64 verification_key_hash_(verification_key_hash), | |
| 65 service_(service), // Can be null for unit tests. | 63 service_(service), // Can be null for unit tests. |
| 66 signing_service_(signing_service), | 64 signing_service_(signing_service), |
| 67 request_context_(request_context), | 65 request_context_(request_context), |
| 68 weak_ptr_factory_(this) { | 66 weak_ptr_factory_(this) { |
| 69 } | 67 } |
| 70 | 68 |
| 71 CloudPolicyClient::~CloudPolicyClient() { | 69 CloudPolicyClient::~CloudPolicyClient() { |
| 72 } | 70 } |
| 73 | 71 |
| 74 void CloudPolicyClient::SetupRegistration(const std::string& dm_token, | 72 void CloudPolicyClient::SetupRegistration(const std::string& dm_token, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 em::PolicyFetchRequest* fetch_request = policy_request->add_request(); | 224 em::PolicyFetchRequest* fetch_request = policy_request->add_request(); |
| 227 fetch_request->set_policy_type(type_to_fetch.first); | 225 fetch_request->set_policy_type(type_to_fetch.first); |
| 228 if (!type_to_fetch.second.empty()) | 226 if (!type_to_fetch.second.empty()) |
| 229 fetch_request->set_settings_entity_id(type_to_fetch.second); | 227 fetch_request->set_settings_entity_id(type_to_fetch.second); |
| 230 | 228 |
| 231 // Request signed policy blobs to help prevent tampering on the client. | 229 // Request signed policy blobs to help prevent tampering on the client. |
| 232 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); | 230 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); |
| 233 if (public_key_version_valid_) | 231 if (public_key_version_valid_) |
| 234 fetch_request->set_public_key_version(public_key_version_); | 232 fetch_request->set_public_key_version(public_key_version_); |
| 235 | 233 |
| 236 if (!verification_key_hash_.empty()) | 234 fetch_request->set_verification_key_hash(kPolicyVerificationKeyHash); |
| 237 fetch_request->set_verification_key_hash(verification_key_hash_); | |
| 238 | 235 |
| 239 // These fields are included only in requests for chrome policy. | 236 // These fields are included only in requests for chrome policy. |
| 240 if (IsChromePolicy(type_to_fetch.first)) { | 237 if (IsChromePolicy(type_to_fetch.first)) { |
| 241 if (submit_machine_id_ && !machine_id_.empty()) | 238 if (submit_machine_id_ && !machine_id_.empty()) |
| 242 fetch_request->set_machine_id(machine_id_); | 239 fetch_request->set_machine_id(machine_id_); |
| 243 if (!last_policy_timestamp_.is_null()) { | 240 if (!last_policy_timestamp_.is_null()) { |
| 244 base::TimeDelta timestamp( | 241 base::TimeDelta timestamp( |
| 245 last_policy_timestamp_ - base::Time::UnixEpoch()); | 242 last_policy_timestamp_ - base::Time::UnixEpoch()); |
| 246 fetch_request->set_timestamp(timestamp.InMilliseconds()); | 243 fetch_request->set_timestamp(timestamp.InMilliseconds()); |
| 247 } | 244 } |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 for (auto& observer : observers_) | 780 for (auto& observer : observers_) |
| 784 observer.OnRobotAuthCodesFetched(this); | 781 observer.OnRobotAuthCodesFetched(this); |
| 785 } | 782 } |
| 786 | 783 |
| 787 void CloudPolicyClient::NotifyClientError() { | 784 void CloudPolicyClient::NotifyClientError() { |
| 788 for (auto& observer : observers_) | 785 for (auto& observer : observers_) |
| 789 observer.OnClientError(this); | 786 observer.OnClientError(this); |
| 790 } | 787 } |
| 791 | 788 |
| 792 } // namespace policy | 789 } // namespace policy |
| OLD | NEW |