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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_
8 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h"
9 #include "components/policy/core/common/cloud/cloud_policy_constants.h"
10 #include "components/policy/core/common/cloud/cloud_policy_store.h"
11 #include "components/policy/core/common/cloud/cloud_policy_validator.h"
15 // Describes the result of an enrollment operation, including the relevant error
16 // codes received from the involved components. Note that the component error
17 // codes only convey useful information in case |status_| points towards a
18 // problem in that specific component.
19 class EnrollmentStatus
{
21 // Enrollment status codes. Do not change the numeric ids or the meaning of
22 // the existing codes to preserve the interpretability of old logfiles.
24 STATUS_SUCCESS
= 0, // Enrollment succeeded.
25 STATUS_NO_STATE_KEYS
= 1, // Server-backed state keys
27 STATUS_REGISTRATION_FAILED
= 2, // DM registration failed.
28 STATUS_REGISTRATION_BAD_MODE
= 3, // Bad device mode.
29 STATUS_ROBOT_AUTH_FETCH_FAILED
= 4, // API OAuth2 auth code failure.
30 STATUS_ROBOT_REFRESH_FETCH_FAILED
= 5, // API OAuth2 refresh token failure.
31 STATUS_ROBOT_REFRESH_STORE_FAILED
= 6, // Failed to store API OAuth2 token.
32 STATUS_POLICY_FETCH_FAILED
= 7, // DM policy fetch failed.
33 STATUS_VALIDATION_FAILED
= 8, // Policy validation failed.
34 STATUS_LOCK_ERROR
= 9, // Cryptohome failed to lock device.
35 /* STATUS_LOCK_TIMEOUT = 10, */ // Unused: Timeout while waiting for
37 /* STATUS_LOCK_WRONG_USER = 11, */ // Unused: Locked to different
39 STATUS_STORE_ERROR
= 12, // Failed to store the policy.
40 STATUS_STORE_TOKEN_AND_ID_FAILED
= 13, // Failed to store DM token and
44 // Helpers for constructing errors for relevant cases.
45 static EnrollmentStatus
ForStatus(Status status
);
46 static EnrollmentStatus
ForRegistrationError(
47 DeviceManagementStatus client_status
);
48 static EnrollmentStatus
ForFetchError(DeviceManagementStatus client_status
);
49 static EnrollmentStatus
ForRobotAuthFetchError(
50 DeviceManagementStatus client_status
);
51 static EnrollmentStatus
ForRobotRefreshFetchError(int http_status
);
52 static EnrollmentStatus
ForValidationError(
53 CloudPolicyValidatorBase::Status validation_status
);
54 static EnrollmentStatus
ForStoreError(
55 CloudPolicyStore::Status store_error
,
56 CloudPolicyValidatorBase::Status validation_status
);
57 static EnrollmentStatus
ForLockError(
58 EnterpriseInstallAttributes::LockResult lock_status
);
60 Status
status() const { return status_
; }
61 DeviceManagementStatus
client_status() const { return client_status_
; }
62 int http_status() const { return http_status_
; }
63 CloudPolicyStore::Status
store_status() const { return store_status_
; }
64 CloudPolicyValidatorBase::Status
validation_status() const {
65 return validation_status_
;
67 EnterpriseInstallAttributes::LockResult
lock_status() const {
72 EnrollmentStatus(Status status
,
73 DeviceManagementStatus client_status
,
75 CloudPolicyStore::Status store_status
,
76 CloudPolicyValidatorBase::Status validation_status
,
77 EnterpriseInstallAttributes::LockResult lock_status
);
80 DeviceManagementStatus client_status_
;
82 CloudPolicyStore::Status store_status_
;
83 CloudPolicyValidatorBase::Status validation_status_
;
84 EnterpriseInstallAttributes::LockResult lock_status_
;
89 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_