| OLD | NEW |
| (Empty) |
| 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 #ifndef CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_H_ | |
| 6 #define CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/threading/non_thread_safe.h" | |
| 12 #include "chrome/browser/policy/cloud_policy_data_store.h" | |
| 13 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | |
| 14 | |
| 15 namespace policy { | |
| 16 | |
| 17 // Interface for clients that need to converse with the device management | |
| 18 // server, which provides services to register Chrome installations and CrOS | |
| 19 // devices for the purpose of fetching centrally-administered policy from the | |
| 20 // cloud. | |
| 21 class DeviceManagementBackend : base::NonThreadSafe { | |
| 22 public: | |
| 23 enum ErrorCode { | |
| 24 // Request payload invalid. | |
| 25 kErrorRequestInvalid, | |
| 26 // The HTTP request failed. | |
| 27 kErrorRequestFailed, | |
| 28 // The server returned an error code that points to a temporary problem. | |
| 29 kErrorTemporaryUnavailable, | |
| 30 // The HTTP request returned a non-success code. | |
| 31 kErrorHttpStatus, | |
| 32 // Response could not be decoded. | |
| 33 kErrorResponseDecoding, | |
| 34 // Service error: Management not supported. | |
| 35 kErrorServiceManagementNotSupported, | |
| 36 // Service error: Device not found. | |
| 37 kErrorServiceDeviceNotFound, | |
| 38 // Service error: Device token invalid. | |
| 39 kErrorServiceManagementTokenInvalid, | |
| 40 // Service error: Activation pending. | |
| 41 kErrorServiceActivationPending, | |
| 42 // Service error: The serial number is not valid or not known to the server. | |
| 43 kErrorServiceInvalidSerialNumber, | |
| 44 // Service error: The device id used for registration is already taken. | |
| 45 kErrorServiceDeviceIdConflict, | |
| 46 // Service error: Policy not found. Error code defined by the DM folks. | |
| 47 kErrorServicePolicyNotFound = 902, | |
| 48 }; | |
| 49 | |
| 50 // These codes are sent in the |error_code| field of the the | |
| 51 // PolicyFetchResponse protobuf. | |
| 52 enum PolicyFetchErrorCode { | |
| 53 kPolicyFetchSuccess = 200, | |
| 54 kPolicyFetchErrorNotFound = 902 | |
| 55 }; | |
| 56 | |
| 57 class DeviceRegisterResponseDelegate { | |
| 58 public: | |
| 59 virtual ~DeviceRegisterResponseDelegate() {} | |
| 60 virtual void HandleRegisterResponse( | |
| 61 const enterprise_management::DeviceRegisterResponse& response) = 0; | |
| 62 virtual void OnError(ErrorCode code) = 0; | |
| 63 | |
| 64 protected: | |
| 65 DeviceRegisterResponseDelegate() {} | |
| 66 | |
| 67 private: | |
| 68 DISALLOW_COPY_AND_ASSIGN(DeviceRegisterResponseDelegate); | |
| 69 }; | |
| 70 | |
| 71 class DeviceUnregisterResponseDelegate { | |
| 72 public: | |
| 73 virtual ~DeviceUnregisterResponseDelegate() {} | |
| 74 virtual void HandleUnregisterResponse( | |
| 75 const enterprise_management::DeviceUnregisterResponse& response) = 0; | |
| 76 virtual void OnError(ErrorCode code) = 0; | |
| 77 | |
| 78 protected: | |
| 79 DeviceUnregisterResponseDelegate() {} | |
| 80 | |
| 81 private: | |
| 82 DISALLOW_COPY_AND_ASSIGN(DeviceUnregisterResponseDelegate); | |
| 83 }; | |
| 84 | |
| 85 class DevicePolicyResponseDelegate { | |
| 86 public: | |
| 87 virtual ~DevicePolicyResponseDelegate() {} | |
| 88 | |
| 89 virtual void HandlePolicyResponse( | |
| 90 const enterprise_management::DevicePolicyResponse& response) = 0; | |
| 91 virtual void OnError(ErrorCode code) = 0; | |
| 92 | |
| 93 protected: | |
| 94 DevicePolicyResponseDelegate() {} | |
| 95 | |
| 96 private: | |
| 97 DISALLOW_COPY_AND_ASSIGN(DevicePolicyResponseDelegate); | |
| 98 }; | |
| 99 | |
| 100 class DeviceAutoEnrollmentResponseDelegate { | |
| 101 public: | |
| 102 virtual ~DeviceAutoEnrollmentResponseDelegate() {} | |
| 103 | |
| 104 virtual void HandleAutoEnrollmentResponse( | |
| 105 const enterprise_management::DeviceAutoEnrollmentResponse& | |
| 106 response) = 0; | |
| 107 virtual void OnError(ErrorCode code) = 0; | |
| 108 | |
| 109 protected: | |
| 110 DeviceAutoEnrollmentResponseDelegate() {} | |
| 111 | |
| 112 private: | |
| 113 DISALLOW_COPY_AND_ASSIGN(DeviceAutoEnrollmentResponseDelegate); | |
| 114 }; | |
| 115 | |
| 116 virtual ~DeviceManagementBackend() {} | |
| 117 | |
| 118 virtual void ProcessRegisterRequest( | |
| 119 const std::string& gaia_auth_token, | |
| 120 const std::string& oauth_token, | |
| 121 const std::string& device_id, | |
| 122 const enterprise_management::DeviceRegisterRequest& request, | |
| 123 DeviceRegisterResponseDelegate* delegate) = 0; | |
| 124 | |
| 125 virtual void ProcessUnregisterRequest( | |
| 126 const std::string& device_management_token, | |
| 127 const std::string& device_id, | |
| 128 const enterprise_management::DeviceUnregisterRequest& request, | |
| 129 DeviceUnregisterResponseDelegate* delegate) = 0; | |
| 130 | |
| 131 virtual void ProcessPolicyRequest( | |
| 132 const std::string& device_management_token, | |
| 133 const std::string& device_id, | |
| 134 CloudPolicyDataStore::UserAffiliation user_affiliation, | |
| 135 const enterprise_management::DevicePolicyRequest& request, | |
| 136 const enterprise_management::DeviceStatusReportRequest* device_status, | |
| 137 DevicePolicyResponseDelegate* delegate) = 0; | |
| 138 | |
| 139 virtual void ProcessAutoEnrollmentRequest( | |
| 140 const std::string& device_id, | |
| 141 const enterprise_management::DeviceAutoEnrollmentRequest& request, | |
| 142 DeviceAutoEnrollmentResponseDelegate* delegate) = 0; | |
| 143 | |
| 144 protected: | |
| 145 DeviceManagementBackend() {} | |
| 146 | |
| 147 private: | |
| 148 DISALLOW_COPY_AND_ASSIGN(DeviceManagementBackend); | |
| 149 }; | |
| 150 | |
| 151 } // namespace policy | |
| 152 | |
| 153 #endif // CHROME_BROWSER_POLICY_DEVICE_MANAGEMENT_BACKEND_H_ | |
| OLD | NEW |