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

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

Issue 2622393002: bluetooth: Add characteristic list to DeviceDetailsPage in internals page. (Closed)
Patch Set: Inline setting of characteristic fieldset object 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 DeviceDetailsPage which displays all of the details of a 6 * Javascript for DeviceDetailsPage which displays all of the details of a
7 * device. The page is generated and managed dynamically in bluetooth_internals. 7 * device. The page is generated and managed dynamically in bluetooth_internals.
8 * served from chrome://bluetooth-internals/. 8 * served from chrome://bluetooth-internals/.
9 */ 9 */
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 address: this.deviceInfo.address, 76 address: this.deviceInfo.address,
77 }, 77 },
78 })); 78 }));
79 }.bind(this)); 79 }.bind(this));
80 80
81 this.connectBtn_ = this.pageDiv.querySelector('.disconnect'); 81 this.connectBtn_ = this.pageDiv.querySelector('.disconnect');
82 this.connectBtn_.addEventListener('click', function() { 82 this.connectBtn_.addEventListener('click', function() {
83 this.devicePtr !== null ? this.disconnect() : this.connect(); 83 this.devicePtr !== null ? this.disconnect() : this.connect();
84 }.bind(this)); 84 }.bind(this));
85 85
86 this.serviceList.addEventListener(
87 'characteristicsrequested', function(event) {
88 if (!this.devicePtr) {
89 event.target.onCharacteristicsReturned([]);
dpapad 2017/01/17 20:01:01 I am confused about what is happening here.
90 return;
91 }
92
93 this.devicePtr.getCharacteristics(event.detail.serviceId).then(
94 function(response) {
95 event.target.onCharacteristicsReturned(
dpapad 2017/01/17 20:01:01 This strikes me as odd. Instead of calling a metho
mbrunson 2017/01/17 21:05:49 I've been juggling solutions to this issue. I'm cr
dpapad 2017/01/17 22:01:39 Firing an event from a subcomponent that propagate
mbrunson 2017/01/18 22:04:23 Ok. I've created a global service object for this,
96 response.characteristics);
97 }.bind(this));
98 }.bind(this));
99
86 this.redraw(); 100 this.redraw();
87 } 101 }
88 102
89 DeviceDetailsPage.prototype = { 103 DeviceDetailsPage.prototype = {
90 __proto__: Page.prototype, 104 __proto__: Page.prototype,
91 105
92 /** Creates a connection to the Bluetooth device. */ 106 /** Creates a connection to the Bluetooth device. */
93 connect: function() { 107 connect: function() {
94 if (this.status_ !== device_collection.ConnectionStatus.DISCONNECTED) 108 if (this.status_ !== device_collection.ConnectionStatus.DISCONNECTED)
95 return; 109 return;
(...skipping 21 matching lines...) Expand all
117 }.bind(this)).catch(function(error) { 131 }.bind(this)).catch(function(error) {
118 // If a connection error occurs while fetching the services, the 132 // If a connection error occurs while fetching the services, the
119 // devicePtr reference must be removed. 133 // devicePtr reference must be removed.
120 if (this.devicePtr) { 134 if (this.devicePtr) {
121 this.devicePtr.disconnect(); 135 this.devicePtr.disconnect();
122 this.devicePtr = null; 136 this.devicePtr = null;
123 } 137 }
124 138
125 Snackbar.show( 139 Snackbar.show(
126 this.deviceInfo.name_for_display + ': ' + error.message, 140 this.deviceInfo.name_for_display + ': ' + error.message,
127 SnackbarType.DANGER, 'Retry', this.connect.bind(this)); 141 SnackbarType.ERROR, 'Retry', this.connect.bind(this));
128 142
129 this.updateConnectionStatus_( 143 this.updateConnectionStatus_(
130 device_collection.ConnectionStatus.DISCONNECTED); 144 device_collection.ConnectionStatus.DISCONNECTED);
131 }.bind(this)); 145 }.bind(this));
132 }, 146 },
133 147
134 /** Disconnects the page from the Bluetooth device. */ 148 /** Disconnects the page from the Bluetooth device. */
135 disconnect: function() { 149 disconnect: function() {
136 if (!this.devicePtr) return; 150 if (!this.devicePtr) return;
137 151
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 status: status, 238 status: status,
225 } 239 }
226 })); 240 }));
227 }, 241 },
228 }; 242 };
229 243
230 return { 244 return {
231 DeviceDetailsPage: DeviceDetailsPage, 245 DeviceDetailsPage: DeviceDetailsPage,
232 }; 246 };
233 }); 247 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698