Home | History | Annotate | Download | only in policy
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
      6 
      7 #include "net/http/http_status_code.h"
      8 
      9 namespace policy {
     10 
     11 // static
     12 EnrollmentStatus EnrollmentStatus::ForStatus(Status status) {
     13   return EnrollmentStatus(status, DM_STATUS_SUCCESS, net::HTTP_OK,
     14                           CloudPolicyStore::STATUS_OK,
     15                           CloudPolicyValidatorBase::VALIDATION_OK);
     16 }
     17 
     18 // static
     19 EnrollmentStatus EnrollmentStatus::ForRegistrationError(
     20     DeviceManagementStatus client_status) {
     21   return EnrollmentStatus(STATUS_REGISTRATION_FAILED, client_status,
     22                           net::HTTP_OK, CloudPolicyStore::STATUS_OK,
     23                           CloudPolicyValidatorBase::VALIDATION_OK);
     24 }
     25 
     26 // static
     27 EnrollmentStatus EnrollmentStatus::ForRobotAuthFetchError(
     28     DeviceManagementStatus client_status) {
     29   return EnrollmentStatus(STATUS_ROBOT_AUTH_FETCH_FAILED, client_status,
     30                           net::HTTP_OK, CloudPolicyStore::STATUS_OK,
     31                           CloudPolicyValidatorBase::VALIDATION_OK);
     32 }
     33 
     34 // static
     35 EnrollmentStatus EnrollmentStatus::ForRobotRefreshFetchError(int http_status) {
     36   return EnrollmentStatus(STATUS_ROBOT_REFRESH_FETCH_FAILED, DM_STATUS_SUCCESS,
     37                           http_status, CloudPolicyStore::STATUS_OK,
     38                           CloudPolicyValidatorBase::VALIDATION_OK);
     39 }
     40 
     41 // static
     42 EnrollmentStatus EnrollmentStatus::ForFetchError(
     43     DeviceManagementStatus client_status) {
     44   return EnrollmentStatus(STATUS_POLICY_FETCH_FAILED, client_status,
     45                           net::HTTP_OK, CloudPolicyStore::STATUS_OK,
     46                           CloudPolicyValidatorBase::VALIDATION_OK);
     47 }
     48 
     49 // static
     50 EnrollmentStatus EnrollmentStatus::ForValidationError(
     51     CloudPolicyValidatorBase::Status validation_status) {
     52   return EnrollmentStatus(STATUS_VALIDATION_FAILED, DM_STATUS_SUCCESS,
     53                           net::HTTP_OK, CloudPolicyStore::STATUS_OK,
     54                           validation_status);
     55 }
     56 
     57 // static
     58 EnrollmentStatus EnrollmentStatus::ForStoreError(
     59     CloudPolicyStore::Status store_error,
     60     CloudPolicyValidatorBase::Status validation_status) {
     61   return EnrollmentStatus(STATUS_STORE_ERROR, DM_STATUS_SUCCESS,
     62                           net::HTTP_OK, store_error, validation_status);
     63 }
     64 
     65 EnrollmentStatus::EnrollmentStatus(
     66     EnrollmentStatus::Status status,
     67     DeviceManagementStatus client_status,
     68     int http_status,
     69     CloudPolicyStore::Status store_status,
     70     CloudPolicyValidatorBase::Status validation_status)
     71     : status_(status),
     72       client_status_(client_status),
     73       http_status_(http_status),
     74       store_status_(store_status),
     75       validation_status_(validation_status) {}
     76 
     77 }  // namespace policy
     78