| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 | 398 |
| 399 // Handles policy request jobs. | 399 // Handles policy request jobs. |
| 400 class DeviceManagementPolicyJob : public DeviceManagementJobBase { | 400 class DeviceManagementPolicyJob : public DeviceManagementJobBase { |
| 401 public: | 401 public: |
| 402 DeviceManagementPolicyJob( | 402 DeviceManagementPolicyJob( |
| 403 DeviceManagementBackendImpl* backend_impl, | 403 DeviceManagementBackendImpl* backend_impl, |
| 404 const std::string& device_management_token, | 404 const std::string& device_management_token, |
| 405 const std::string& device_id, | 405 const std::string& device_id, |
| 406 const std::string& user_affiliation, | 406 const std::string& user_affiliation, |
| 407 const em::DevicePolicyRequest& request, | 407 const em::DevicePolicyRequest& request, |
| 408 const em::DeviceStatusReportRequest& device_status, |
| 408 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate) | 409 DeviceManagementBackend::DevicePolicyResponseDelegate* delegate) |
| 409 : DeviceManagementJobBase( | 410 : DeviceManagementJobBase( |
| 410 backend_impl, | 411 backend_impl, |
| 411 DeviceManagementBackendImpl::kValueRequestPolicy, | 412 DeviceManagementBackendImpl::kValueRequestPolicy, |
| 412 device_id), | 413 device_id), |
| 413 delegate_(delegate) { | 414 delegate_(delegate) { |
| 414 SetDeviceManagementToken(device_management_token); | 415 SetDeviceManagementToken(device_management_token); |
| 415 SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation, | 416 SetQueryParam(DeviceManagementBackendImpl::kParamUserAffiliation, |
| 416 user_affiliation); | 417 user_affiliation); |
| 417 em::DeviceManagementRequest request_wrapper; | 418 em::DeviceManagementRequest request_wrapper; |
| 418 request_wrapper.mutable_policy_request()->CopyFrom(request); | 419 request_wrapper.mutable_policy_request()->CopyFrom(request); |
| 420 request_wrapper.mutable_device_status_report_request()->CopyFrom( |
| 421 device_status); |
| 419 SetPayload(request_wrapper); | 422 SetPayload(request_wrapper); |
| 420 } | 423 } |
| 421 virtual ~DeviceManagementPolicyJob() {} | 424 virtual ~DeviceManagementPolicyJob() {} |
| 422 | 425 |
| 423 private: | 426 private: |
| 424 // DeviceManagementJobBase overrides. | 427 // DeviceManagementJobBase overrides. |
| 425 virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { | 428 virtual void OnError(DeviceManagementBackend::ErrorCode error) OVERRIDE { |
| 426 MetricPolicy sample; | 429 MetricPolicy sample; |
| 427 switch (error) { | 430 switch (error) { |
| 428 case DeviceManagementBackend::kErrorRequestInvalid: | 431 case DeviceManagementBackend::kErrorRequestInvalid: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 DeviceUnregisterResponseDelegate* delegate) { | 559 DeviceUnregisterResponseDelegate* delegate) { |
| 557 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, | 560 AddJob(new DeviceManagementUnregisterJob(this, device_management_token, |
| 558 device_id, request, delegate)); | 561 device_id, request, delegate)); |
| 559 } | 562 } |
| 560 | 563 |
| 561 void DeviceManagementBackendImpl::ProcessPolicyRequest( | 564 void DeviceManagementBackendImpl::ProcessPolicyRequest( |
| 562 const std::string& device_management_token, | 565 const std::string& device_management_token, |
| 563 const std::string& device_id, | 566 const std::string& device_id, |
| 564 CloudPolicyDataStore::UserAffiliation affiliation, | 567 CloudPolicyDataStore::UserAffiliation affiliation, |
| 565 const em::DevicePolicyRequest& request, | 568 const em::DevicePolicyRequest& request, |
| 569 const em::DeviceStatusReportRequest& device_status, |
| 566 DevicePolicyResponseDelegate* delegate) { | 570 DevicePolicyResponseDelegate* delegate) { |
| 567 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested, | 571 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchRequested, |
| 568 kMetricPolicySize); | 572 kMetricPolicySize); |
| 569 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, | 573 AddJob(new DeviceManagementPolicyJob(this, device_management_token, device_id, |
| 570 UserAffiliationToString(affiliation), | 574 UserAffiliationToString(affiliation), |
| 571 request, delegate)); | 575 request, device_status, delegate)); |
| 572 } | 576 } |
| 573 | 577 |
| 574 // static | 578 // static |
| 575 const char* DeviceManagementBackendImpl::UserAffiliationToString( | 579 const char* DeviceManagementBackendImpl::UserAffiliationToString( |
| 576 CloudPolicyDataStore::UserAffiliation affiliation) { | 580 CloudPolicyDataStore::UserAffiliation affiliation) { |
| 577 switch (affiliation) { | 581 switch (affiliation) { |
| 578 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: | 582 case CloudPolicyDataStore::USER_AFFILIATION_MANAGED: |
| 579 return kValueUserAffiliationManaged; | 583 return kValueUserAffiliationManaged; |
| 580 case CloudPolicyDataStore::USER_AFFILIATION_NONE: | 584 case CloudPolicyDataStore::USER_AFFILIATION_NONE: |
| 581 return kValueUserAffiliationNone; | 585 return kValueUserAffiliationNone; |
| 582 } | 586 } |
| 583 NOTREACHED(); | 587 NOTREACHED(); |
| 584 return kValueUserAffiliationNone; | 588 return kValueUserAffiliationNone; |
| 585 } | 589 } |
| 586 | 590 |
| 587 } // namespace policy | 591 } // namespace policy |
| OLD | NEW |