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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h

Issue 184953002: Migrate Chrome OS Bluetooth UI to the new discovery API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "chrome/browser/ui/webui/options/options_ui.h" 14 #include "chrome/browser/ui/webui/options/options_ui.h"
15 #include "device/bluetooth/bluetooth_adapter.h" 15 #include "device/bluetooth/bluetooth_adapter.h"
16 #include "device/bluetooth/bluetooth_device.h" 16 #include "device/bluetooth/bluetooth_device.h"
17 #include "device/bluetooth/bluetooth_discovery_session.h"
17 18
18 namespace base { 19 namespace base {
19 class DictionaryValue; 20 class DictionaryValue;
20 } 21 }
21 22
22 namespace chromeos { 23 namespace chromeos {
23 namespace options { 24 namespace options {
24 25
25 // Handler for Bluetooth options on the system options page. 26 // Handler for Bluetooth options on the system options page.
26 class BluetoothOptionsHandler 27 class BluetoothOptionsHandler
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 device::BluetoothDevice* device) OVERRIDE; 148 device::BluetoothDevice* device) OVERRIDE;
148 149
149 private: 150 private:
150 // Displays in the UI a connecting to the device |device| message. 151 // Displays in the UI a connecting to the device |device| message.
151 void DeviceConnecting(device::BluetoothDevice* device); 152 void DeviceConnecting(device::BluetoothDevice* device);
152 153
153 // Called by device::BluetoothAdapter in response to a failure to 154 // Called by device::BluetoothAdapter in response to a failure to
154 // change the power status of the adapter. 155 // change the power status of the adapter.
155 void EnableChangeError(); 156 void EnableChangeError();
156 157
158 // Called by device::BluetoothAdapter in response to a successful request
159 // to initiate a discovery session.
160 void OnStartDiscoverySession(
161 scoped_ptr<device::BluetoothDiscoverySession> discovery_session);
162
157 // Called by device::BluetoothAdapter in response to a failure to 163 // Called by device::BluetoothAdapter in response to a failure to
158 // set the adapter into discovery mode. 164 // initiate a discovery session.
159 void FindDevicesError(); 165 void FindDevicesError();
160 166
161 // Called by device::BluetoothAdapter in response to a failure to 167 // Called by device::BluetoothAdapter in response to a failure to
162 // remove the adapter from discovery mode. 168 // terminate a discovery session.
163 void StopDiscoveryError(); 169 void StopDiscoveryError();
164 170
165 // Called by device::BluetoothDevice on a successful pairing and connection 171 // Called by device::BluetoothDevice on a successful pairing and connection
166 // to a device. 172 // to a device.
167 void Connected(); 173 void Connected();
168 174
169 // Called by device::BluetoothDevice in response to a failure to 175 // Called by device::BluetoothDevice in response to a failure to
170 // connect to the device with bluetooth address |address| due to an error 176 // connect to the device with bluetooth address |address| due to an error
171 // encoded in |error_code|. 177 // encoded in |error_code|.
172 void ConnectError(const std::string& address, 178 void ConnectError(const std::string& address,
(...skipping 30 matching lines...) Expand all
203 void StopDiscoveryCallback(const base::ListValue* args); 209 void StopDiscoveryCallback(const base::ListValue* args);
204 210
205 // Called when the list of paired devices is initialized in order to 211 // Called when the list of paired devices is initialized in order to
206 // populate the list. 212 // populate the list.
207 // |args| will be an empty list. 213 // |args| will be an empty list.
208 void GetPairedDevicesCallback(const base::ListValue* args); 214 void GetPairedDevicesCallback(const base::ListValue* args);
209 215
210 // Default bluetooth adapter, used for all operations. 216 // Default bluetooth adapter, used for all operations.
211 scoped_refptr<device::BluetoothAdapter> adapter_; 217 scoped_refptr<device::BluetoothAdapter> adapter_;
212 218
213 // True while performing device discovery. 219 // The current device discovery session. Only one active discovery session is
214 bool discovering_; 220 // kept at a time and the instance that |discovery_session_| points to gets
221 // replaced by a new one when a new discovery session is initiated.
222 scoped_ptr<device::BluetoothDiscoverySession> discovery_session_;
215 223
216 // Cached information about the current pairing device, if any. 224 // Cached information about the current pairing device, if any.
217 std::string pairing_device_address_; 225 std::string pairing_device_address_;
218 std::string pairing_device_pairing_; 226 std::string pairing_device_pairing_;
219 std::string pairing_device_pincode_; 227 std::string pairing_device_pincode_;
220 int pairing_device_passkey_; 228 int pairing_device_passkey_;
221 int pairing_device_entered_; 229 int pairing_device_entered_;
222 230
223 // Weak pointer factory for generating 'this' pointers that might live longer 231 // Weak pointer factory for generating 'this' pointers that might live longer
224 // than this object does. 232 // than this object does.
225 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; 233 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_;
226 234
227 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); 235 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler);
228 }; 236 };
229 237
230 } // namespace options 238 } // namespace options
231 } // namespace chromeos 239 } // namespace chromeos
232 240
233 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ 241 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698