OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 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_CHROMEOS_POLICY_ANDROID_MANAGEMENT_CLIENT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ANDROID_MANAGEMENT_CLIENT_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" |
| 14 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 15 #include "net/url_request/url_request_context_getter.h" |
| 16 |
| 17 namespace enterprise_management { |
| 18 class DeviceManagementResponse; |
| 19 } |
| 20 |
| 21 namespace policy { |
| 22 |
| 23 class DeviceManagementRequestJob; |
| 24 class DeviceManagementService; |
| 25 |
| 26 // Interacts with the device management service and determines whether Android |
| 27 // management is enabled for the user or not. |
| 28 class AndroidManagementClient { |
| 29 public: |
| 30 // Indicates result of the android management check. |
| 31 enum Result { |
| 32 RESULT_MANAGED, // Android management is enabled. |
| 33 RESULT_UNMANAGED, // Android management is disabled. |
| 34 RESULT_ERROR, // Received a error. |
| 35 }; |
| 36 |
| 37 // A callback which receives Result status of an operation. |
| 38 using StatusCallback = base::Callback<void(Result)>; |
| 39 |
| 40 AndroidManagementClient( |
| 41 DeviceManagementService* service, |
| 42 scoped_refptr<net::URLRequestContextGetter> request_context); |
| 43 ~AndroidManagementClient(); |
| 44 |
| 45 // Sends a check Android management request to the device management service. |
| 46 void CheckAndroidManagement(const std::string& auth_token, |
| 47 const StatusCallback& callback); |
| 48 |
| 49 private: |
| 50 // Callback for check Android management requests. |
| 51 void OnAndroidManagementChecked( |
| 52 const StatusCallback& callback, |
| 53 DeviceManagementStatus status, |
| 54 int net_error, |
| 55 const enterprise_management::DeviceManagementResponse& response); |
| 56 |
| 57 // Used to communicate with the device management service. |
| 58 DeviceManagementService* service_; |
| 59 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 60 std::unique_ptr<DeviceManagementRequestJob> request_job_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(AndroidManagementClient); |
| 63 }; |
| 64 |
| 65 } // namespace policy |
| 66 |
| 67 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ANDROID_MANAGEMENT_CLIENT_H_ |
OLD | NEW |