Extension syncing: Introduce a NeedsSync pref
[chromium-blink-merge.git] / components / pairing / controller_pairing_controller.h
blob60b17a922f6429c384707af4f38c2e8836166b49
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_PAIRING_DONE,
34 STAGE_HOST_UPDATE_IN_PROGRESS,
35 STAGE_HOST_CONNECTION_LOST,
36 STAGE_WAITING_FOR_CREDENTIALS,
37 STAGE_HOST_ENROLLMENT_IN_PROGRESS,
38 STAGE_HOST_ENROLLMENT_ERROR,
39 STAGE_HOST_ENROLLMENT_SUCCESS,
40 STAGE_FINISHED
43 class Observer {
44 public:
45 Observer();
46 virtual ~Observer();
48 // Called when pairing has moved on from one stage to another.
49 virtual void PairingStageChanged(Stage new_stage) = 0;
51 // Called when new device was discovered or existing device was lost.
52 // This notification is made only on |STAGE_DEVICES_DISCOVERY| stage.
53 virtual void DiscoveredDevicesListChanged() = 0;
55 private:
56 DISALLOW_COPY_AND_ASSIGN(Observer);
59 typedef std::vector<std::string> DeviceIdList;
61 ControllerPairingController();
62 virtual ~ControllerPairingController();
64 // Returns current stage of pairing process.
65 virtual Stage GetCurrentStage() = 0;
67 // Starts pairing process. Can be called only on |STAGE_NONE| stage.
68 virtual void StartPairing() = 0;
70 // Returns list of discovered devices. Can be called only on
71 // |STAGE_DEVICES_DISCOVERY| stage.
72 virtual DeviceIdList GetDiscoveredDevices() = 0;
74 // This method is called to start pairing with the device having |device_id|
75 // ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage.
76 virtual void ChooseDeviceForPairing(const std::string& device_id) = 0;
78 // Rescan for devices to pair with. Can be called only on
79 // stages |STAGE_DEVICE_NOT_FOUND|, |STAGE_ESTABLISHING_CONNECTION_ERROR|,
80 // |STAGE_HOST_ENROLLMENT_ERROR|.
81 virtual void RepeatDiscovery() = 0;
83 // Returns pairing confirmation code.
84 // Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage.
85 virtual std::string GetConfirmationCode() = 0;
87 // Called to confirm or deny confirmation code. Can be called only on
88 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
89 virtual void SetConfirmationCodeIsCorrect(bool correct) = 0;
91 // Set the values that will be sent to the host if it needs to be configured.
92 virtual void SetHostConfiguration(bool accepted_eula,
93 const std::string& lang,
94 const std::string& timezone,
95 bool send_reports,
96 const std::string& keyboard_layout) = 0;
98 // Called when user successfully authenticated on GAIA page. Can be called
99 // only on |STAGE_WAITING_FOR_CREDENTIALS| stage.
100 // |auth_token| will be sent to the host to be used for enrollment.
101 virtual void OnAuthenticationDone(const std::string& domain,
102 const std::string& auth_token) = 0;
104 // Installs app and starts session.
105 // Can be called only on |STAGE_HOST_ENROLLMENT_SUCCESS| stage.
106 virtual void StartSession() = 0;
108 virtual void AddObserver(Observer* observer) = 0;
109 virtual void RemoveObserver(Observer* observer) = 0;
111 private:
112 DISALLOW_COPY_AND_ASSIGN(ControllerPairingController);
115 } // namespace pairing_chromeos
117 #endif // COMPONENTS_PAIRING_CONTROLLER_PAIRING_CONTROLLER_H_