OLD | NEW |
(Empty) | |
| 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 |
| 5 #ifndef CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ |
| 6 #define CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "chromeos/chromeos_export.h" |
| 13 |
| 14 namespace chromeos { |
| 15 class UserContext; |
| 16 } |
| 17 |
| 18 namespace content { |
| 19 class BrowserContext; |
| 20 } |
| 21 |
| 22 namespace chromeos { |
| 23 |
| 24 class CHROMEOS_EXPORT ControllerPairingFlow { |
| 25 public: |
| 26 enum Stage { |
| 27 STAGE_NONE, |
| 28 STAGE_DEVICES_DISCOVERY, |
| 29 STAGE_DEVICE_NOT_FOUND, |
| 30 STAGE_ESTABLISHING_CONNECTION, |
| 31 STAGE_ESTABLISHING_CONNECTION_ERROR, |
| 32 STAGE_WAITING_FOR_CODE_CONFIRMATION, |
| 33 STAGE_HOST_UPDATE_IN_PROGRESS, |
| 34 STAGE_HOST_CONNECTION_LOST, |
| 35 STAGE_WAITING_FOR_CREDENTIALS, |
| 36 STAGE_HOST_ENROLLMENT_IN_PROGRESS, |
| 37 STAGE_HOST_ENROLLMENT_ERROR, |
| 38 STAGE_PAIRING_DONE, |
| 39 STAGE_STARTING_SESSION, |
| 40 STAGE_FINISHED |
| 41 }; |
| 42 |
| 43 class Observer { |
| 44 public: |
| 45 Observer(); |
| 46 virtual ~Observer(); |
| 47 |
| 48 // Called when flow has moved on from one stage to another. |
| 49 virtual void PairingStageChanged(Stage new_stage) = 0; |
| 50 |
| 51 // Called when new device was discovered or existing device was lost. |
| 52 // This notification is made only on |STAGE_SCANNING_FOR_DEVICES| stage. |
| 53 virtual void DiscoveredDevicesListChanged() = 0; |
| 54 |
| 55 private: |
| 56 DISALLOW_COPY_AND_ASSIGN(Observer); |
| 57 }; |
| 58 |
| 59 typedef std::vector<std::string> DeviceIdList; |
| 60 |
| 61 ControllerPairingFlow(); |
| 62 virtual ~ControllerPairingFlow(); |
| 63 |
| 64 virtual void AddObserver(Observer* observer) = 0; |
| 65 virtual void RemoveObserver(Observer* observer) = 0; |
| 66 |
| 67 // Returns current stage of flow. |
| 68 virtual Stage GetCurrentStage() = 0; |
| 69 |
| 70 // Starts pairing flow. Can be called only on |STAGE_NONE| stage. |
| 71 virtual void StartFlow() = 0; |
| 72 |
| 73 // Returns list of discovered devices. Can be called only on |
| 74 // |STAGE_DEVICES_DISCOVERY| stage. |
| 75 virtual DeviceIdList GetDiscoveredDevices() = 0; |
| 76 |
| 77 // This method is called to start pairing with the device having |device_id| |
| 78 // ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage. |
| 79 virtual void ChooseDeviceForPairing(const std::string& device_id) = 0; |
| 80 |
| 81 // Rescan for devices to pair with. Can be called only on |
| 82 // |STAGE_DEVICE_NOT_FOUND| stage. |
| 83 virtual void RepeatDiscovery() = 0; |
| 84 |
| 85 // Returns pairing confirmation code. |
| 86 // Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage. |
| 87 virtual std::string GetConfirmationCode() = 0; |
| 88 |
| 89 // Called to confirm or deny confirmation code. Can be called only on |
| 90 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. |
| 91 virtual void SetConfirmationCodeIsCorrect(bool right) = 0; |
| 92 |
| 93 // Called when user successfully authenticated on GAIA page. Can be called |
| 94 // only on |STAGE_WAITING_FOR_CREDENTIALS| stage. |
| 95 virtual void OnAuthenticationDone( |
| 96 const chromeos::UserContext& user_context, |
| 97 content::BrowserContext* browser_context) = 0; |
| 98 |
| 99 // Installs app and starts session. |
| 100 // Can be called only on |STAGE_PAIRING_DONE| stage. |
| 101 virtual void StartSession() = 0; |
| 102 |
| 103 private: |
| 104 DISALLOW_COPY_AND_ASSIGN(ControllerPairingFlow); |
| 105 }; |
| 106 |
| 107 } // namespace chromeos |
| 108 |
| 109 #endif // CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ |
OLD | NEW |