enrollment_status_chromeos.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
136f893c1efe367f929d92c8b125f964c22ba189eJohn McCall// Copyright (c) 2012 The Chromium Authors. All rights reserved. 236f893c1efe367f929d92c8b125f964c22ba189eJohn McCall// Use of this source code is governed by a BSD-style license that can be 336f893c1efe367f929d92c8b125f964c22ba189eJohn McCall// found in the LICENSE file. 436f893c1efe367f929d92c8b125f964c22ba189eJohn McCall 536f893c1efe367f929d92c8b125f964c22ba189eJohn McCall#ifndef CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_ 636f893c1efe367f929d92c8b125f964c22ba189eJohn McCall#define CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_ 736f893c1efe367f929d92c8b125f964c22ba189eJohn McCall 836f893c1efe367f929d92c8b125f964c22ba189eJohn McCall#include "chrome/browser/policy/cloud/cloud_policy_constants.h" 936f893c1efe367f929d92c8b125f964c22ba189eJohn McCall#include "chrome/browser/policy/cloud/cloud_policy_store.h" 1036f893c1efe367f929d92c8b125f964c22ba189eJohn McCall#include "chrome/browser/policy/cloud/cloud_policy_validator.h" 1136f893c1efe367f929d92c8b125f964c22ba189eJohn McCall 1236f893c1efe367f929d92c8b125f964c22ba189eJohn McCallnamespace policy { 1336f893c1efe367f929d92c8b125f964c22ba189eJohn McCall 1436f893c1efe367f929d92c8b125f964c22ba189eJohn McCall// Describes the result of an enrollment operation, including the relevant error 1536f893c1efe367f929d92c8b125f964c22ba189eJohn McCall// codes received from the involved components. 1636f893c1efe367f929d92c8b125f964c22ba189eJohn McCallclass EnrollmentStatus { 1743a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner public: 186fe91e448f948b78a36dd7f978125e0a882c623fReid Kleckner // Enrollment status codes. 196fe91e448f948b78a36dd7f978125e0a882c623fReid Kleckner enum Status { 2043a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_SUCCESS, // Enrollment succeeded. 2143a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_REGISTRATION_FAILED, // DM registration failed. 2243a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_REGISTRATION_BAD_MODE, // Bad device mode. 2343a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_ROBOT_AUTH_FETCH_FAILED, // API OAuth2 auth code failure. 2443a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_ROBOT_REFRESH_FETCH_FAILED, // API OAuth2 refresh token failure. 2543a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_ROBOT_REFRESH_STORE_FAILED, // Failed to store API OAuth2 token. 2643a75fcbe4b592d7bea1fe262117114bcebc003cReid Kleckner STATUS_POLICY_FETCH_FAILED, // DM policy fetch failed. 2736f893c1efe367f929d92c8b125f964c22ba189eJohn McCall STATUS_VALIDATION_FAILED, // Policy validation failed. 2836f893c1efe367f929d92c8b125f964c22ba189eJohn McCall STATUS_LOCK_ERROR, // Cryptohome failed to lock the device. 2936f893c1efe367f929d92c8b125f964c22ba189eJohn McCall STATUS_LOCK_TIMEOUT, // Timeout while waiting for the lock. 3036f893c1efe367f929d92c8b125f964c22ba189eJohn McCall STATUS_LOCK_WRONG_USER, // Locked to different domain. 3136f893c1efe367f929d92c8b125f964c22ba189eJohn McCall STATUS_STORE_ERROR, // Failed to store the policy. 3236f893c1efe367f929d92c8b125f964c22ba189eJohn McCall }; 3336f893c1efe367f929d92c8b125f964c22ba189eJohn McCall 34777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall // Helpers for constructing errors for relevant cases. 3536f893c1efe367f929d92c8b125f964c22ba189eJohn McCall static EnrollmentStatus ForStatus(Status status); 36777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall static EnrollmentStatus ForRegistrationError( 37777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall DeviceManagementStatus client_status); 38777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall static EnrollmentStatus ForFetchError(DeviceManagementStatus client_status); 39777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall static EnrollmentStatus ForRobotAuthFetchError( 40777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall DeviceManagementStatus client_status); 41777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall static EnrollmentStatus ForRobotRefreshFetchError(int http_status); 42777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall static EnrollmentStatus ForValidationError( 4336f893c1efe367f929d92c8b125f964c22ba189eJohn McCall CloudPolicyValidatorBase::Status validation_status); 4436f893c1efe367f929d92c8b125f964c22ba189eJohn McCall static EnrollmentStatus ForStoreError( 45777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyStore::Status store_error, 46777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyValidatorBase::Status validation_status); 47777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall 48777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall Status status() const { return status_; } 49777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall DeviceManagementStatus client_status() const { return client_status_; } 50777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall int http_status() const { return http_status_; } 51777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyStore::Status store_status() const { return store_status_; } 52777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyValidatorBase::Status validation_status() const { 53777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall return validation_status_; 54777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall } 55777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall 56777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall private: 57777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall EnrollmentStatus(Status status, 58777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall DeviceManagementStatus client_status, 59777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall int http_status, 60777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyStore::Status store_status, 61777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyValidatorBase::Status validation_status); 62777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall 63777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall Status status_; 64777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall DeviceManagementStatus client_status_; 65777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall int http_status_; 66777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyStore::Status store_status_; 67777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall CloudPolicyValidatorBase::Status validation_status_; 68777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall}; 69777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall 70777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall} // namespace policy 71777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall 72777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall#endif // CHROME_BROWSER_CHROMEOS_POLICY_ENROLLMENT_STATUS_CHROMEOS_H_ 73777d6e56ad9b1fed9866daf3ee6486d85c5b7d32John McCall