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 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 | 400 |
401 // Handles policy request jobs. | 401 // Handles policy request jobs. |
402 class DeviceManagementPolicyJob : public DeviceManagementJobBase { | 402 class DeviceManagementPolicyJob : public DeviceManagementJobBase { |
403 public: | 403 public: |
404 DeviceManagementPolicyJob( | 404 DeviceManagementPolicyJob( |
405 DeviceManagementBackendImpl* backend_impl, | 405 DeviceManagementBackendImpl* backend_impl, |
406 const std::string& device_management_token, | 406 const std::string& device_management_token, |
407 const std::string& device_id, | 407 const std::string& device_id, |
408 const std::string& user_affiliation, | 408 const std::string& user_affiliation, |
409 const em::DevicePolicyRequest& request, | 409 const em::DevicePolicyRequest& request, |
| 410 const em::DeviceStatusReportRequest* device_status, |
410 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate) | 411 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate) |
411 : DeviceManagementJobBase( | 412 : DeviceManagementJobBase( |
412 backend_impl, | 413 backend_impl, |
413 DeviceManagementBackendImpl::kValueRequestPolicy, | 414 DeviceManagementBackendImpl::kValueRequestPolicy, |
414 device_id), | 415 device_id), |
415 delegate_(delegate) { | 416 delegate_(delegate) { |
416 SetDeviceManagementToken(device_management_token); | 417 SetDeviceManagementToken(device_management_token); |
417 SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation, | 418 SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation, |
418 user_affiliation); | 419 user_affiliation); |
419 em::DeviceManagementRequest request_wrapper; | 420 em::DeviceManagementRequest request_wrapper; |
420 request_wrapper.mutable_policy_request()->CopyFrom(request); | 421 request_wrapper.mutable_policy_request()->CopyFrom(request); |
| 422 if (device_status != NULL) { |
| 423 request_wrapper.mutable_device_status_report_request()->CopyFrom( |
| 424 *device_status); |
| 425 } |
421 SetPayload(request_wrapper); | 426 SetPayload(request_wrapper); |
422 } | 427 } |
423 virtual ~DeviceManagementPolicyJob() {} | 428 virtual ~DeviceManagementPolicyJob() {} |
424 | 429 |
425 private: | 430 private: |
426 // DeviceManagementJobBase overrides. | 431 // DeviceManagementJobBase overrides. |
427 virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { | 432 virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { |
428 MetricPolicy sample; | 433 MetricPolicy sample; |
429 switch (error) { | 434 switch (error) { |
430 case DeviceManagementBackend::kErrorRequestInvalid: | 435 case DeviceManagementBackend::kErrorRequestInvalid: |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 DeviceUnregisterResponseDelegate* delegate) { | 600 DeviceUnregisterResponseDelegate* delegate) { |
596 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, | 601 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, |
597 device_id, request, delegate)); | 602 device_id, request, delegate)); |
598 } | 603 } |
599 | 604 |
600 void DeviceManagementBackendImpl::ProcessPolicyRequest( | 605 void DeviceManagementBackendImpl::ProcessPolicyRequest( |
601 const std::string& device_management_token, | 606 const std::string& device_management_token, |
602 const std::string& device_id, | 607 const std::string& device_id, |
603 CloudPolicyDataStore::UserAffiliation affiliation, | 608 CloudPolicyDataStore::UserAffiliation affiliation, |
604 const em::DevicePolicyRequest& request, | 609 const em::DevicePolicyRequest& request, |
| 610 const em::DeviceStatusReportRequest* device_status, |
605 DevicePolicyResponseDelegate* delegate) { | 611 DevicePolicyResponseDelegate* delegate) { |
606 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested, | 612 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested, |
607 kMetricPolicySize); | 613 kMetricPolicySize); |
608 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, | 614 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, |
609 UserAffiliationToString(affiliation), | 615 UserAffiliationToString(affiliation), |
610 request, delegate)); | 616 request, device_status, delegate)); |
611 } | 617 } |
612 | 618 |
613 void DeviceManagementBackendImpl::ProcessAutoEnrollmentRequest( | 619 void DeviceManagementBackendImpl::ProcessAutoEnrollmentRequest( |
614 const std::string& device_id, | 620 const std::string& device_id, |
615 const em::DeviceAutoEnrollmentRequest& request, | 621 const em::DeviceAutoEnrollmentRequest& request, |
616 DeviceAutoEnrollmentResponseDelegate* delegate) { | 622 DeviceAutoEnrollmentResponseDelegate* delegate) { |
617 AddJob(new DeviceManagementAutoEnrollmentJob(this, device_id, request, | 623 AddJob(new DeviceManagementAutoEnrollmentJob(this, device_id, request, |
618 delegate)); | 624 delegate)); |
619 } | 625 } |
620 | 626 |
621 // static | 627 // static |
622 const char* DeviceManagementBackendImpl::UserAffiliationToString( | 628 const char* DeviceManagementBackendImpl::UserAffiliationToString( |
623 CloudPolicyDataStore::UserAffiliation affiliation) { | 629 CloudPolicyDataStore::UserAffiliation affiliation) { |
624 switch (affiliation) { | 630 switch (affiliation) { |
625 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: | 631 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: |
626 return kValueUserAffiliationManaged; | 632 return kValueUserAffiliationManaged; |
627 case CloudPolicyDataStore::USER_AFFILIATION_NONE: | 633 case CloudPolicyDataStore::USER_AFFILIATION_NONE: |
628 return kValueUserAffiliationNone; | 634 return kValueUserAffiliationNone; |
629 } | 635 } |
630 NOTREACHED(); | 636 NOTREACHED(); |
631 return kValueUserAffiliationNone; | 637 return kValueUserAffiliationNone; |
632 } | 638 } |
633 | 639 |
634 } // namespace policy | 640 } // namespace policy |
OLD | NEW |