OLD | NEW |
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" |
(...skipping 16 matching lines...) Expand all Loading... |
27 class BluetoothOptionsHandler | 27 class BluetoothOptionsHandler |
28 : public ::options::OptionsPageUIHandler, | 28 : public ::options::OptionsPageUIHandler, |
29 public device::BluetoothAdapter::Observer, | 29 public device::BluetoothAdapter::Observer, |
30 public device::BluetoothDevice::PairingDelegate { | 30 public device::BluetoothDevice::PairingDelegate { |
31 public: | 31 public: |
32 BluetoothOptionsHandler(); | 32 BluetoothOptionsHandler(); |
33 virtual ~BluetoothOptionsHandler(); | 33 virtual ~BluetoothOptionsHandler(); |
34 | 34 |
35 // OptionsPageUIHandler implementation. | 35 // OptionsPageUIHandler implementation. |
36 virtual void GetLocalizedValues( | 36 virtual void GetLocalizedValues( |
37 base::DictionaryValue* localized_strings) OVERRIDE; | 37 base::DictionaryValue* localized_strings) override; |
38 virtual void RegisterMessages() OVERRIDE; | 38 virtual void RegisterMessages() override; |
39 virtual void InitializeHandler() OVERRIDE; | 39 virtual void InitializeHandler() override; |
40 virtual void InitializePage() OVERRIDE; | 40 virtual void InitializePage() override; |
41 | 41 |
42 void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter); | 42 void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
43 | 43 |
44 // Sends a notification to the Web UI of the status of a Bluetooth device. | 44 // Sends a notification to the Web UI of the status of a Bluetooth device. |
45 // |device| is the Bluetooth device. | 45 // |device| is the Bluetooth device. |
46 // |params| is an optional set of parameters. | 46 // |params| is an optional set of parameters. |
47 void SendDeviceNotification(const device::BluetoothDevice* device, | 47 void SendDeviceNotification(const device::BluetoothDevice* device, |
48 base::DictionaryValue* params); | 48 base::DictionaryValue* params); |
49 | 49 |
50 // device::BluetoothDevice::PairingDelegate override. | 50 // device::BluetoothDevice::PairingDelegate override. |
51 // | 51 // |
52 // This method will be called when the Bluetooth daemon requires a | 52 // This method will be called when the Bluetooth daemon requires a |
53 // PIN Code for authentication of the device |device|, the UI will display | 53 // PIN Code for authentication of the device |device|, the UI will display |
54 // a blank entry form to obtain the PIN code from the user. | 54 // a blank entry form to obtain the PIN code from the user. |
55 // | 55 // |
56 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices | 56 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices |
57 // for which there is no automatic pairing or special handling. | 57 // for which there is no automatic pairing or special handling. |
58 virtual void RequestPinCode(device::BluetoothDevice* device) OVERRIDE; | 58 virtual void RequestPinCode(device::BluetoothDevice* device) override; |
59 | 59 |
60 // device::BluetoothDevice::PairingDelegate override. | 60 // device::BluetoothDevice::PairingDelegate override. |
61 // | 61 // |
62 // This method will be called when the Bluetooth daemon requires a | 62 // This method will be called when the Bluetooth daemon requires a |
63 // Passkey for authentication of the device |device|, the UI will display | 63 // Passkey for authentication of the device |device|, the UI will display |
64 // a blank entry form to obtain the passkey from the user (a numeric in the | 64 // a blank entry form to obtain the passkey from the user (a numeric in the |
65 // range 0-999999). | 65 // range 0-999999). |
66 // | 66 // |
67 // Passkeys are generally required for Bluetooth 2.1 and later devices | 67 // Passkeys are generally required for Bluetooth 2.1 and later devices |
68 // which cannot provide input or display on their own, and don't accept | 68 // which cannot provide input or display on their own, and don't accept |
69 // passkey-less pairing. | 69 // passkey-less pairing. |
70 virtual void RequestPasskey(device::BluetoothDevice* device) OVERRIDE; | 70 virtual void RequestPasskey(device::BluetoothDevice* device) override; |
71 | 71 |
72 // device::BluetoothDevice::PairingDelegate override. | 72 // device::BluetoothDevice::PairingDelegate override. |
73 // | 73 // |
74 // This method will be called when the Bluetooth daemon requires that the | 74 // This method will be called when the Bluetooth daemon requires that the |
75 // user enter the PIN code |pincode| into the device |device| so that it | 75 // user enter the PIN code |pincode| into the device |device| so that it |
76 // may be authenticated, the UI will display the PIN code with accompanying | 76 // may be authenticated, the UI will display the PIN code with accompanying |
77 // instructions. | 77 // instructions. |
78 // | 78 // |
79 // This is used for Bluetooth 2.0 and earlier keyboard devices, the | 79 // This is used for Bluetooth 2.0 and earlier keyboard devices, the |
80 // |pincode| will always be a six-digit numeric in the range 000000-999999 | 80 // |pincode| will always be a six-digit numeric in the range 000000-999999 |
81 // for compatibilty with later specifications. | 81 // for compatibilty with later specifications. |
82 virtual void DisplayPinCode(device::BluetoothDevice* device, | 82 virtual void DisplayPinCode(device::BluetoothDevice* device, |
83 const std::string& pincode) OVERRIDE; | 83 const std::string& pincode) override; |
84 | 84 |
85 // device::BluetoothDevice::PairingDelegate override. | 85 // device::BluetoothDevice::PairingDelegate override. |
86 // | 86 // |
87 // This method will be called when the Bluetooth daemon requires that the | 87 // This method will be called when the Bluetooth daemon requires that the |
88 // user enter the Passkey |passkey| into the device |device| so that it | 88 // user enter the Passkey |passkey| into the device |device| so that it |
89 // may be authenticated, the UI will display the passkey with accompanying | 89 // may be authenticated, the UI will display the passkey with accompanying |
90 // instructions. | 90 // instructions. |
91 // | 91 // |
92 // This is used for Bluetooth 2.1 and later devices that support input | 92 // This is used for Bluetooth 2.1 and later devices that support input |
93 // but not display, such as keyboards. The Passkey is a numeric in the | 93 // but not display, such as keyboards. The Passkey is a numeric in the |
94 // range 0-999999 and should be always presented zero-padded to six | 94 // range 0-999999 and should be always presented zero-padded to six |
95 // digits. | 95 // digits. |
96 virtual void DisplayPasskey( | 96 virtual void DisplayPasskey( |
97 device::BluetoothDevice* device, uint32 passkey) OVERRIDE; | 97 device::BluetoothDevice* device, uint32 passkey) override; |
98 | 98 |
99 // device::BluetoothDevice::PairingDelegate override. | 99 // device::BluetoothDevice::PairingDelegate override. |
100 // | 100 // |
101 // This method will be called when the Bluetooth daemon gets a notification | 101 // This method will be called when the Bluetooth daemon gets a notification |
102 // of a key entered on the device |device| while pairing with the device | 102 // of a key entered on the device |device| while pairing with the device |
103 // using a PIN code or a Passkey. | 103 // using a PIN code or a Passkey. |
104 // | 104 // |
105 // The UI will show a visual indication that a given key was pressed in the | 105 // The UI will show a visual indication that a given key was pressed in the |
106 // same pairing overlay where the PIN code or Passkey is displayed. | 106 // same pairing overlay where the PIN code or Passkey is displayed. |
107 // | 107 // |
108 // A first call with |entered| as 0 will indicate that this notification | 108 // A first call with |entered| as 0 will indicate that this notification |
109 // mechanism is supported by the device allowing the UI to display this fact. | 109 // mechanism is supported by the device allowing the UI to display this fact. |
110 // A last call with |entered| as the length of the key plus one will indicate | 110 // A last call with |entered| as the length of the key plus one will indicate |
111 // that the [enter] key was pressed. | 111 // that the [enter] key was pressed. |
112 virtual void KeysEntered(device::BluetoothDevice* device, | 112 virtual void KeysEntered(device::BluetoothDevice* device, |
113 uint32 entered) OVERRIDE; | 113 uint32 entered) override; |
114 | 114 |
115 // device::BluetoothDevice::PairingDelegate override. | 115 // device::BluetoothDevice::PairingDelegate override. |
116 // | 116 // |
117 // This method will be called when the Bluetooth daemon requires that the | 117 // This method will be called when the Bluetooth daemon requires that the |
118 // user confirm that the Passkey |passkey| is displayed on the screen | 118 // user confirm that the Passkey |passkey| is displayed on the screen |
119 // of the device |device| so that it may be authenticated, the UI will | 119 // of the device |device| so that it may be authenticated, the UI will |
120 // display the passkey with accompanying instructions. | 120 // display the passkey with accompanying instructions. |
121 // | 121 // |
122 // This is used for Bluetooth 2.1 and later devices that support display, | 122 // This is used for Bluetooth 2.1 and later devices that support display, |
123 // such as other computers or phones. The Passkey is a numeric in the | 123 // such as other computers or phones. The Passkey is a numeric in the |
124 // range 0-999999 and should be always present zero-padded to six | 124 // range 0-999999 and should be always present zero-padded to six |
125 // digits. | 125 // digits. |
126 virtual void ConfirmPasskey( | 126 virtual void ConfirmPasskey( |
127 device::BluetoothDevice* device, uint32 passkey) OVERRIDE; | 127 device::BluetoothDevice* device, uint32 passkey) override; |
128 | 128 |
129 // device::BluetoothDevice::PairingDelegate override. | 129 // device::BluetoothDevice::PairingDelegate override. |
130 virtual void AuthorizePairing(device::BluetoothDevice* device) OVERRIDE; | 130 virtual void AuthorizePairing(device::BluetoothDevice* device) override; |
131 | 131 |
132 // Displays a Bluetooth error. | 132 // Displays a Bluetooth error. |
133 // |error| maps to a localized resource for the error message. | 133 // |error| maps to a localized resource for the error message. |
134 // |address| is the address of the Bluetooth device. May be an empty | 134 // |address| is the address of the Bluetooth device. May be an empty |
135 // string if the error is not specific to a single device. | 135 // string if the error is not specific to a single device. |
136 void ReportError(const std::string& error, const std::string& address); | 136 void ReportError(const std::string& error, const std::string& address); |
137 | 137 |
138 // device::BluetoothAdapter::Observer implementation. | 138 // device::BluetoothAdapter::Observer implementation. |
139 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 139 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
140 bool present) OVERRIDE; | 140 bool present) override; |
141 virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 141 virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
142 bool powered) OVERRIDE; | 142 bool powered) override; |
143 virtual void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, | 143 virtual void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, |
144 bool discovering) OVERRIDE; | 144 bool discovering) override; |
145 virtual void DeviceAdded(device::BluetoothAdapter* adapter, | 145 virtual void DeviceAdded(device::BluetoothAdapter* adapter, |
146 device::BluetoothDevice* device) OVERRIDE; | 146 device::BluetoothDevice* device) override; |
147 virtual void DeviceChanged(device::BluetoothAdapter* adapter, | 147 virtual void DeviceChanged(device::BluetoothAdapter* adapter, |
148 device::BluetoothDevice* device) OVERRIDE; | 148 device::BluetoothDevice* device) override; |
149 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, | 149 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, |
150 device::BluetoothDevice* device) OVERRIDE; | 150 device::BluetoothDevice* device) override; |
151 | 151 |
152 private: | 152 private: |
153 // Displays in the UI a connecting to the device |device| message. | 153 // Displays in the UI a connecting to the device |device| message. |
154 void DeviceConnecting(device::BluetoothDevice* device); | 154 void DeviceConnecting(device::BluetoothDevice* device); |
155 | 155 |
156 // Called by device::BluetoothAdapter in response to a failure to | 156 // Called by device::BluetoothAdapter in response to a failure to |
157 // change the power status of the adapter. | 157 // change the power status of the adapter. |
158 void EnableChangeError(); | 158 void EnableChangeError(); |
159 | 159 |
160 // Called by device::BluetoothAdapter in response to a successful request | 160 // Called by device::BluetoothAdapter in response to a successful request |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // than this object does. | 239 // than this object does. |
240 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; | 240 base::WeakPtrFactory<BluetoothOptionsHandler> weak_ptr_factory_; |
241 | 241 |
242 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); | 242 DISALLOW_COPY_AND_ASSIGN(BluetoothOptionsHandler); |
243 }; | 243 }; |
244 | 244 |
245 } // namespace options | 245 } // namespace options |
246 } // namespace chromeos | 246 } // namespace chromeos |
247 | 247 |
248 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ | 248 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_CHROMEOS_BLUETOOTH_OPTIONS_HANDLER_H_ |
OLD | NEW |