| 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..20f4ca81e735bfd85afc6ab1db1b8241436c47fe 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,50 @@ 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_);
|
| },
|
| +
|
| + /**
|
| + * 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;
|
| + },
|
| +
|
| + /** @override */
|
| + onExpandInternal: 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;
|
| + },
|
| };
|
|
|
| /**
|
|
|