OLD | NEW |
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 Loading... |
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.onCharacteristicsRequested([]); |
| 90 return; |
| 91 } |
| 92 |
| 93 this.devicePtr.getCharacteristics(event.detail.serviceId).then( |
| 94 function(response) { |
| 95 event.target.onCharacteristicsRequested( |
| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }); |
OLD | NEW |