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