OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 AdapterBroker, served from | 6 * Javascript for AdapterBroker, served from |
7 * chrome://bluetooth-internals/. | 7 * chrome://bluetooth-internals/. |
8 */ | 8 */ |
9 cr.define('adapter_broker', function() { | 9 cr.define('adapter_broker', function() { |
10 /** @typedef {interfaces.BluetoothAdapter.Adapter.ptrClass} */ | 10 /** @typedef {interfaces.BluetoothAdapter.Adapter.ptrClass} */ |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 * service. | 107 * service. |
108 * @constructor | 108 * @constructor |
109 * @param {!AdapterBroker} adapterBroker Broker to dispatch events through. | 109 * @param {!AdapterBroker} adapterBroker Broker to dispatch events through. |
110 */ | 110 */ |
111 var AdapterClient = function(adapterBroker) { | 111 var AdapterClient = function(adapterBroker) { |
112 this.adapterBroker_ = adapterBroker; | 112 this.adapterBroker_ = adapterBroker; |
113 }; | 113 }; |
114 | 114 |
115 AdapterClient.prototype = { | 115 AdapterClient.prototype = { |
116 /** | 116 /** |
117 * Fires adapterchanged event. | 117 * Fires adapterchanged event with "present" property. |
| 118 * @param {boolean} present |
| 119 */ |
| 120 presentChanged: function(present) { |
| 121 var event = new CustomEvent('adapterchanged', { |
| 122 detail: { |
| 123 property: 'present', |
| 124 value: present, |
| 125 } |
| 126 }); |
| 127 this.adapterBroker_.dispatchEvent(event); |
| 128 }, |
| 129 |
| 130 /** |
| 131 * Fires adapterchanged event with "powered" property changed. |
| 132 * @param {boolean} powered |
| 133 */ |
| 134 poweredChanged: function(powered) { |
| 135 var event = new CustomEvent('adapterchanged', { |
| 136 detail: { |
| 137 property: 'powered', |
| 138 value: powered, |
| 139 } |
| 140 }); |
| 141 this.adapterBroker_.dispatchEvent(event); |
| 142 }, |
| 143 |
| 144 /** |
| 145 * Fires adapterchanged event with "discoverable" property changed. |
| 146 * @param {boolean} discoverable |
| 147 */ |
| 148 discoverableChanged: function(discoverable) { |
| 149 var event = new CustomEvent('adapterchanged', { |
| 150 detail: { |
| 151 property: 'discoverable', |
| 152 value: discoverable, |
| 153 } |
| 154 }); |
| 155 this.adapterBroker_.dispatchEvent(event); |
| 156 }, |
| 157 |
| 158 /** |
| 159 * Fires adapterchanged event with "discovering" property changed. |
118 * @param {boolean} discovering | 160 * @param {boolean} discovering |
119 */ | 161 */ |
120 discoveringChanged: function(discovering) { | 162 discoveringChanged: function(discovering) { |
121 var event = new CustomEvent('adapterchanged', { | 163 var event = new CustomEvent('adapterchanged', { |
122 detail: { | 164 detail: { |
123 property: 'discovering', | 165 property: 'discovering', |
124 value: discovering, | 166 value: discovering, |
125 } | 167 } |
126 }); | 168 }); |
127 this.adapterBroker_.dispatchEvent(event); | 169 this.adapterBroker_.dispatchEvent(event); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 233 |
192 adapterBroker = new AdapterBroker(response.adapter); | 234 adapterBroker = new AdapterBroker(response.adapter); |
193 return adapterBroker; | 235 return adapterBroker; |
194 }); | 236 }); |
195 } | 237 } |
196 | 238 |
197 return { | 239 return { |
198 getAdapterBroker: getAdapterBroker, | 240 getAdapterBroker: getAdapterBroker, |
199 }; | 241 }; |
200 }); | 242 }); |
OLD | NEW |