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

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

Issue 11075006: Moved bluetooth adapter files to device/bluetooth/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: renamed 'bluetooth' target to 'device_bluetooth'. Created 8 years, 2 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/chromeos/bluetooth/bluetooth_adapter.h"
15 #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
16 #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"
16 #include "device/bluetooth/bluetooth_device.h"
17 17
18 namespace base { 18 namespace base {
19 class DictionaryValue; 19 class DictionaryValue;
20 } 20 }
21 21
22 namespace chromeos { 22 namespace chromeos {
23 namespace options { 23 namespace options {
24 24
25 // Handler for Bluetooth options on the system options page. 25 // Handler for Bluetooth options on the system options page.
26 class BluetoothOptionsHandler : public ::options::OptionsPageUIHandler, 26 class BluetoothOptionsHandler
27 public chromeos::BluetoothAdapter::Observer, 27 : public ::options::OptionsPageUIHandler,
28 public BluetoothDevice::PairingDelegate { 28 public device::BluetoothAdapter::Observer,
29 public device::BluetoothDevice::PairingDelegate {
29 public: 30 public:
30 BluetoothOptionsHandler(); 31 BluetoothOptionsHandler();
31 virtual ~BluetoothOptionsHandler(); 32 virtual ~BluetoothOptionsHandler();
32 33
33 // OptionsPageUIHandler implementation. 34 // OptionsPageUIHandler implementation.
34 virtual void GetLocalizedValues( 35 virtual void GetLocalizedValues(
35 base::DictionaryValue* localized_strings) OVERRIDE; 36 base::DictionaryValue* localized_strings) OVERRIDE;
36 virtual void RegisterMessages() OVERRIDE; 37 virtual void RegisterMessages() OVERRIDE;
37 virtual void InitializeHandler() OVERRIDE; 38 virtual void InitializeHandler() OVERRIDE;
38 virtual void InitializePage() OVERRIDE; 39 virtual void InitializePage() OVERRIDE;
39 40
40 // Sends a notification to the Web UI of the status of a Bluetooth device. 41 // Sends a notification to the Web UI of the status of a Bluetooth device.
41 // |device| is the Bluetooth device. 42 // |device| is the Bluetooth device.
42 // |params| is an optional set of parameters. 43 // |params| is an optional set of parameters.
43 void SendDeviceNotification(const BluetoothDevice* device, 44 void SendDeviceNotification(const device::BluetoothDevice* device,
44 base::DictionaryValue* params); 45 base::DictionaryValue* params);
45 46
46 // BluetoothDevice::PairingDelegate override. 47 // device::BluetoothDevice::PairingDelegate override.
47 // 48 //
48 // This method will be called when the Bluetooth daemon requires a 49 // This method will be called when the Bluetooth daemon requires a
49 // PIN Code for authentication of the device |device|, the UI will display 50 // PIN Code for authentication of the device |device|, the UI will display
50 // a blank entry form to obtain the PIN code from the user. 51 // a blank entry form to obtain the PIN code from the user.
51 // 52 //
52 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices 53 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices
53 // for which there is no automatic pairing or special handling. 54 // for which there is no automatic pairing or special handling.
54 virtual void RequestPinCode(BluetoothDevice* device) OVERRIDE; 55 virtual void RequestPinCode(device::BluetoothDevice* device) OVERRIDE;
55 56
56 // BluetoothDevice::PairingDelegate override. 57 // device::BluetoothDevice::PairingDelegate override.
57 // 58 //
58 // This method will be called when the Bluetooth daemon requires a 59 // This method will be called when the Bluetooth daemon requires a
59 // Passkey for authentication of the device |device|, the UI will display 60 // Passkey for authentication of the device |device|, the UI will display
60 // a blank entry form to obtain the passkey from the user (a numeric in the 61 // a blank entry form to obtain the passkey from the user (a numeric in the
61 // range 0-999999). 62 // range 0-999999).
62 // 63 //
63 // Passkeys are generally required for Bluetooth 2.1 and later devices 64 // Passkeys are generally required for Bluetooth 2.1 and later devices
64 // which cannot provide input or display on their own, and don't accept 65 // which cannot provide input or display on their own, and don't accept
65 // passkey-less pairing. 66 // passkey-less pairing.
66 virtual void RequestPasskey(BluetoothDevice* device) OVERRIDE; 67 virtual void RequestPasskey(device::BluetoothDevice* device) OVERRIDE;
67 68
68 // BluetoothDevice::PairingDelegate override. 69 // device::BluetoothDevice::PairingDelegate override.
69 // 70 //
70 // This method will be called when the Bluetooth daemon requires that the 71 // This method will be called when the Bluetooth daemon requires that the
71 // user enter the PIN code |pincode| into the device |device| so that it 72 // user enter the PIN code |pincode| into the device |device| so that it
72 // may be authenticated, the UI will display the PIN code with accompanying 73 // may be authenticated, the UI will display the PIN code with accompanying
73 // instructions. 74 // instructions.
74 // 75 //
75 // This is used for Bluetooth 2.0 and earlier keyboard devices, the 76 // This is used for Bluetooth 2.0 and earlier keyboard devices, the
76 // |pincode| will always be a six-digit numeric in the range 000000-999999 77 // |pincode| will always be a six-digit numeric in the range 000000-999999
77 // for compatibilty with later specifications. 78 // for compatibilty with later specifications.
78 virtual void DisplayPinCode(BluetoothDevice* device, 79 virtual void DisplayPinCode(device::BluetoothDevice* device,
79 const std::string& pincode) OVERRIDE; 80 const std::string& pincode) OVERRIDE;
80 81
81 // BluetoothDevice::PairingDelegate override. 82 // device::BluetoothDevice::PairingDelegate override.
82 // 83 //
83 // This method will be called when the Bluetooth daemon requires that the 84 // This method will be called when the Bluetooth daemon requires that the
84 // user enter the Passkey |passkey| into the device |device| so that it 85 // user enter the Passkey |passkey| into the device |device| so that it
85 // may be authenticated, the UI will display the passkey with accompanying 86 // may be authenticated, the UI will display the passkey with accompanying
86 // instructions. 87 // instructions.
87 // 88 //
88 // This is used for Bluetooth 2.1 and later devices that support input 89 // This is used for Bluetooth 2.1 and later devices that support input
89 // but not display, such as keyboards. The Passkey is a numeric in the 90 // but not display, such as keyboards. The Passkey is a numeric in the
90 // range 0-999999 and should be always presented zero-padded to six 91 // range 0-999999 and should be always presented zero-padded to six
91 // digits. 92 // digits.
92 virtual void DisplayPasskey(BluetoothDevice* device, uint32 passkey) OVERRIDE; 93 virtual void DisplayPasskey(
94 device::BluetoothDevice* device, uint32 passkey) OVERRIDE;
93 95
94 // BluetoothDevice::PairingDelegate override. 96 // device::BluetoothDevice::PairingDelegate override.
95 // 97 //
96 // This method will be called when the Bluetooth daemon requires that the 98 // This method will be called when the Bluetooth daemon requires that the
97 // user confirm that the Passkey |passkey| is displayed on the screen 99 // user confirm that the Passkey |passkey| is displayed on the screen
98 // of the device |device| so that it may be authenticated, the UI will 100 // of the device |device| so that it may be authenticated, the UI will
99 // display the passkey with accompanying instructions. 101 // display the passkey with accompanying instructions.
100 // 102 //
101 // This is used for Bluetooth 2.1 and later devices that support display, 103 // This is used for Bluetooth 2.1 and later devices that support display,
102 // such as other computers or phones. The Passkey is a numeric in the 104 // such as other computers or phones. The Passkey is a numeric in the
103 // range 0-999999 and should be always present zero-padded to six 105 // range 0-999999 and should be always present zero-padded to six
104 // digits. 106 // digits.
105 virtual void ConfirmPasskey(BluetoothDevice* device, uint32 passkey) OVERRIDE; 107 virtual void ConfirmPasskey(
108 device::BluetoothDevice* device, uint32 passkey) OVERRIDE;
106 109
107 // BluetoothDevice::PairingDelegate override. 110 // device::BluetoothDevice::PairingDelegate override.
108 // 111 //
109 // This method will be called when any previous DisplayPinCode(), 112 // This method will be called when any previous DisplayPinCode(),
110 // DisplayPasskey() or ConfirmPasskey() request should be concluded 113 // DisplayPasskey() or ConfirmPasskey() request should be concluded
111 // and removed from the user. 114 // and removed from the user.
112 virtual void DismissDisplayOrConfirm() OVERRIDE; 115 virtual void DismissDisplayOrConfirm() OVERRIDE;
113 116
114 // Displays a Bluetooth error. 117 // Displays a Bluetooth error.
115 // |error| maps to a localized resource for the error message. 118 // |error| maps to a localized resource for the error message.
116 // |address| is the address of the Bluetooth device. May be an empty 119 // |address| is the address of the Bluetooth device. May be an empty
117 // string if the error is not specific to a single device. 120 // string if the error is not specific to a single device.
118 void ReportError(const std::string& error, const std::string& address); 121 void ReportError(const std::string& error, const std::string& address);
119 122
120 // BluetoothAdapter::Observer implementation. 123 // device::BluetoothAdapter::Observer implementation.
121 virtual void AdapterPresentChanged(BluetoothAdapter* adapter, 124 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter,
122 bool present) OVERRIDE; 125 bool present) OVERRIDE;
123 virtual void AdapterPoweredChanged(BluetoothAdapter* adapter, 126 virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
124 bool powered) OVERRIDE; 127 bool powered) OVERRIDE;
125 virtual void DeviceAdded(BluetoothAdapter* adapter, 128 virtual void DeviceAdded(device::BluetoothAdapter* adapter,
126 BluetoothDevice* device) OVERRIDE; 129 device::BluetoothDevice* device) OVERRIDE;
127 virtual void DeviceChanged(BluetoothAdapter* adapter, 130 virtual void DeviceChanged(device::BluetoothAdapter* adapter,
128 BluetoothDevice* device) OVERRIDE; 131 device::BluetoothDevice* device) OVERRIDE;
129 virtual void DeviceRemoved(BluetoothAdapter* adapter, 132 virtual void DeviceRemoved(device::BluetoothAdapter* adapter,
130 BluetoothDevice* device) OVERRIDE; 133 device::BluetoothDevice* device) OVERRIDE;
131 134
132 private: 135 private:
133 // Called by BluetoothAdapter in response to a failure to change the power 136 // Called by device::BluetoothAdapter in response to a failure to
134 // status of the adapter. 137 // change the power status of the adapter.
135 void EnableChangeError(); 138 void EnableChangeError();
136 139
137 // Called by BluetoothAdapter in response to a failure to set the adapter into 140 // Called by device::BluetoothAdapter in response to a failure to
138 // discovery mode. 141 // set the adapter into discovery mode.
139 void FindDevicesError(); 142 void FindDevicesError();
140 143
141 // Called by BluetoothAdapter in response to a failure to remove the adapter 144 // Called by device::BluetoothAdapter in response to a failure to
142 // from discovery mode. 145 // remove the adapter from discovery mode.
143 void StopDiscoveryError(); 146 void StopDiscoveryError();
144 147
145 // Called by BluetoothDevice in response to a failure to connect to the device 148 // Called by device::BluetoothDevice in response to a failure to
146 // with bluetooth address |address|. 149 // connect to the device with bluetooth address |address|.
147 void ConnectError(const std::string& address); 150 void ConnectError(const std::string& address);
148 151
149 // Called by BluetoothDevice in response to a failure to disconnect the device 152 // Called by device::BluetoothDevice in response to a failure to
150 // with bluetooth address |address|. 153 // disconnect the device with bluetooth address |address|.
151 void DisconnectError(const std::string& address); 154 void DisconnectError(const std::string& address);
152 155
153 // Called by BluetoothDevice in response to a failure to disconnect and unpair 156 // Called by device::BluetoothDevice in response to a failure to
154 // the device with bluetooth address |address|. 157 // disconnect and unpair the device with bluetooth address |address|.
155 void ForgetError(const std::string& address); 158 void ForgetError(const std::string& address);
156 159
157 // Called when the 'Enable bluetooth' checkbox value is changed. 160 // Called when the 'Enable bluetooth' checkbox value is changed.
158 // |args| will contain the checkbox checked state as a string 161 // |args| will contain the checkbox checked state as a string
159 // ("true" or "false"). 162 // ("true" or "false").
160 void EnableChangeCallback(const base::ListValue* args); 163 void EnableChangeCallback(const base::ListValue* args);
161 164
162 // Called when the 'Find Devices' button is pressed from the Bluetooth 165 // Called when the 'Find Devices' button is pressed from the Bluetooth
163 // ssettings. 166 // ssettings.
164 // |args| will be an empty list. 167 // |args| will be an empty list.
(...skipping 10 matching lines...) Expand all
175 // process. 178 // process.
176 // |args| will be an empty list. 179 // |args| will be an empty list.
177 void StopDiscoveryCallback(const base::ListValue* args); 180 void StopDiscoveryCallback(const base::ListValue* args);
178 181
179 // Called when the list of paired devices is initialized in order to 182 // Called when the list of paired devices is initialized in order to
180 // populate the list. 183 // populate the list.
181 // |args| will be an empty list. 184 // |args| will be an empty list.
182 void GetPairedDevicesCallback(const base::ListValue* args); 185 void GetPairedDevicesCallback(const base::ListValue* args);
183 186
184 // Default bluetooth adapter, used for all operations. 187 // Default bluetooth adapter, used for all operations.
185 scoped_refptr<BluetoothAdapter> adapter_; 188 scoped_refptr<device::BluetoothAdapter> adapter_;
186 189
187 // Weak pointer factory for generating 'this' pointers that might live longer 190 // Weak pointer factory for generating 'this' pointers that might live longer
188 // than this object does. 191 // than this object does.
189 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; 192 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_;
190 193
191 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); 194 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler);
192 }; 195 };
193 196
194 } // namespace options 197 } // namespace options
195 } // namespace chromeos 198 } // namespace chromeos
196 199
197 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ 200 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698