Certificate Transparency: Require SCTs for EV certificates.
[chromium-blink-merge.git] / components / pairing / bluetooth_controller_pairing_controller.h
blobedb79bba3e69b1c08ad646b556b3ddfb3817da97
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 CHROMEOS_PAIRING_BLUETOOTH_CONTROLLER_PAIRING_FLOW_H_
6 #define CHROMEOS_PAIRING_BLUETOOTH_CONTROLLER_PAIRING_FLOW_H_
8 #include <set>
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/observer_list.h"
13 #include "base/threading/thread_checker.h"
14 #include "components/pairing/controller_pairing_controller.h"
15 #include "components/pairing/proto_decoder.h"
16 #include "device/bluetooth/bluetooth_adapter.h"
17 #include "device/bluetooth/bluetooth_device.h"
18 #include "device/bluetooth/bluetooth_socket.h"
20 namespace net {
21 class IOBuffer;
24 namespace pairing_chromeos {
26 class BluetoothControllerPairingController
27 : public ControllerPairingController,
28 public ProtoDecoder::Observer,
29 public device::BluetoothAdapter::Observer,
30 public device::BluetoothDevice::PairingDelegate {
31 public:
32 BluetoothControllerPairingController();
33 virtual ~BluetoothControllerPairingController();
35 private:
36 void ChangeStage(Stage new_stage);
37 device::BluetoothDevice* GetController();
38 void Reset();
39 void DeviceFound(device::BluetoothDevice* device);
40 void DeviceLost(device::BluetoothDevice* device);
41 void SendBuffer(scoped_refptr<net::IOBuffer> io_buffer, int size);
42 void CompleteSetup();
44 void OnSetPowered();
45 void OnGetAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
46 void OnStartDiscoverySession(
47 scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
48 void OnConnect();
49 void OnConnectToService(scoped_refptr<device::BluetoothSocket> socket);
50 void OnSendComplete(int bytes_sent);
51 void OnReceiveComplete(int bytes, scoped_refptr<net::IOBuffer> io_buffer);
53 void OnError();
54 void OnErrorWithMessage(const std::string& message);
55 void OnConnectError(device::BluetoothDevice::ConnectErrorCode error_code);
56 void OnReceiveError(device::BluetoothSocket::ErrorReason reason,
57 const std::string& error_message);
59 // ControllerPairingController:
60 virtual void AddObserver(
61 ControllerPairingController::Observer* observer) override;
62 virtual void RemoveObserver(
63 ControllerPairingController::Observer* observer) override;
64 virtual Stage GetCurrentStage() override;
65 virtual void StartPairing() override;
66 virtual DeviceIdList GetDiscoveredDevices() override;
67 virtual void ChooseDeviceForPairing(const std::string& device_id) override;
68 virtual void RepeatDiscovery() override;
69 virtual std::string GetConfirmationCode() override;
70 virtual void SetConfirmationCodeIsCorrect(bool correct) override;
71 virtual void SetHostConfiguration(
72 bool accepted_eula,
73 const std::string& lang,
74 const std::string& timezone,
75 bool send_reports,
76 const std::string& keyboard_layout) override;
77 virtual void OnAuthenticationDone(const std::string& domain,
78 const std::string& auth_token) override;
79 virtual void StartSession() override;
81 // ProtoDecoder::Observer:
82 virtual void OnHostStatusMessage(
83 const pairing_api::HostStatus& message) override;
84 virtual void OnConfigureHostMessage(
85 const pairing_api::ConfigureHost& message) override;
86 virtual void OnPairDevicesMessage(
87 const pairing_api::PairDevices& message) override;
88 virtual void OnCompleteSetupMessage(
89 const pairing_api::CompleteSetup& message) override;
90 virtual void OnErrorMessage(const pairing_api::Error& message) override;
92 // BluetoothAdapter::Observer:
93 virtual void DeviceAdded(device::BluetoothAdapter* adapter,
94 device::BluetoothDevice* device) override;
95 virtual void DeviceRemoved(device::BluetoothAdapter* adapter,
96 device::BluetoothDevice* device) override;
98 // device::BluetoothDevice::PairingDelegate:
99 virtual void RequestPinCode(device::BluetoothDevice* device) override;
100 virtual void RequestPasskey(device::BluetoothDevice* device) override;
101 virtual void DisplayPinCode(device::BluetoothDevice* device,
102 const std::string& pincode) override;
103 virtual void DisplayPasskey(device::BluetoothDevice* device,
104 uint32 passkey) override;
105 virtual void KeysEntered(device::BluetoothDevice* device,
106 uint32 entered) override;
107 virtual void ConfirmPasskey(device::BluetoothDevice* device,
108 uint32 passkey) override;
109 virtual void AuthorizePairing(device::BluetoothDevice* device) override;
111 Stage current_stage_;
112 scoped_refptr<device::BluetoothAdapter> adapter_;
113 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_;
114 scoped_refptr<device::BluetoothSocket> socket_;
115 std::string controller_device_id_;
117 std::string confirmation_code_;
118 std::set<std::string> discovered_devices_;
120 scoped_ptr<ProtoDecoder> proto_decoder_;
122 base::ThreadChecker thread_checker_;
123 ObserverList<ControllerPairingController::Observer> observers_;
124 base::WeakPtrFactory<BluetoothControllerPairingController> ptr_factory_;
126 DISALLOW_COPY_AND_ASSIGN(BluetoothControllerPairingController);
129 } // namespace pairing_chromeos
131 #endif // CHROMEOS_PAIRING_BLUETOOTH_CONTROLLER_PAIRING_FLOW_H_