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::string DeviceID; | |
stevenjb
2014/06/02 16:35:57
I think that typdefing to a string adds more poten
dzhioev (left Google)
2014/06/02 19:58:26
Done.
| |
60 | |
61 public: | |
stevenjb
2014/06/02 16:35:57
Remove duplicate 'public'
dzhioev (left Google)
2014/06/02 19:58:26
Done.
| |
62 ControllerPairingFlow(); | |
63 virtual ~ControllerPairingFlow(); | |
64 | |
65 virtual void AddObserver(Observer* observer) = 0; | |
66 virtual void RemoveObserver(Observer* observer) = 0; | |
67 | |
68 // Returns current stage of flow. | |
69 virtual Stage GetCurrentStage() = 0; | |
70 | |
71 // Starts pairing flow. Can be called only on |STAGE_NONE| stage. | |
72 virtual void StartFlow() = 0; | |
73 | |
74 // Returns list of discovered devices. Can be called only on | |
75 // |STAGE_DEVICES_DISCOVERY| stage. | |
76 virtual std::vector<DeviceID> GetDiscoveredDevices() = 0; | |
77 | |
78 // This method is called to start pairing with the device having |device_id| | |
79 // ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage. | |
80 virtual void ChooseDeviceForPairing(const DeviceID& device_id) = 0; | |
81 | |
82 // Rescan for devices to pair with. Can be called only on | |
83 // |STAGE_DEVICE_NOT_FOUND| stage. | |
84 virtual void RepeatDiscovery() = 0; | |
85 | |
86 // Returns pairing confirmation code. | |
87 // Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage. | |
88 virtual std::string GetConfirmationCode() = 0; | |
89 | |
90 // Called to confirm or deny confirmation code. Can be called only on | |
91 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. | |
92 virtual void SetConfirmationCodeIsRight(bool right) = 0; | |
stevenjb
2014/06/02 16:35:57
s/Right/Correct/
dzhioev (left Google)
2014/06/02 19:58:26
Done.
| |
93 | |
94 // Called when user successfully authenticated on GAIA page. Can be called | |
95 // only on |STAGE_WAITING_FOR_CREDENTIALS| stage. | |
96 virtual void OnAuthenticationDone( | |
97 const chromeos::UserContext& user_context, | |
98 content::BrowserContext* browser_context) = 0; | |
99 | |
100 // Installs app and starts session. | |
101 // Can be called only on |STAGE_PAIRING_DONE| stage. | |
102 virtual void StartSession() = 0; | |
stevenjb
2014/06/02 16:35:57
WS
dzhioev (left Google)
2014/06/02 19:58:26
Done.
| |
103 private: | |
104 DISALLOW_COPY_AND_ASSIGN(ControllerPairingFlow); | |
105 }; | |
106 | |
107 } // namespace chromeos | |
108 | |
109 #endif // CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ | |
OLD | NEW |