15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "net/http/http_status_code.h"
81e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace policy {
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForStatus(Status status) {
131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  return EnrollmentStatus(status, DM_STATUS_SUCCESS, net::HTTP_OK,
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          CloudPolicyStore::STATUS_OK,
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          CloudPolicyValidatorBase::VALIDATION_OK);
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForRegistrationError(
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DeviceManagementStatus client_status) {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return EnrollmentStatus(STATUS_REGISTRATION_FAILED, client_status,
221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          net::HTTP_OK, CloudPolicyStore::STATUS_OK,
231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          CloudPolicyValidatorBase::VALIDATION_OK);
241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// static
271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForRobotAuthFetchError(
281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    DeviceManagementStatus client_status) {
291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  return EnrollmentStatus(STATUS_ROBOT_AUTH_FETCH_FAILED, client_status,
301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          net::HTTP_OK, CloudPolicyStore::STATUS_OK,
311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          CloudPolicyValidatorBase::VALIDATION_OK);
321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}
331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
341e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// static
351e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForRobotRefreshFetchError(int http_status) {
361e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  return EnrollmentStatus(STATUS_ROBOT_REFRESH_FETCH_FAILED, DM_STATUS_SUCCESS,
371e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          http_status, CloudPolicyStore::STATUS_OK,
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          CloudPolicyValidatorBase::VALIDATION_OK);
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForFetchError(
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DeviceManagementStatus client_status) {
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return EnrollmentStatus(STATUS_POLICY_FETCH_FAILED, client_status,
451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          net::HTTP_OK, CloudPolicyStore::STATUS_OK,
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                          CloudPolicyValidatorBase::VALIDATION_OK);
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForValidationError(
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CloudPolicyValidatorBase::Status validation_status) {
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return EnrollmentStatus(STATUS_VALIDATION_FAILED, DM_STATUS_SUCCESS,
531e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          net::HTTP_OK, CloudPolicyStore::STATUS_OK,
541e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          validation_status);
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// static
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus EnrollmentStatus::ForStoreError(
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CloudPolicyStore::Status store_error,
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CloudPolicyValidatorBase::Status validation_status) {
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return EnrollmentStatus(STATUS_STORE_ERROR, DM_STATUS_SUCCESS,
621e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)                          net::HTTP_OK, store_error, validation_status);
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EnrollmentStatus::EnrollmentStatus(
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    EnrollmentStatus::Status status,
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    DeviceManagementStatus client_status,
681e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)    int http_status,
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CloudPolicyStore::Status store_status,
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    CloudPolicyValidatorBase::Status validation_status)
715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    : status_(status),
725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      client_status_(client_status),
731e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)      http_status_(http_status),
745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      store_status_(store_status),
755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      validation_status_(validation_status) {}
765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace policy
78