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/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "components/policy/core/common/cloud/device_management_service.h" | 14 #include "components/policy/core/common/cloud/device_management_service.h" |
| 15 #include "components/policy/core/common/cloud/signing_service.h" |
15 #include "google_apis/gaia/gaia_constants.h" | 16 #include "google_apis/gaia/gaia_constants.h" |
16 #include "google_apis/gaia/gaia_urls.h" | 17 #include "google_apis/gaia/gaia_urls.h" |
17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
18 | 19 |
19 namespace em = enterprise_management; | 20 namespace em = enterprise_management; |
20 | 21 |
21 namespace policy { | 22 namespace policy { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 fetched_invalidation_version_ = invalidation_version_; | 265 fetched_invalidation_version_ = invalidation_version_; |
265 | 266 |
266 // Fire the job. | 267 // Fire the job. |
267 policy_fetch_request_job_->Start( | 268 policy_fetch_request_job_->Start( |
268 base::Bind(&CloudPolicyClient::OnPolicyFetchCompleted, | 269 base::Bind(&CloudPolicyClient::OnPolicyFetchCompleted, |
269 weak_ptr_factory_.GetWeakPtr())); | 270 weak_ptr_factory_.GetWeakPtr())); |
270 } | 271 } |
271 | 272 |
272 void CloudPolicyClient::FetchRobotAuthCodes(const std::string& auth_token) { | 273 void CloudPolicyClient::FetchRobotAuthCodes(const std::string& auth_token) { |
273 CHECK(is_registered()); | 274 CHECK(is_registered()); |
274 DCHECK(!auth_token.empty()); | |
275 | 275 |
276 policy_fetch_request_job_.reset(service_->CreateJob( | 276 policy_fetch_request_job_.reset(service_->CreateJob( |
277 DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH, | 277 DeviceManagementRequestJob::TYPE_API_AUTH_CODE_FETCH, |
278 GetRequestContext())); | 278 GetRequestContext())); |
279 // The credentials of a domain user are needed in order to mint a new OAuth2 | |
280 // authorization token for the robot account. | |
281 policy_fetch_request_job_->SetOAuthToken(auth_token); | 279 policy_fetch_request_job_->SetOAuthToken(auth_token); |
282 policy_fetch_request_job_->SetDMToken(dm_token_); | 280 policy_fetch_request_job_->SetDMToken(dm_token_); |
283 policy_fetch_request_job_->SetClientID(client_id_); | 281 policy_fetch_request_job_->SetClientID(client_id_); |
284 | 282 |
285 em::DeviceServiceApiAccessRequest* request = | 283 em::DeviceServiceApiAccessRequest* request = |
286 policy_fetch_request_job_->GetRequest()-> | 284 policy_fetch_request_job_->GetRequest()-> |
287 mutable_service_api_access_request(); | 285 mutable_service_api_access_request(); |
288 request->set_oauth2_client_id( | 286 request->set_oauth2_client_id( |
289 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); | 287 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); |
290 request->add_auth_scope(GaiaConstants::kAnyApiOAuth2Scope); | 288 request->add_auth_scope(GaiaConstants::kAnyApiOAuth2Scope); |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 | 776 |
779 void CloudPolicyClient::NotifyRobotAuthCodesFetched() { | 777 void CloudPolicyClient::NotifyRobotAuthCodesFetched() { |
780 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this)); | 778 FOR_EACH_OBSERVER(Observer, observers_, OnRobotAuthCodesFetched(this)); |
781 } | 779 } |
782 | 780 |
783 void CloudPolicyClient::NotifyClientError() { | 781 void CloudPolicyClient::NotifyClientError() { |
784 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); | 782 FOR_EACH_OBSERVER(Observer, observers_, OnClientError(this)); |
785 } | 783 } |
786 | 784 |
787 } // namespace policy | 785 } // namespace policy |
OLD | NEW |