Chromium Code Reviews| 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: |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 * @private | 73 * @private |
| 74 */ | 74 */ |
| 75 deviceList_: { | 75 deviceList_: { |
| 76 type: Array, | 76 type: Array, |
| 77 value: function() { | 77 value: function() { |
| 78 return []; | 78 return []; |
| 79 }, | 79 }, |
| 80 }, | 80 }, |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * The ordered list of paired or connecting bluetooth devices. | |
| 84 * @type {!Array<!chrome.bluetooth.Device>} | |
| 85 */ | |
| 86 pairedDeviceList_: { | |
| 87 type: Array, | |
| 88 value: /** @return {Array} */ function() { | |
| 89 return []; | |
| 90 }, | |
| 91 }, | |
| 92 | |
| 93 /** | |
| 83 * Reflects the iron-list selecteditem property. | 94 * Reflects the iron-list selecteditem property. |
| 84 * @type {!chrome.bluetooth.Device} | 95 * @type {!chrome.bluetooth.Device} |
| 85 * @private | 96 * @private |
| 86 */ | 97 */ |
| 87 selectedItem_: { | 98 selectedItem_: { |
| 88 type: Object, | 99 type: Object, |
| 89 observer: 'selectedItemChanged_', | 100 observer: 'selectedItemChanged_', |
| 90 }, | 101 }, |
| 91 | 102 |
| 92 /** | 103 /** |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 | 232 |
| 222 /** @private */ | 233 /** @private */ |
| 223 bluetoothEnabledChanged_: function() { | 234 bluetoothEnabledChanged_: function() { |
| 224 // When bluetooth is enabled, auto-expand the device list. | 235 // When bluetooth is enabled, auto-expand the device list. |
| 225 if (this.bluetoothEnabled_) | 236 if (this.bluetoothEnabled_) |
| 226 this.deviceListExpanded_ = true; | 237 this.deviceListExpanded_ = true; |
| 227 }, | 238 }, |
| 228 | 239 |
| 229 /** @private */ | 240 /** @private */ |
| 230 deviceListChanged_: function() { | 241 deviceListChanged_: function() { |
| 242 var devices = this.$.devices; | |
|
Dan Beam
2017/02/01 06:13:17
what's the point of this var? |this| wont change
stevenjb
2017/02/02 01:17:47
We use it twice below... Not sure I understand the
| |
| 243 this.saveScroll(devices); | |
| 244 this.pairedDeviceList_ = this.deviceList_.filter(function(device) { | |
| 245 return !!device.paired || !!device.connecting; | |
| 246 }); | |
| 247 this.updateScrollableContents(); | |
| 248 this.restoreScroll(devices); | |
| 249 | |
| 231 for (var i = 0; i < this.deviceList_.length; ++i) { | 250 for (var i = 0; i < this.deviceList_.length; ++i) { |
| 232 if (this.deviceList_[i].connected) { | 251 if (this.deviceList_[i].connected) { |
| 233 this.deviceConnected_ = true; | 252 this.deviceConnected_ = true; |
| 234 return; | 253 return; |
| 235 } | 254 } |
| 236 } | 255 } |
| 237 this.deviceConnected_ = false; | 256 this.deviceConnected_ = false; |
| 238 }, | 257 }, |
| 239 | 258 |
| 240 /** @private */ | 259 /** @private */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 * this.deviceList_. | 301 * this.deviceList_. |
| 283 * @private | 302 * @private |
| 284 */ | 303 */ |
| 285 updateDeviceList_: function() { | 304 updateDeviceList_: function() { |
| 286 if (!this.bluetoothEnabled_) { | 305 if (!this.bluetoothEnabled_) { |
| 287 this.deviceList_ = []; | 306 this.deviceList_ = []; |
| 288 return; | 307 return; |
| 289 } | 308 } |
| 290 this.bluetooth.getDevices(function(devices) { | 309 this.bluetooth.getDevices(function(devices) { |
| 291 this.deviceList_ = devices; | 310 this.deviceList_ = devices; |
| 292 this.updateScrollableContents(); | |
| 293 }.bind(this)); | 311 }.bind(this)); |
| 294 }, | 312 }, |
| 295 | 313 |
| 296 /** | 314 /** |
| 297 * Event called when a user action changes the bluetoothEnabled state. | 315 * Event called when a user action changes the bluetoothEnabled state. |
| 298 * @private | 316 * @private |
| 299 */ | 317 */ |
| 300 onBluetoothEnabledChange_: function() { | 318 onBluetoothEnabledChange_: function() { |
| 301 this.bluetoothPrivate.setAdapterState( | 319 this.bluetoothPrivate.setAdapterState( |
| 302 {powered: this.bluetoothEnabled_}, function() { | 320 {powered: this.bluetoothEnabled_}, function() { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 479 /** | 497 /** |
| 480 * @param {!chrome.bluetooth.Device} device | 498 * @param {!chrome.bluetooth.Device} device |
| 481 * @return {string} The text to display for |device| in the device list. | 499 * @return {string} The text to display for |device| in the device list. |
| 482 * @private | 500 * @private |
| 483 */ | 501 */ |
| 484 getDeviceName_: function(device) { | 502 getDeviceName_: function(device) { |
| 485 return device.name || device.address; | 503 return device.name || device.address; |
| 486 }, | 504 }, |
| 487 | 505 |
| 488 /** | 506 /** |
| 489 * @return {!Array<!chrome.bluetooth.Device>} | |
| 490 * @private | |
| 491 */ | |
| 492 getPairedOrConnecting_: function() { | |
| 493 return this.deviceList_.filter(function(device) { | |
| 494 return !!device.paired || !!device.connecting; | |
| 495 }); | |
| 496 }, | |
| 497 | |
| 498 /** | |
| 499 * @return {boolean} True if deviceList contains any paired devices. | 507 * @return {boolean} True if deviceList contains any paired devices. |
| 500 * @private | 508 * @private |
| 501 */ | 509 */ |
| 502 haveDevices_: function() { | 510 haveDevices_: function() { |
| 503 return this.deviceList_.findIndex(function(d) { | 511 return this.deviceList_.findIndex(function(d) { |
| 504 return !!d.paired; | 512 return !!d.paired; |
| 505 }) != -1; | 513 }) != -1; |
| 506 }, | 514 }, |
| 507 | 515 |
| 508 /** | 516 /** |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 }, | 626 }, |
| 619 | 627 |
| 620 /** | 628 /** |
| 621 * @param {Event} e | 629 * @param {Event} e |
| 622 * @private | 630 * @private |
| 623 */ | 631 */ |
| 624 stopTap_: function(e) { | 632 stopTap_: function(e) { |
| 625 e.stopPropagation(); | 633 e.stopPropagation(); |
| 626 }, | 634 }, |
| 627 }); | 635 }); |
| OLD | NEW |