Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / pairing / controller_pairing_controller.h
blobd1942927fb26b3c467d38b4f4bbea21ae0b1bb3f
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.
5 #ifndef COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_
6 #define COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_
8 #include <string>
9 #include <vector>
11 #include "base/macros.h"
13 namespace chromeos {
14 class UserContext;
17 namespace content {
18 class BrowserContext;
21 namespace pairing_chromeos {
23 class ControllerPairingController {
24 public:
25 enum Stage {
26 STAGE_NONE,
27 STAGE_INITIALIZATION_ERROR,
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_FINISHED
42 class Observer {
43 public:
44 Observer();
45 virtual ~Observer();
47 // Called when pairing has moved on from one stage to another.
48 virtual void PairingStageChanged(Stage new_stage) = 0;
50 // Called when new device was discovered or existing device was lost.
51 // This notification is made only on |STAGE_DEVICES_DISCOVERY| stage.
52 virtual void DiscoveredDevicesListChanged() = 0;
54 private:
55 DISALLOW_COPY_AND_ASSIGN(Observer);
58 typedef std::vector<std::string> DeviceIdList;
60 ControllerPairingController();
61 virtual ~ControllerPairingController();
63 // Returns current stage of pairing process.
64 virtual Stage GetCurrentStage() = 0;
66 // Starts pairing process. Can be called only on |STAGE_NONE| stage.
67 virtual void StartPairing() = 0;
69 // Returns list of discovered devices. Can be called only on
70 // |STAGE_DEVICES_DISCOVERY| stage.
71 virtual DeviceIdList GetDiscoveredDevices() = 0;
73 // This method is called to start pairing with the device having |device_id|
74 // ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage.
75 virtual void ChooseDeviceForPairing(const std::string& device_id) = 0;
77 // Rescan for devices to pair with. Can be called only on
78 // stages |STAGE_DEVICE_NOT_FOUND|, |STAGE_ESTABLISHING_CONNECTION_ERROR|,
79 // |STAGE_HOST_ENROLLMENT_ERROR|.
80 virtual void RepeatDiscovery() = 0;
82 // Returns pairing confirmation code.
83 // Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage.
84 virtual std::string GetConfirmationCode() = 0;
86 // Called to confirm or deny confirmation code. Can be called only on
87 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
88 virtual void SetConfirmationCodeIsCorrect(bool correct) = 0;
90 // Set the values that will be sent to the host if it needs to be configured.
91 virtual void SetHostConfiguration(bool accepted_eula,
92 const std::string& lang,
93 const std::string& timezone,
94 bool send_reports,
95 const std::string& keyboard_layout) = 0;
97 // Called when user successfully authenticated on GAIA page. Can be called
98 // only on |STAGE_WAITING_FOR_CREDENTIALS| stage.
99 // |auth_token| will be sent to the host to be used for enrollment.
100 virtual void OnAuthenticationDone(const std::string& domain,
101 const std::string& auth_token) = 0;
103 // Installs app and starts session.
104 // Can be called only on |STAGE_PAIRING_DONE| stage.
105 virtual void StartSession() = 0;
107 virtual void AddObserver(Observer* observer) = 0;
108 virtual void RemoveObserver(Observer* observer) = 0;
110 private:
111 DISALLOW_COPY_AND_ASSIGN(ControllerPairingController);
114 } // namespace pairing_chromeos
116 #endif // COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_