Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h

Issue 252503002: Base version of HID detection OOBE screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Logic bug-fix. Progress dots hidden. Style improved. BT names support. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H_
7 7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/values.h"
15 #include "chrome/browser/chromeos/device/input_service_proxy.h"
8 #include "chrome/browser/chromeos/login/screens/hid_detection_screen_actor.h" 16 #include "chrome/browser/chromeos/login/screens/hid_detection_screen_actor.h"
9 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" 17 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h"
10 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
19 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_device.h"
21 #include "device/bluetooth/bluetooth_discovery_session.h"
22
11 23
12 namespace base { 24 namespace base {
13 class DictionaryValue; 25 class DictionaryValue;
14 } 26 }
15 27
16 namespace chromeos { 28 namespace chromeos {
17 29
18 // WebUI implementation of HIDDetectionScreenActor. 30 // WebUI implementation of HIDDetectionScreenActor.
19 class HIDDetectionScreenHandler : public HIDDetectionScreenActor, 31 class HIDDetectionScreenHandler
20 public BaseScreenHandler { 32 : public HIDDetectionScreenActor,
33 public BaseScreenHandler,
34 public device::BluetoothAdapter::Observer,
35 public device::BluetoothDevice::PairingDelegate,
36 public InputServiceProxy::Observer {
21 public: 37 public:
38 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo;
39
22 HIDDetectionScreenHandler(); 40 HIDDetectionScreenHandler();
23 virtual ~HIDDetectionScreenHandler(); 41 virtual ~HIDDetectionScreenHandler();
24 42
25 // HIDDetectionScreenActor implementation: 43 // HIDDetectionScreenActor implementation:
26 virtual void PrepareToShow() OVERRIDE; 44 virtual void PrepareToShow() OVERRIDE;
27 virtual void Show() OVERRIDE; 45 virtual void Show() OVERRIDE;
28 virtual void Hide() OVERRIDE; 46 virtual void Hide() OVERRIDE;
29 virtual void SetDelegate(Delegate* delegate) OVERRIDE; 47 virtual void SetDelegate(Delegate* delegate) OVERRIDE;
30 48
31 // BaseScreenHandler implementation: 49 // BaseScreenHandler implementation:
32 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE; 50 virtual void DeclareLocalizedValues(LocalizedValuesBuilder* builder) OVERRIDE;
33 virtual void Initialize() OVERRIDE; 51 virtual void Initialize() OVERRIDE;
34 52
35 // WebUIMessageHandler implementation: 53 // WebUIMessageHandler implementation:
36 virtual void RegisterMessages() OVERRIDE; 54 virtual void RegisterMessages() OVERRIDE;
37 55
56 // device::BluetoothDevice::PairingDelegate implementation:
57 virtual void RequestPinCode(device::BluetoothDevice* device) OVERRIDE;
58 virtual void RequestPasskey(device::BluetoothDevice* device) OVERRIDE;
59 virtual void DisplayPinCode(device::BluetoothDevice* device,
60 const std::string& pincode) OVERRIDE;
61 virtual void DisplayPasskey(
62 device::BluetoothDevice* device, uint32 passkey) OVERRIDE;
63 virtual void KeysEntered(device::BluetoothDevice* device,
64 uint32 entered) OVERRIDE;
65 virtual void ConfirmPasskey(
66 device::BluetoothDevice* device, uint32 passkey) OVERRIDE;
67 virtual void AuthorizePairing(device::BluetoothDevice* device) OVERRIDE;
68
69 // device::BluetoothAdapter::Observer implementation.
70 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter,
71 bool present) OVERRIDE;
72 virtual void DeviceAdded(device::BluetoothAdapter* adapter,
73 device::BluetoothDevice* device) OVERRIDE;
74 virtual void DeviceChanged(device::BluetoothAdapter* adapter,
75 device::BluetoothDevice* device) OVERRIDE;
76 virtual void DeviceRemoved(device::BluetoothAdapter* adapter,
77 device::BluetoothDevice* device) OVERRIDE;
78
79 // InputServiceProxy::Observer implementation.
80 virtual void OnInputDeviceAdded(const InputDeviceInfo& info) OVERRIDE;
81 virtual void OnInputDeviceRemoved(const std::string& id) OVERRIDE;
82
38 private: 83 private:
84 void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
85
86 // Sends a notification to the Web UI of the status of available Bluetooth/USB
87 // pointing device.
88 void SendPointingDeviceNotification();
89
90 // Sends a notification to the Web UI of the status of available Bluetooth/USB
91 // keyboard device.
92 void SendKeyboardDeviceNotification(base::DictionaryValue* params);
93 void OnGetInputDevicesList(bool skip_screen_if_devices_present,
94 const std::vector<InputDeviceInfo>& devices);
95
96 void StartBTDiscoverySession();
97
98 // Called by device::BluetoothDevice on a successful pairing and connection
99 // to a device.
100 void BTConnected();
101
102 // Called by device::BluetoothDevice in response to a failure to
103 // connect to the device with bluetooth address |address| due to an error
104 // encoded in |error_code|.
105 void BTConnectError(const std::string& address,
106 device::BluetoothDevice::ConnectErrorCode error_code);
107
39 // JS messages handlers. 108 // JS messages handlers.
40 void HandleOnContinue(); 109 void HandleOnContinue();
41 110
42 Delegate* delegate_; 111 Delegate* delegate_;
43 112
44 // Keeps whether screen should be shown right after initialization. 113 // Keeps whether screen should be shown right after initialization.
45 bool show_on_init_; 114 bool show_on_init_;
46 115
116 // Displays in the UI a connecting to the device |device| message.
117 void DeviceConnecting(device::BluetoothDevice* device);
118
119 // Called by device::BluetoothAdapter in response to a failure to
120 // change the power status of the adapter.
121 void EnableChangeError();
122
123 // Called by device::BluetoothAdapter in response to a successful request
124 // to initiate a discovery session.
125 void OnStartDiscoverySession(
126 scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
127
128 // Called by device::BluetoothAdapter in response to a failure to
129 // initiate a discovery session.
130 void FindDevicesError();
131
132 // Called by device::BluetoothAdapter in response to a failure to
133 // power BT adapter.
134 void SetPoweredError();
135
136 // Called by device::BluetoothAdapter in response to a failure to
137 // terminate a discovery session.
138 void StopDiscoveryError();
139
140 // Called by device::BluetoothDevice on a successful pairing and connection
141 // to a device.
142 void Connected();
143
144 // Called by device::BluetoothDevice in response to a failure to
145 // connect to the device with bluetooth address |address| due to an error
146 // encoded in |error_code|.
147 void ConnectError(const std::string& address,
148 device::BluetoothDevice::ConnectErrorCode error_code);
149
150 // Called by device::BluetoothDevice in response to a failure to
151 // disconnect the device with bluetooth address |address|.
152 void DisconnectError(const std::string& address);
153
154 // Called by device::BluetoothDevice in response to a failure to
155 // disconnect and unpair the device with bluetooth address |address|.
156 void ForgetError(const std::string& address);
157
158 // Called when the 'Enable bluetooth' checkbox value is changed.
159 // |args| will contain the checkbox checked state as a string
160 // ("true" or "false").
161 void EnableChangeCallback(const base::ListValue* args);
162
163 // Called when the 'Find Devices' button is pressed from the Bluetooth
164 // ssettings.
165 // |args| will be an empty list.
166 void FindDevicesCallback(const base::ListValue* args);
167
168 // Called when the "Add a device" dialog closes to stop the discovery
169 // process.
170 // |args| will be an empty list.
171 void StopDiscoveryCallback(const base::ListValue* args);
172
173 // Called when the list of paired devices is initialized in order to
174 // populate the list.
175 // |args| will be an empty list.
176 void GetPairedDevicesCallback(const base::ListValue* args);
177
178 // Called for revision of active devices. If current-placement is available
179 // for mouse or keyboard device, sets one of active devices as current or
180 // tries to connect some BT device if no appropriate devices are connected.
181 void UpdateDevices(bool skip_screen_if_devices_present);
182
183 // Tries to connect some BT devices if no type-appropriate devices are
184 // connected.
185 void UpdateBTDevices();
186
187 // Tries to connect given BT device.
188 void ConnectBTDevice(device::BluetoothDevice* device);
189
190 // Default bluetooth adapter, used for all operations.
191 scoped_refptr<device::BluetoothAdapter> adapter_;
192
193 InputServiceProxy input_service_proxy_;
194
195 // True, if the UI has requested device discovery. False, if either no device
196 // discovery was requested or the dialog responsible for device discovery was
197 // dismissed.
198 bool should_run_device_discovery_;
199
200 // The current device discovery session. Only one active discovery session is
201 // kept at a time and the instance that |discovery_session_| points to gets
202 // replaced by a new one when a new discovery session is initiated.
203 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_;
204
205 // Cached information about the current pairing device, if any.
206 std::string pairing_device_address_;
207 std::string pairing_device_pairing_;
208 std::string pairing_device_pincode_;
209 int pairing_device_passkey_;
210 int pairing_device_entered_;
211
212 // Current pointing device, if any.
213 std::string pointing_device_name_;
214 std::string pointing_device_id_;
215 InputDeviceInfo::Type pointing_device_connect_type_;
216
217 // Current keyboard device, if any.
218 std::string keyboard_device_name_;
219 std::string keyboard_device_id_;
220 bool keyboard_is_connecting_;
221 InputDeviceInfo::Type keyboard_device_connect_type_;
222
223 bool switch_on_adapter_when_ready_;
224
225 base::WeakPtrFactory<HIDDetectionScreenHandler> weak_ptr_factory_;
226
47 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenHandler); 227 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenHandler);
48 }; 228 };
49 229
50 } // namespace chromeos 230 } // namespace chromeos
51 231
52 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H _ 232 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_HID_DETECTION_SCREEN_HANDLER_H _
53 233
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698