Add 'did_proceed' and 'repeat_visit' to ClientMalwareReportRequest to track CTR.
[chromium-blink-merge.git] / components / pairing / bluetooth_controller_pairing_controller.h
blobd77f033c893c280ff036b26e76c3c3ea1b5c66dd
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_BLUETOOTH_CONTROLLER_PAIRING_CONTROLLER_H_
6 #define COMPONENTS_PAIRING_BLUETOOTH_CONTROLLER_PAIRING_CONTROLLER_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 ~BluetoothControllerPairingController() override;
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 void AddObserver(ControllerPairingController::Observer* observer) override;
61 void RemoveObserver(ControllerPairingController::Observer* observer) override;
62 Stage GetCurrentStage() override;
63 void StartPairing() override;
64 DeviceIdList GetDiscoveredDevices() override;
65 void ChooseDeviceForPairing(const std::string& device_id) override;
66 void RepeatDiscovery() override;
67 std::string GetConfirmationCode() override;
68 void SetConfirmationCodeIsCorrect(bool correct) override;
69 void SetHostConfiguration(bool accepted_eula,
70 const std::string& lang,
71 const std::string& timezone,
72 bool send_reports,
73 const std::string& keyboard_layout) override;
74 void OnAuthenticationDone(const std::string& domain,
75 const std::string& auth_token) override;
76 void StartSession() override;
78 // ProtoDecoder::Observer:
79 void OnHostStatusMessage(const pairing_api::HostStatus& message) override;
80 void OnConfigureHostMessage(
81 const pairing_api::ConfigureHost& message) override;
82 void OnPairDevicesMessage(const pairing_api::PairDevices& message) override;
83 void OnCompleteSetupMessage(
84 const pairing_api::CompleteSetup& message) override;
85 void OnErrorMessage(const pairing_api::Error& message) override;
86 void OnAddNetworkMessage(const pairing_api::AddNetwork& message) override;
88 // BluetoothAdapter::Observer:
89 void DeviceAdded(device::BluetoothAdapter* adapter,
90 device::BluetoothDevice* device) override;
91 void DeviceRemoved(device::BluetoothAdapter* adapter,
92 device::BluetoothDevice* device) override;
94 // device::BluetoothDevice::PairingDelegate:
95 void RequestPinCode(device::BluetoothDevice* device) override;
96 void RequestPasskey(device::BluetoothDevice* device) override;
97 void DisplayPinCode(device::BluetoothDevice* device,
98 const std::string& pincode) override;
99 void DisplayPasskey(device::BluetoothDevice* device, uint32 passkey) override;
100 void KeysEntered(device::BluetoothDevice* device, uint32 entered) override;
101 void ConfirmPasskey(device::BluetoothDevice* device, uint32 passkey) override;
102 void AuthorizePairing(device::BluetoothDevice* device) override;
104 Stage current_stage_;
105 scoped_refptr<device::BluetoothAdapter> adapter_;
106 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_;
107 scoped_refptr<device::BluetoothSocket> socket_;
108 std::string controller_device_id_;
110 std::string confirmation_code_;
111 std::set<std::string> discovered_devices_;
113 scoped_ptr<ProtoDecoder> proto_decoder_;
115 base::ThreadChecker thread_checker_;
116 base::ObserverList<ControllerPairingController::Observer> observers_;
117 base::WeakPtrFactory<BluetoothControllerPairingController> ptr_factory_;
119 DISALLOW_COPY_AND_ASSIGN(BluetoothControllerPairingController);
122 } // namespace pairing_chromeos
124 #endif // COMPONENTS_PAIRING_BLUETOOTH_CONTROLLER_PAIRING_CONTROLLER_H_