Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Side by Side Diff: chrome/browser/resources/bluetooth_internals/service_list.js

Issue 2640073004: bluetooth: Add descriptor list to DeviceDetailsPage on internals page. (Closed)
Patch Set: Fix merge issue of bluetooth_internals.css Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 * Javascript for ServiceList and ServiceListItem, served from 6 * Javascript for ServiceList and ServiceListItem, served from
7 * chrome://bluetooth-internals/. 7 * chrome://bluetooth-internals/.
8 */ 8 */
9 9
10 cr.define('service_list', function() { 10 cr.define('service_list', function() {
(...skipping 20 matching lines...) Expand all
31 * given |serviceInfo|. Data is not loaded until the ServiceListItem is 31 * given |serviceInfo|. Data is not loaded until the ServiceListItem is
32 * expanded for the first time. 32 * expanded for the first time.
33 * @param {!interfaces.BluetoothDevice.ServiceInfo} serviceInfo 33 * @param {!interfaces.BluetoothDevice.ServiceInfo} serviceInfo
34 * @param {string} deviceAddress 34 * @param {string} deviceAddress
35 * @constructor 35 * @constructor
36 */ 36 */
37 function ServiceListItem(serviceInfo, deviceAddress) { 37 function ServiceListItem(serviceInfo, deviceAddress) {
38 var listItem = new ExpandableListItem(); 38 var listItem = new ExpandableListItem();
39 listItem.__proto__ = ServiceListItem.prototype; 39 listItem.__proto__ = ServiceListItem.prototype;
40 40
41 /** @type {!interfaces.BluetoothDevice.ServiceInfo} */
41 listItem.info = serviceInfo; 42 listItem.info = serviceInfo;
43 /** @private {string} */
42 listItem.deviceAddress_ = deviceAddress; 44 listItem.deviceAddress_ = deviceAddress;
45
43 listItem.decorate(); 46 listItem.decorate();
44
45 return listItem; 47 return listItem;
46 } 48 }
47 49
48 ServiceListItem.prototype = { 50 ServiceListItem.prototype = {
49 __proto__: ExpandableListItem.prototype, 51 __proto__: ExpandableListItem.prototype,
50 52
51 /** 53 /**
52 * Decorates the element as a service list item. Creates layout and caches 54 * Decorates the element as a service list item. Creates layout and caches
53 * references to the created header and fieldset. 55 * references to the created header and fieldset.
54 * @override 56 * @override
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return new ServiceListItem(data, this.deviceAddress_); 134 return new ServiceListItem(data, this.deviceAddress_);
133 }, 135 },
134 136
135 /** 137 /**
136 * Loads the service list with an array of ServiceInfo from the 138 * Loads the service list with an array of ServiceInfo from the
137 * device with |deviceAddress|. If no active connection to the device 139 * device with |deviceAddress|. If no active connection to the device
138 * exists, one is created. 140 * exists, one is created.
139 * @param {string} deviceAddress 141 * @param {string} deviceAddress
140 */ 142 */
141 load: function(deviceAddress) { 143 load: function(deviceAddress) {
142 if (this.servicesRequested_ || !this.isLoading()) 144 if (this.servicesRequested_ || !this.isSpinnerShowing())
143 return; 145 return;
144 146
145 this.deviceAddress_ = deviceAddress; 147 this.deviceAddress_ = deviceAddress;
146 this.servicesRequested_ = true; 148 this.servicesRequested_ = true;
147 149
148 device_broker.connectToDevice(this.deviceAddress_).then( 150 device_broker.connectToDevice(this.deviceAddress_).then(
149 function(device) { 151 function(device) {
150 return device.getServices(); 152 return device.getServices();
151 }.bind(this)).then(function(response) { 153 }.bind(this)).then(function(response) {
152 this.setData(new ArrayDataModel(response.services)); 154 this.setData(new ArrayDataModel(response.services));
153 this.setLoading(false); 155 this.setSpinnerShowing(false);
154 this.servicesRequested_ = false; 156 this.servicesRequested_ = false;
155 }.bind(this)).catch(function(error) { 157 }.bind(this)).catch(function(error) {
156 this.servicesRequested_ = false; 158 this.servicesRequested_ = false;
157 Snackbar.show( 159 Snackbar.show(
158 deviceAddress + ': ' + error.message, SnackbarType.ERROR, 160 deviceAddress + ': ' + error.message, SnackbarType.ERROR,
159 'Retry', function() { this.load(deviceAddress); }.bind(this)); 161 'Retry', function() { this.load(deviceAddress); }.bind(this));
160 }.bind(this)); 162 }.bind(this));
161 }, 163 },
162 }; 164 };
163 165
164 return { 166 return {
165 ServiceList: ServiceList, 167 ServiceList: ServiceList,
166 ServiceListItem: ServiceListItem, 168 ServiceListItem: ServiceListItem,
167 }; 169 };
168 }); 170 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698