Chromium Code Reviews| 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" |
| 11 #include "base/guid.h" | 11 #include "base/guid.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | |
|
emaxx
2016/11/29 14:24:58
nit: This is already included in the header file.
Thiemo Nagel
2016/11/29 15:16:38
Done.
| |
| 15 #include "components/policy/core/common/cloud/device_management_service.h" | 16 #include "components/policy/core/common/cloud/device_management_service.h" |
| 16 #include "components/policy/core/common/cloud/signing_service.h" | 17 #include "components/policy/core/common/cloud/signing_service.h" |
| 17 #include "google_apis/gaia/gaia_constants.h" | 18 #include "google_apis/gaia/gaia_constants.h" |
| 18 #include "google_apis/gaia/gaia_urls.h" | 19 #include "google_apis/gaia/gaia_urls.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| 20 | 21 |
| 21 namespace em = enterprise_management; | 22 namespace em = enterprise_management; |
| 22 | 23 |
| 23 namespace policy { | 24 namespace policy { |
| 24 | 25 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 48 } // namespace | 49 } // namespace |
| 49 | 50 |
| 50 CloudPolicyClient::Observer::~Observer() {} | 51 CloudPolicyClient::Observer::~Observer() {} |
| 51 | 52 |
| 52 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched( | 53 void CloudPolicyClient::Observer::OnRobotAuthCodesFetched( |
| 53 CloudPolicyClient* client) {} | 54 CloudPolicyClient* client) {} |
| 54 | 55 |
| 55 CloudPolicyClient::CloudPolicyClient( | 56 CloudPolicyClient::CloudPolicyClient( |
| 56 const std::string& machine_id, | 57 const std::string& machine_id, |
| 57 const std::string& machine_model, | 58 const std::string& machine_model, |
| 58 const std::string& verification_key_hash, | |
| 59 DeviceManagementService* service, | 59 DeviceManagementService* service, |
| 60 scoped_refptr<net::URLRequestContextGetter> request_context, | 60 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 61 SigningService* signing_service) | 61 SigningService* signing_service) |
| 62 : machine_id_(machine_id), | 62 : machine_id_(machine_id), |
| 63 machine_model_(machine_model), | 63 machine_model_(machine_model), |
| 64 verification_key_hash_(verification_key_hash), | |
| 65 service_(service), // Can be null for unit tests. | 64 service_(service), // Can be null for unit tests. |
| 66 signing_service_(signing_service), | 65 signing_service_(signing_service), |
| 67 request_context_(request_context), | 66 request_context_(request_context), |
| 68 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
| 69 } | 68 } |
| 70 | 69 |
| 71 CloudPolicyClient::~CloudPolicyClient() { | 70 CloudPolicyClient::~CloudPolicyClient() { |
| 72 } | 71 } |
| 73 | 72 |
| 74 void CloudPolicyClient::SetupRegistration(const std::string& dm_token, | 73 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(); | 225 em::PolicyFetchRequest* fetch_request = policy_request->add_request(); |
| 227 fetch_request->set_policy_type(type_to_fetch.first); | 226 fetch_request->set_policy_type(type_to_fetch.first); |
| 228 if (!type_to_fetch.second.empty()) | 227 if (!type_to_fetch.second.empty()) |
| 229 fetch_request->set_settings_entity_id(type_to_fetch.second); | 228 fetch_request->set_settings_entity_id(type_to_fetch.second); |
| 230 | 229 |
| 231 // Request signed policy blobs to help prevent tampering on the client. | 230 // Request signed policy blobs to help prevent tampering on the client. |
| 232 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); | 231 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); |
| 233 if (public_key_version_valid_) | 232 if (public_key_version_valid_) |
| 234 fetch_request->set_public_key_version(public_key_version_); | 233 fetch_request->set_public_key_version(public_key_version_); |
| 235 | 234 |
| 236 if (!verification_key_hash_.empty()) | 235 fetch_request->set_verification_key_hash(kPolicyVerificationKeyHash); |
| 237 fetch_request->set_verification_key_hash(verification_key_hash_); | |
| 238 | 236 |
| 239 // These fields are included only in requests for chrome policy. | 237 // These fields are included only in requests for chrome policy. |
| 240 if (IsChromePolicy(type_to_fetch.first)) { | 238 if (IsChromePolicy(type_to_fetch.first)) { |
| 241 if (submit_machine_id_ && !machine_id_.empty()) | 239 if (submit_machine_id_ && !machine_id_.empty()) |
| 242 fetch_request->set_machine_id(machine_id_); | 240 fetch_request->set_machine_id(machine_id_); |
| 243 if (!last_policy_timestamp_.is_null()) { | 241 if (!last_policy_timestamp_.is_null()) { |
| 244 base::TimeDelta timestamp( | 242 base::TimeDelta timestamp( |
| 245 last_policy_timestamp_ - base::Time::UnixEpoch()); | 243 last_policy_timestamp_ - base::Time::UnixEpoch()); |
| 246 fetch_request->set_timestamp(timestamp.InMilliseconds()); | 244 fetch_request->set_timestamp(timestamp.InMilliseconds()); |
| 247 } | 245 } |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 for (auto& observer : observers_) | 781 for (auto& observer : observers_) |
| 784 observer.OnRobotAuthCodesFetched(this); | 782 observer.OnRobotAuthCodesFetched(this); |
| 785 } | 783 } |
| 786 | 784 |
| 787 void CloudPolicyClient::NotifyClientError() { | 785 void CloudPolicyClient::NotifyClientError() { |
| 788 for (auto& observer : observers_) | 786 for (auto& observer : observers_) |
| 789 observer.OnClientError(this); | 787 observer.OnClientError(this); |
| 790 } | 788 } |
| 791 | 789 |
| 792 } // namespace policy | 790 } // namespace policy |
| OLD | NEW |