Chromium Code Reviews| 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; | 62 virtual void AddObserver(Observer* observer) = 0; |
|
achuithb
2014/08/20 23:28:13
Since you're updating this file, can we move these
Zachary Kuznia
2014/08/20 23:34:23
Done.
| |
| 54 virtual void RemoveObserver(Observer* observer) = 0; | 63 virtual void RemoveObserver(Observer* observer) = 0; |
| 55 | 64 |
| 56 // Returns current stage of pairing process. | 65 // Returns current stage of pairing process. |
| 57 virtual Stage GetCurrentStage() = 0; | 66 virtual Stage GetCurrentStage() = 0; |
| 58 | 67 |
| 59 // Starts pairing process. Can be called only on |STAGE_NONE| stage. | 68 // Starts pairing process. Can be called only on |STAGE_NONE| stage. |
| 60 virtual void StartPairing() = 0; | 69 virtual void StartPairing() = 0; |
| 61 | 70 |
| 62 // Returns device name. | 71 // Returns device name. |
| 63 virtual std::string GetDeviceName() = 0; | 72 virtual std::string GetDeviceName() = 0; |
| 64 | 73 |
| 65 // Returns 6-digit confirmation code. Can be called only on | 74 // Returns 6-digit confirmation code. Can be called only on |
| 66 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. | 75 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. |
| 67 virtual std::string GetConfirmationCode() = 0; | 76 virtual std::string GetConfirmationCode() = 0; |
| 68 | 77 |
| 69 // Returns an enrollment domain name. Can be called on stage | 78 // Returns an enrollment domain name. Can be called on stage |
| 70 // |STAGE_ENROLLMENT| and later. | 79 // |STAGE_ENROLLMENT| and later. |
| 71 virtual std::string GetEnrollmentDomain() = 0; | 80 virtual std::string GetEnrollmentDomain() = 0; |
| 72 | 81 |
| 82 // Notify that the update status has changed. | |
| 83 // Can be called on stage |STAGE_UPDATING|. | |
| 84 virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 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 |