Chromium Code Reviews| Index: chrome/browser/resources/bluetooth_internals/service_list.js |
| diff --git a/chrome/browser/resources/bluetooth_internals/service_list.js b/chrome/browser/resources/bluetooth_internals/service_list.js |
| index 3409d5ecc36667bb4c4a4fd30f168efc9a311a3c..cc2034822c64b6d25a7d9b99038a7a54c5ad11a0 100644 |
| --- a/chrome/browser/resources/bluetooth_internals/service_list.js |
| +++ b/chrome/browser/resources/bluetooth_internals/service_list.js |
| @@ -8,6 +8,7 @@ |
| */ |
| cr.define('service_list', function() { |
| + /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; |
| /** @const */ var ExpandableList = expandable_list.ExpandableList; |
| /** @const */ var ExpandableListItem = expandable_list.ExpandableListItem; |
| @@ -50,6 +51,9 @@ cr.define('service_list', function() { |
| decorate: function() { |
| this.classList.add('service-list-item'); |
| + /** @private {boolean} */ |
| + this.characteristicsRequested_ = false; |
| + |
| /** @private {!HTMLElement} */ |
| this.infoDiv_ = document.createElement('div'); |
| this.infoDiv_.classList.add('info-container'); |
| @@ -83,11 +87,49 @@ cr.define('service_list', function() { |
| var serviceDiv = document.createElement('div'); |
| serviceDiv.classList.add('flex'); |
| serviceDiv.appendChild(this.serviceFieldSet_); |
| - |
| this.infoDiv_.appendChild(serviceInfoHeader); |
| this.infoDiv_.appendChild(serviceDiv); |
| + |
| + var characteristicsListHeader = document.createElement('h4'); |
| + characteristicsListHeader.textContent = 'Characteristics'; |
| + this.infoDiv_.appendChild(characteristicsListHeader); |
| + |
| + this.characteristicList_ = new characteristic_list.CharacteristicList(); |
| + this.characteristicList_.setLoading(true); |
| + this.infoDiv_.appendChild(this.characteristicList_); |
| + |
| this.expandedContent_.appendChild(this.infoDiv_); |
| }, |
| + |
| + /** @override */ |
| + onExpand: function(expanded) { |
| + if (!expanded || this.characteristicsRequested_ || |
| + !this.characteristicList_.isLoading()) |
| + return; |
| + |
| + this.dispatchEvent(new CustomEvent('characteristicsrequested', { |
| + bubbles: true, |
| + detail: { |
| + serviceId: this.info.id, |
| + } |
| + })); |
| + this.characteristicsRequested_ = true; |
| + }, |
| + |
| + /** |
| + * Called when the 'characteristicsrequested' event is handled. The incoming |
| + * |characteristics| are wrapped in an ArrayDataModel then set as the data |
| + * model of the characteristics list and cached in the service info. |
| + * @param {!Array<!interfaces.BluetoothDevice.CharacteristicInfo}>} |
| + * characteristics |
| + */ |
| + onCharacteristicsRequested: function(characteristics) { |
|
scheib
2017/01/13 05:24:40
Current name implies this is called when they are
mbrunson
2017/01/13 21:21:13
Done.
|
| + this.characteristicList_.setData(new ArrayDataModel(characteristics)); |
| + this.characteristicList_.setLoading(false); |
| + |
| + this.info.characteristics = this.characteristicList_.dataModel; |
| + this.characteristicsRequested_ = false; |
| + }, |
| }; |
| /** |