Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/policy/device_management_backend_impl.cc

Issue 6537020: Update policy backend and testserver for the newest policy protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more last minute changes Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "net/base/escape.h" 11 #include "net/base/escape.h"
12 #include "net/url_request/url_request_status.h" 12 #include "net/url_request/url_request_status.h"
13 #include "chrome/browser/policy/device_management_service.h" 13 #include "chrome/browser/policy/device_management_service.h"
14 #include "chrome/common/chrome_version_info.h" 14 #include "chrome/common/chrome_version_info.h"
15 15
16 namespace policy { 16 namespace policy {
17 17
18 // Name constants for URL query parameters. 18 // Name constants for URL query parameters.
19 const char DeviceManagementBackendImpl::kParamRequest[] = "request"; 19 const char DeviceManagementBackendImpl::kParamRequest[] = "request";
20 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype"; 20 const char DeviceManagementBackendImpl::kParamDeviceType[] = "devicetype";
21 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype"; 21 const char DeviceManagementBackendImpl::kParamAppType[] = "apptype";
22 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid"; 22 const char DeviceManagementBackendImpl::kParamDeviceID[] = "deviceid";
23 const char DeviceManagementBackendImpl::kParamAgent[] = "agent"; 23 const char DeviceManagementBackendImpl::kParamAgent[] = "agent";
24 24
25 // String constants for the device and app type we report to the server. 25 // String constants for the device and app type we report to the server.
26 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register"; 26 const char DeviceManagementBackendImpl::kValueRequestRegister[] = "register";
27 const char DeviceManagementBackendImpl::kValueRequestUnregister[] = 27 const char DeviceManagementBackendImpl::kValueRequestUnregister[] =
28 "unregister"; 28 "unregister";
29 const char DeviceManagementBackendImpl::kValueRequestPolicy[] = "policy"; 29 const char DeviceManagementBackendImpl::kValueRequestPolicy[] = "policy";
30 const char DeviceManagementBackendImpl::kValueRequestCloudPolicy[] = 30 const char DeviceManagementBackendImpl::kValueDeviceType[] = "2";
31 "cloud_policy";
32 const char DeviceManagementBackendImpl::kValueDeviceType[] = "Chrome OS";
33 const char DeviceManagementBackendImpl::kValueAppType[] = "Chrome"; 31 const char DeviceManagementBackendImpl::kValueAppType[] = "Chrome";
34 32
35 namespace { 33 namespace {
36 34
37 const char kValueAgent[] = "%s enterprise management client version %s (%s)"; 35 const char kValueAgent[] = "%s enterprise management client %s (%s)";
38 36
39 const char kPostContentType[] = "application/protobuf"; 37 const char kPostContentType[] = "application/protobuf";
40 38
41 const char kServiceTokenAuthHeader[] = "Authorization: GoogleLogin auth="; 39 const char kServiceTokenAuthHeader[] = "Authorization: GoogleLogin auth=";
42 const char kDMTokenAuthHeader[] = "Authorization: GoogleDMToken token="; 40 const char kDMTokenAuthHeader[] = "Authorization: GoogleDMToken token=";
43 41
44 } // namespace 42 } // namespace
45 43
46 // Helper class for URL query parameter encoding/decoding. 44 // Helper class for URL query parameter encoding/decoding.
47 class URLQueryParameters { 45 class URLQueryParameters {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 323 }
326 virtual void OnResponse(const em::DeviceManagementResponse& response) { 324 virtual void OnResponse(const em::DeviceManagementResponse& response) {
327 delegate_->HandlePolicyResponse(response.policy_response()); 325 delegate_->HandlePolicyResponse(response.policy_response());
328 } 326 }
329 327
330 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate_; 328 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate_;
331 329
332 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyJob); 330 DISALLOW_COPY_AND_ASSIGN(DeviceManagementPolicyJob);
333 }; 331 };
334 332
335 // Handles cloud policy request jobs.
336 class CloudPolicyJob : public DeviceManagementJobBase {
337 public:
338 CloudPolicyJob(
339 DeviceManagementBackendImpl* backend_impl,
340 const std::string& device_management_token,
341 const std::string& device_id,
342 const em::CloudPolicyRequest& request,
343 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate)
344 : DeviceManagementJobBase(
345 backend_impl,
346 DeviceManagementBackendImpl::kValueRequestCloudPolicy,
347 device_id),
348 delegate_(delegate) {
349 SetDeviceManagementToken(device_management_token);
350 em::DeviceManagementRequest request_wrapper;
351 request_wrapper.mutable_cloud_policy_request()->CopyFrom(request);
352 SetPayload(request_wrapper);
353 }
354 virtual ~CloudPolicyJob() {}
355
356 private:
357 // DeviceManagementJobBase overrides.
358 virtual void OnError(DeviceManagementBackend::ErrorCode error) {
359 delegate_->OnError(error);
360 }
361 virtual void OnResponse(const em::DeviceManagementResponse& response) {
362 delegate_->HandleCloudPolicyResponse(response.cloud_policy_response());
363 }
364
365 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate_;
366
367 DISALLOW_COPY_AND_ASSIGN(CloudPolicyJob);
368 };
369
370 DeviceManagementBackendImpl::DeviceManagementBackendImpl( 333 DeviceManagementBackendImpl::DeviceManagementBackendImpl(
371 DeviceManagementService* service) 334 DeviceManagementService* service)
372 : service_(service) { 335 : service_(service) {
373 } 336 }
374 337
375 DeviceManagementBackendImpl::~DeviceManagementBackendImpl() { 338 DeviceManagementBackendImpl::~DeviceManagementBackendImpl() {
376 // Swap to a helper, so we don't interfere with the unregistration on delete. 339 // Swap to a helper, so we don't interfere with the unregistration on delete.
377 JobSet to_be_deleted; 340 JobSet to_be_deleted;
378 to_be_deleted.swap(pending_jobs_); 341 to_be_deleted.swap(pending_jobs_);
379 for (JobSet::iterator job(to_be_deleted.begin()); 342 for (JobSet::iterator job(to_be_deleted.begin());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 384
422 void DeviceManagementBackendImpl::ProcessPolicyRequest( 385 void DeviceManagementBackendImpl::ProcessPolicyRequest(
423 const std::string& device_management_token, 386 const std::string& device_management_token,
424 const std::string& device_id, 387 const std::string& device_id,
425 const em::DevicePolicyRequest& request, 388 const em::DevicePolicyRequest& request,
426 DevicePolicyResponseDelegate* delegate) { 389 DevicePolicyResponseDelegate* delegate) {
427 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, 390 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id,
428 request, delegate)); 391 request, delegate));
429 } 392 }
430 393
431 void DeviceManagementBackendImpl::ProcessCloudPolicyRequest(
432 const std::string& device_management_token,
433 const std::string& device_id,
434 const em::CloudPolicyRequest& request,
435 DevicePolicyResponseDelegate* delegate) {
436 AddJob(new CloudPolicyJob(this, device_management_token, device_id,
437 request, delegate));
438 }
439
440 } // namespace policy 394 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_management_backend_impl.h ('k') | chrome/browser/policy/device_management_backend_mock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698