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

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

Issue 2567983007: bluetooth: Add adapter page to internals page. (Closed)
Patch Set: Merge upstream 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 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} */
11 var AdapterPtr; 11 var AdapterPtr;
12 /** @typedef {interfaces.BluetoothDevice.Device.ptrClass} */ 12 /** @typedef {interfaces.BluetoothDevice.Device.ptrClass} */
13 var DevicePtr; 13 var DevicePtr;
14 /** @typedef {interfaces.BluetoothAdapter.DiscoverySession.ptrClass} */ 14 /** @typedef {interfaces.BluetoothAdapter.DiscoverySession.ptrClass} */
15 var DiscoverySessionPtr; 15 var DiscoverySessionPtr;
16 16
17 /** 17 /**
18 * Enum of adapter property names. Used for adapterchanged events. 18 * Enum of adapter property names. Used for adapterchanged events.
19 * @enum {string} 19 * @enum {string}
20 */ 20 */
21 var AdapterProperty = { 21 var AdapterProperty = {
22 DISCOVERABLE: 'discoverable',
22 DISCOVERING: 'discovering', 23 DISCOVERING: 'discovering',
24 POWERED: 'powered',
25 PRESENT: 'present',
23 }; 26 };
24 27
25 /** 28 /**
26 * The proxy class of an adapter and router of adapter events. 29 * The proxy class of an adapter and router of adapter events.
27 * Exposes an EventTarget interface that allows other object to subscribe to 30 * Exposes an EventTarget interface that allows other object to subscribe to
28 * to specific AdapterClient events. 31 * to specific AdapterClient events.
29 * Provides proxy access to Adapter functions. Converts parameters to Mojo 32 * Provides proxy access to Adapter functions. Converts parameters to Mojo
30 * handles and back when necessary. 33 * handles and back when necessary.
31 * @constructor 34 * @constructor
32 * @extends {cr.EventTarget} 35 * @extends {cr.EventTarget}
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 * service. 118 * service.
116 * @constructor 119 * @constructor
117 * @param {!AdapterBroker} adapterBroker Broker to dispatch events through. 120 * @param {!AdapterBroker} adapterBroker Broker to dispatch events through.
118 */ 121 */
119 var AdapterClient = function(adapterBroker) { 122 var AdapterClient = function(adapterBroker) {
120 this.adapterBroker_ = adapterBroker; 123 this.adapterBroker_ = adapterBroker;
121 }; 124 };
122 125
123 AdapterClient.prototype = { 126 AdapterClient.prototype = {
124 /** 127 /**
125 * Fires adapterchanged event. 128 * Fires adapterchanged event with "present" property.
129 * @param {boolean} present
130 */
131 presentChanged: function(present) {
132 var event = new CustomEvent('adapterchanged', {
133 detail: {
134 property: AdapterProperty.PRESENT,
135 value: present,
136 }
137 });
138 this.adapterBroker_.dispatchEvent(event);
139 },
140
141 /**
142 * Fires adapterchanged event with "powered" property changed.
143 * @param {boolean} powered
144 */
145 poweredChanged: function(powered) {
146 var event = new CustomEvent('adapterchanged', {
147 detail: {
148 property: AdapterProperty.POWERED,
149 value: powered,
150 }
151 });
152 this.adapterBroker_.dispatchEvent(event);
153 },
154
155 /**
156 * Fires adapterchanged event with "discoverable" property changed.
157 * @param {boolean} discoverable
158 */
159 discoverableChanged: function(discoverable) {
160 var event = new CustomEvent('adapterchanged', {
161 detail: {
162 property: AdapterProperty.DISCOVERABLE,
163 value: discoverable,
164 }
165 });
166 this.adapterBroker_.dispatchEvent(event);
167 },
168
169 /**
170 * Fires adapterchanged event with "discovering" property changed.
126 * @param {boolean} discovering 171 * @param {boolean} discovering
127 */ 172 */
128 discoveringChanged: function(discovering) { 173 discoveringChanged: function(discovering) {
129 var event = new CustomEvent('adapterchanged', { 174 var event = new CustomEvent('adapterchanged', {
130 detail: { 175 detail: {
131 property: AdapterProperty.DISCOVERING, 176 property: AdapterProperty.DISCOVERING,
132 value: discovering, 177 value: discovering,
133 } 178 }
134 }); 179 });
135 this.adapterBroker_.dispatchEvent(event); 180 this.adapterBroker_.dispatchEvent(event);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 adapterBroker = new AdapterBroker(response.adapter); 245 adapterBroker = new AdapterBroker(response.adapter);
201 return adapterBroker; 246 return adapterBroker;
202 }); 247 });
203 } 248 }
204 249
205 return { 250 return {
206 AdapterProperty: AdapterProperty, 251 AdapterProperty: AdapterProperty,
207 getAdapterBroker: getAdapterBroker, 252 getAdapterBroker: getAdapterBroker,
208 }; 253 };
209 }); 254 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698