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 f189b3d067b34ff72d49a40abfd6f9600eef6c37..ee52c5885949dc187d755c1187650f5a0e95028f 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'); |
| @@ -82,11 +86,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; |
|
dpapad
2017/01/17 20:01:01
Use braces when the "if" condition spans multiple
mbrunson
2017/01/17 21:05:49
Done.
|
| + |
| + 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 |
| + */ |
| + onCharacteristicsReturned: function(characteristics) { |
| + this.characteristicList_.setData(new ArrayDataModel(characteristics)); |
| + this.characteristicList_.setLoading(false); |
| + |
| + this.info.characteristics = this.characteristicList_.dataModel; |
| + this.characteristicsRequested_ = false; |
| + }, |
| }; |
| /** |