[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 7d54a19 | 2014-07-22 00:17:38 | [diff] [blame^] | 5 | #ifndef COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |
| 6 | #define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/macros.h" |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 11 | |
[email protected] | 7d54a19 | 2014-07-22 00:17:38 | [diff] [blame^] | 12 | namespace pairing_chromeos { |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 13 | |
[email protected] | 7d54a19 | 2014-07-22 00:17:38 | [diff] [blame^] | 14 | class HostPairingController { |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 15 | public: |
| 16 | enum Stage { |
| 17 | STAGE_NONE, |
| 18 | STAGE_WAITING_FOR_CONTROLLER, |
| 19 | STAGE_WAITING_FOR_CODE_CONFIRMATION, |
| 20 | STAGE_UPDATING, |
| 21 | STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE, |
| 22 | STAGE_WAITING_FOR_CREDENTIALS, |
| 23 | STAGE_ENROLLING, |
| 24 | STAGE_ENROLLMENT_ERROR, |
| 25 | STAGE_PAIRING_DONE, |
| 26 | STAGE_FINISHED |
| 27 | }; |
| 28 | |
| 29 | struct UpdateProgress { |
| 30 | // Number in [0, 1]. |
| 31 | double progress; |
| 32 | }; |
| 33 | |
| 34 | class Observer { |
| 35 | public: |
| 36 | Observer(); |
| 37 | virtual ~Observer(); |
| 38 | |
| 39 | // Called when pairing has moved on from one stage to another. |
| 40 | virtual void PairingStageChanged(Stage new_stage) = 0; |
| 41 | |
| 42 | // Called periodically on |STAGE_UPDATING| stage. Current update progress |
| 43 | // is stored in |progress|. |
| 44 | virtual void UpdateAdvanced(const UpdateProgress& progress) = 0; |
| 45 | |
| 46 | private: |
| 47 | DISALLOW_COPY_AND_ASSIGN(Observer); |
| 48 | }; |
| 49 | |
| 50 | HostPairingController(); |
| 51 | virtual ~HostPairingController(); |
| 52 | |
| 53 | virtual void AddObserver(Observer* observer) = 0; |
| 54 | virtual void RemoveObserver(Observer* observer) = 0; |
| 55 | |
| 56 | // Returns current stage of pairing process. |
| 57 | virtual Stage GetCurrentStage() = 0; |
| 58 | |
| 59 | // Starts pairing process. Can be called only on |STAGE_NONE| stage. |
| 60 | virtual void StartPairing() = 0; |
| 61 | |
| 62 | // Returns device name. |
| 63 | virtual std::string GetDeviceName() = 0; |
| 64 | |
| 65 | // Returns 6-digit confirmation code. Can be called only on |
| 66 | // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. |
| 67 | virtual std::string GetConfirmationCode() = 0; |
| 68 | |
[email protected] | 7730e38 | 2014-07-04 18:38:05 | [diff] [blame] | 69 | // Returns an enrollment domain name. Can be called on stage |
| 70 | // |STAGE_ENROLLMENT| and later. |
| 71 | virtual std::string GetEnrollmentDomain() = 0; |
| 72 | |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 73 | private: |
| 74 | DISALLOW_COPY_AND_ASSIGN(HostPairingController); |
| 75 | }; |
| 76 | |
[email protected] | 7d54a19 | 2014-07-22 00:17:38 | [diff] [blame^] | 77 | } // namespace pairing_chromeos |
[email protected] | 03c32fe1 | 2014-06-24 17:34:54 | [diff] [blame] | 78 | |
[email protected] | 7d54a19 | 2014-07-22 00:17:38 | [diff] [blame^] | 79 | #endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ |