1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_
#define COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_
#include <string>
#include <vector>
#include "base/macros.h"
namespace chromeos {
class UserContext;
}
namespace content {
class BrowserContext;
}
namespace pairing_chromeos {
class ControllerPairingController {
public:
enum Stage {
STAGE_NONE,
STAGE_INITIALIZATION_ERROR,
STAGE_DEVICES_DISCOVERY,
STAGE_DEVICE_NOT_FOUND,
STAGE_ESTABLISHING_CONNECTION,
STAGE_ESTABLISHING_CONNECTION_ERROR,
STAGE_WAITING_FOR_CODE_CONFIRMATION,
STAGE_HOST_UPDATE_IN_PROGRESS,
STAGE_HOST_CONNECTION_LOST,
STAGE_WAITING_FOR_CREDENTIALS,
STAGE_HOST_ENROLLMENT_IN_PROGRESS,
STAGE_HOST_ENROLLMENT_ERROR,
STAGE_PAIRING_DONE,
STAGE_FINISHED
};
class Observer {
public:
Observer();
virtual ~Observer();
// Called when pairing has moved on from one stage to another.
virtual void PairingStageChanged(Stage new_stage) = 0;
// Called when new device was discovered or existing device was lost.
// This notification is made only on |STAGE_DEVICES_DISCOVERY| stage.
virtual void DiscoveredDevicesListChanged() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(Observer);
};
typedef std::vector<std::string> DeviceIdList;
ControllerPairingController();
virtual ~ControllerPairingController();
// Returns current stage of pairing process.
virtual Stage GetCurrentStage() = 0;
// Starts pairing process. Can be called only on |STAGE_NONE| stage.
virtual void StartPairing() = 0;
// Returns list of discovered devices. Can be called only on
// |STAGE_DEVICES_DISCOVERY| stage.
virtual DeviceIdList GetDiscoveredDevices() = 0;
// This method is called to start pairing with the device having |device_id|
// ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage.
virtual void ChooseDeviceForPairing(const std::string& device_id) = 0;
// Rescan for devices to pair with. Can be called only on
// stages |STAGE_DEVICE_NOT_FOUND|, |STAGE_ESTABLISHING_CONNECTION_ERROR|,
// |STAGE_HOST_ENROLLMENT_ERROR|.
virtual void RepeatDiscovery() = 0;
// Returns pairing confirmation code.
// Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage.
virtual std::string GetConfirmationCode() = 0;
// Called to confirm or deny confirmation code. Can be called only on
// |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
virtual void SetConfirmationCodeIsCorrect(bool correct) = 0;
// Set the values that will be sent to the host if it needs to be configured.
virtual void SetHostConfiguration(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) = 0;
// Called when user successfully authenticated on GAIA page. Can be called
// only on |STAGE_WAITING_FOR_CREDENTIALS| stage.
// |auth_token| will be sent to the host to be used for enrollment.
virtual void OnAuthenticationDone(const std::string& domain,
const std::string& auth_token) = 0;
// Installs app and starts session.
// Can be called only on |STAGE_PAIRING_DONE| stage.
virtual void StartSession() = 0;
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(ControllerPairingController);
};
} // namespace pairing_chromeos
#endif // COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_
|