OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ | 5 #ifndef COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |
6 #define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ | 6 #define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 | 11 |
12 namespace pairing_chromeos { | 12 namespace pairing_chromeos { |
13 | 13 |
14 class HostPairingController { | 14 class HostPairingController { |
15 public: | 15 public: |
16 enum Stage { | 16 enum Stage { |
17 STAGE_NONE, | 17 STAGE_NONE, |
| 18 STAGE_INITIALIZATION_ERROR, |
18 STAGE_WAITING_FOR_CONTROLLER, | 19 STAGE_WAITING_FOR_CONTROLLER, |
19 STAGE_WAITING_FOR_CODE_CONFIRMATION, | 20 STAGE_WAITING_FOR_CODE_CONFIRMATION, |
20 STAGE_UPDATING, | 21 STAGE_UPDATING, |
21 STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE, | 22 STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE, |
22 STAGE_WAITING_FOR_CREDENTIALS, | 23 STAGE_WAITING_FOR_CREDENTIALS, |
23 STAGE_ENROLLING, | 24 STAGE_ENROLLING, |
24 STAGE_ENROLLMENT_ERROR, | 25 STAGE_ENROLLMENT_ERROR, |
25 STAGE_PAIRING_DONE, | 26 STAGE_PAIRING_DONE, |
26 STAGE_FINISHED | 27 STAGE_FINISHED |
27 }; | 28 }; |
28 | 29 |
29 struct UpdateProgress { | 30 enum UpdateStatus { |
30 // Number in [0, 1]. | 31 UPDATE_STATUS_UNKNOWN, |
31 double progress; | 32 UPDATE_STATUS_UPDATING, |
| 33 UPDATE_STATUS_REBOOTING, |
| 34 UPDATE_STATUS_UPDATED, |
32 }; | 35 }; |
33 | 36 |
34 class Observer { | 37 class Observer { |
35 public: | 38 public: |
36 Observer(); | 39 Observer(); |
37 virtual ~Observer(); | 40 virtual ~Observer(); |
38 | 41 |
39 // Called when pairing has moved on from one stage to another. | 42 // Called when pairing has moved on from one stage to another. |
40 virtual void PairingStageChanged(Stage new_stage) = 0; | 43 virtual void PairingStageChanged(Stage new_stage) = 0; |
41 | 44 |
42 // Called periodically on |STAGE_UPDATING| stage. Current update progress | 45 // Called when the controller has sent a configuration to apply. |
43 // is stored in |progress|. | 46 virtual void ConfigureHost(bool accepted_eula, |
44 virtual void UpdateAdvanced(const UpdateProgress& progress) = 0; | 47 const std::string& lang, |
| 48 const std::string& timezone, |
| 49 bool send_reports, |
| 50 const std::string& keyboard_layout) = 0; |
| 51 |
| 52 // Called when the controller has provided an |auth_token| for enrollment. |
| 53 virtual void EnrollHost(const std::string& auth_token) = 0; |
45 | 54 |
46 private: | 55 private: |
47 DISALLOW_COPY_AND_ASSIGN(Observer); | 56 DISALLOW_COPY_AND_ASSIGN(Observer); |
48 }; | 57 }; |
49 | 58 |
50 HostPairingController(); | 59 HostPairingController(); |
51 virtual ~HostPairingController(); | 60 virtual ~HostPairingController(); |
52 | 61 |
53 virtual void AddObserver(Observer* observer) = 0; | |
54 virtual void RemoveObserver(Observer* observer) = 0; | |
55 | |
56 // Returns current stage of pairing process. | 62 // Returns current stage of pairing process. |
57 virtual Stage GetCurrentStage() = 0; | 63 virtual Stage GetCurrentStage() = 0; |
58 | 64 |
59 // Starts pairing process. Can be called only on |STAGE_NONE| stage. | 65 // Starts pairing process. Can be called only on |STAGE_NONE| stage. |
60 virtual void StartPairing() = 0; | 66 virtual void StartPairing() = 0; |
61 | 67 |
62 // Returns device name. | 68 // Returns device name. |
63 virtual std::string GetDeviceName() = 0; | 69 virtual std::string GetDeviceName() = 0; |
64 | 70 |
65 // Returns 6-digit confirmation code. Can be called only on | 71 // Returns 6-digit confirmation code. Can be called only on |
66 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. | 72 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. |
67 virtual std::string GetConfirmationCode() = 0; | 73 virtual std::string GetConfirmationCode() = 0; |
68 | 74 |
69 // Returns an enrollment domain name. Can be called on stage | 75 // Returns an enrollment domain name. Can be called on stage |
70 // |STAGE_ENROLLMENT| and later. | 76 // |STAGE_ENROLLMENT| and later. |
71 virtual std::string GetEnrollmentDomain() = 0; | 77 virtual std::string GetEnrollmentDomain() = 0; |
72 | 78 |
| 79 // Notify that the update status has changed. |
| 80 // Can be called on stage |STAGE_UPDATING|. |
| 81 virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 0; |
| 82 |
| 83 virtual void AddObserver(Observer* observer) = 0; |
| 84 virtual void RemoveObserver(Observer* observer) = 0; |
| 85 |
73 private: | 86 private: |
74 DISALLOW_COPY_AND_ASSIGN(HostPairingController); | 87 DISALLOW_COPY_AND_ASSIGN(HostPairingController); |
75 }; | 88 }; |
76 | 89 |
77 } // namespace pairing_chromeos | 90 } // namespace pairing_chromeos |
78 | 91 |
79 #endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ | 92 #endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |
OLD | NEW |