OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * 'settings-bluetooth-page' is the settings page for managing bluetooth | 7 * 'settings-bluetooth-page' is the settings page for managing bluetooth |
8 * properties and devices. | 8 * properties and devices. |
9 * | 9 * |
10 * Example: | 10 * Example: |
11 * <core-animated-pages> | 11 * <core-animated-pages> |
12 * <settings-bluetooth-page> | 12 * <settings-bluetooth-page> |
13 * </settings-bluetooth-page> | 13 * </settings-bluetooth-page> |
14 * ... other pages ... | 14 * ... other pages ... |
15 * </core-animated-pages> | 15 * </core-animated-pages> |
16 * | 16 * |
17 * @group Chrome Settings Elements | 17 * @group Chrome Settings Elements |
18 * @element settings-bluetooth-page | 18 * @element settings-bluetooth-page |
19 */ | 19 */ |
| 20 |
| 21 var bluetoothPage = bluetoothPage || { |
| 22 /** |
| 23 * Set this to provide a fake implementation for testing. |
| 24 * @type {Bluetooth} |
| 25 */ |
| 26 bluetoothApiForTest: null, |
| 27 |
| 28 /** |
| 29 * Set this to provide a fake implementation for testing. |
| 30 * @type {BluetoothPrivate} |
| 31 */ |
| 32 bluetoothPrivateApiForTest: null, |
| 33 }; |
| 34 |
20 Polymer({ | 35 Polymer({ |
21 is: 'settings-bluetooth-page', | 36 is: 'settings-bluetooth-page', |
22 | 37 |
23 behaviors: [ | 38 behaviors: [ |
24 I18nBehavior, | 39 I18nBehavior, |
25 ], | 40 ], |
26 | 41 |
27 properties: { | 42 properties: { |
28 /** The current active route. */ | 43 /** The current active route. */ |
29 currentRoute: { | 44 currentRoute: { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 */ | 91 */ |
77 bluetoothDeviceUpdatedListener_: undefined, | 92 bluetoothDeviceUpdatedListener_: undefined, |
78 | 93 |
79 /** | 94 /** |
80 * Listener for chrome.bluetooth.onBluetoothDeviceRemoved events. | 95 * Listener for chrome.bluetooth.onBluetoothDeviceRemoved events. |
81 * @type {function(!chrome.bluetooth.Device)|undefined} | 96 * @type {function(!chrome.bluetooth.Device)|undefined} |
82 * @private | 97 * @private |
83 */ | 98 */ |
84 bluetoothDeviceRemovedListener_: undefined, | 99 bluetoothDeviceRemovedListener_: undefined, |
85 | 100 |
| 101 /** @override */ |
| 102 ready: function() { |
| 103 if (bluetoothPage.bluetoothApiForTest) |
| 104 this.bluetooth = bluetoothPage.bluetoothApiForTest; |
| 105 if (bluetoothPage.bluetoothPrivateApiForTest) |
| 106 this.bluetoothPrivate = bluetoothPage.bluetoothPrivateApiForTest; |
| 107 }, |
86 | 108 |
87 /** @override */ | 109 /** @override */ |
88 attached: function() { | 110 attached: function() { |
89 this.bluetoothAdapterStateChangedListener_ = | 111 this.bluetoothAdapterStateChangedListener_ = |
90 this.onBluetoothAdapterStateChanged_.bind(this); | 112 this.onBluetoothAdapterStateChanged_.bind(this); |
91 this.bluetooth.onAdapterStateChanged.addListener( | 113 this.bluetooth.onAdapterStateChanged.addListener( |
92 this.bluetoothAdapterStateChangedListener_); | 114 this.bluetoothAdapterStateChangedListener_); |
93 | 115 |
94 this.bluetoothDeviceUpdatedListener_ = | 116 this.bluetoothDeviceUpdatedListener_ = |
95 this.onBluetoothDeviceUpdated_.bind(this); | 117 this.onBluetoothDeviceUpdated_.bind(this); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 /** | 246 /** |
225 * @param {!chrome.bluetooth.Device} device | 247 * @param {!chrome.bluetooth.Device} device |
226 * @return {boolean} True if |device| should be shown in the device list. | 248 * @return {boolean} True if |device| should be shown in the device list. |
227 * @private | 249 * @private |
228 */ | 250 */ |
229 showDeviceInList_: function(device) { | 251 showDeviceInList_: function(device) { |
230 return !!device.paired || !!device.connected || !!device.connecting; | 252 return !!device.paired || !!device.connected || !!device.connecting; |
231 }, | 253 }, |
232 | 254 |
233 /** | 255 /** |
234 * @param {!Array<!chrome.bluetooth.Device>} deviceList | 256 * @param {Object} deviceListChanges |
235 * @return {boolean} True if deviceList is not empty. | 257 * @return {boolean} True if deviceList is not empty. |
236 * @private | 258 * @private |
237 */ | 259 */ |
238 haveDevices_: function(deviceList) { return !!deviceList.length; }, | 260 haveDevices_: function(deviceListChanges) { |
| 261 return !!this.deviceList.length; |
| 262 }, |
239 | 263 |
240 /** | 264 /** |
241 * @param {number} selectedDevice | 265 * @param {number} selectedDevice |
242 * @return {boolean} True if a device is selected. | 266 * @return {boolean} True if a device is selected. |
243 * @private | 267 * @private |
244 */ | 268 */ |
245 haveSelectedDevice_: function(selectedDevice) { return selectedDevice >= 0; }, | 269 haveSelectedDevice_: function(selectedDevice) { return selectedDevice >= 0; }, |
246 | 270 |
247 /** @private */ | 271 /** @private */ |
248 onConnectTap_: function() { | 272 onConnectTap_: function() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 'Error forgetting devce: ' + device.name + ': ' + | 309 'Error forgetting devce: ' + device.name + ': ' + |
286 chrome.runtime.lastError.message); | 310 chrome.runtime.lastError.message); |
287 } | 311 } |
288 }); | 312 }); |
289 } | 313 } |
290 }, | 314 }, |
291 | 315 |
292 /** @private */ | 316 /** @private */ |
293 onAddDeviceTap_: function() {} | 317 onAddDeviceTap_: function() {} |
294 }); | 318 }); |
OLD | NEW |