OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/policy/device_management_backend_impl.h" | 5 #include "chrome/browser/policy/device_management_backend_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 : public DeviceManagementService::DeviceManagementJob { | 128 : public DeviceManagementService::DeviceManagementJob { |
129 public: | 129 public: |
130 virtual ~DeviceManagementJobBase() {} | 130 virtual ~DeviceManagementJobBase() {} |
131 | 131 |
132 // DeviceManagementJob overrides: | 132 // DeviceManagementJob overrides: |
133 virtual void HandleResponse(const net::URLRequestStatus& status, | 133 virtual void HandleResponse(const net::URLRequestStatus& status, |
134 int response_code, | 134 int response_code, |
135 const net::ResponseCookies& cookies, | 135 const net::ResponseCookies& cookies, |
136 const std::string& data); | 136 const std::string& data); |
137 virtual GURL GetURL(const std::string& server_url); | 137 virtual GURL GetURL(const std::string& server_url); |
138 virtual void ConfigureRequest(URLFetcher* fetcher); | 138 virtual void ConfigureRequest(content::URLFetcher* fetcher); |
139 | 139 |
140 protected: | 140 protected: |
141 // Constructs a device management job running for the given backend. | 141 // Constructs a device management job running for the given backend. |
142 DeviceManagementJobBase(DeviceManagementBackendImpl* backend_impl, | 142 DeviceManagementJobBase(DeviceManagementBackendImpl* backend_impl, |
143 const std::string& request_type, | 143 const std::string& request_type, |
144 const std::string& device_id) | 144 const std::string& device_id) |
145 : backend_impl_(backend_impl) { | 145 : backend_impl_(backend_impl) { |
146 query_params_.Put(DeviceManagementBackendImpl::kParamRequest, request_type); | 146 query_params_.Put(DeviceManagementBackendImpl::kParamRequest, request_type); |
147 query_params_.Put(DeviceManagementBackendImpl::kParamDeviceType, | 147 query_params_.Put(DeviceManagementBackendImpl::kParamDeviceType, |
148 DeviceManagementBackendImpl::kValueDeviceType); | 148 DeviceManagementBackendImpl::kValueDeviceType); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return; | 275 return; |
276 } | 276 } |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 GURL DeviceManagementJobBase::GetURL( | 280 GURL DeviceManagementJobBase::GetURL( |
281 const std::string& server_url) { | 281 const std::string& server_url) { |
282 return GURL(server_url + '?' + query_params_.Encode()); | 282 return GURL(server_url + '?' + query_params_.Encode()); |
283 } | 283 } |
284 | 284 |
285 void DeviceManagementJobBase::ConfigureRequest(URLFetcher* fetcher) { | 285 void DeviceManagementJobBase::ConfigureRequest(content::URLFetcher* fetcher) { |
286 fetcher->set_upload_data(kPostContentType, payload_); | 286 fetcher->SetUploadData(kPostContentType, payload_); |
287 std::string extra_headers; | 287 std::string extra_headers; |
288 if (!gaia_auth_token_.empty()) | 288 if (!gaia_auth_token_.empty()) |
289 extra_headers += kServiceTokenAuthHeader + gaia_auth_token_ + "\n"; | 289 extra_headers += kServiceTokenAuthHeader + gaia_auth_token_ + "\n"; |
290 if (!device_management_token_.empty()) | 290 if (!device_management_token_.empty()) |
291 extra_headers += kDMTokenAuthHeader + device_management_token_ + "\n"; | 291 extra_headers += kDMTokenAuthHeader + device_management_token_ + "\n"; |
292 fetcher->set_extra_request_headers(extra_headers); | 292 fetcher->SetExtraRequestHeaders(extra_headers); |
293 } | 293 } |
294 | 294 |
295 // Handles device registration jobs. | 295 // Handles device registration jobs. |
296 class DeviceManagementRegisterJob : public DeviceManagementJobBase { | 296 class DeviceManagementRegisterJob : public DeviceManagementJobBase { |
297 public: | 297 public: |
298 DeviceManagementRegisterJob( | 298 DeviceManagementRegisterJob( |
299 DeviceManagementBackendImpl* backend_impl, | 299 DeviceManagementBackendImpl* backend_impl, |
300 const std::string& gaia_auth_token, | 300 const std::string& gaia_auth_token, |
301 const std::string& oauth_token, | 301 const std::string& oauth_token, |
302 const std::string& device_id, | 302 const std::string& device_id, |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: | 578 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: |
579 return kValueUserAffiliationManaged; | 579 return kValueUserAffiliationManaged; |
580 case CloudPolicyDataStore::USER_AFFILIATION_NONE: | 580 case CloudPolicyDataStore::USER_AFFILIATION_NONE: |
581 return kValueUserAffiliationNone; | 581 return kValueUserAffiliationNone; |
582 } | 582 } |
583 NOTREACHED(); | 583 NOTREACHED(); |
584 return kValueUserAffiliationNone; | 584 return kValueUserAffiliationNone; |
585 } | 585 } |
586 | 586 |
587 } // namespace policy | 587 } // namespace policy |
OLD | NEW |