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

Unified Diff: chrome/browser/resources/bluetooth_internals/interfaces.js

Issue 2446823002: bluetooth: Componentize device list in chrome://bluetooth-internals. (Closed)
Patch Set: Formatting changes, comments Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/bluetooth_internals/interfaces.js
diff --git a/chrome/browser/resources/bluetooth_internals/interfaces.js b/chrome/browser/resources/bluetooth_internals/interfaces.js
new file mode 100644
index 0000000000000000000000000000000000000000..92366c289bf952c3f3dd1cf653ac10454fc5dd4e
--- /dev/null
+++ b/chrome/browser/resources/bluetooth_internals/interfaces.js
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * Javascript for Mojo interface helpers, served from
+ * chrome://bluetooth-internals/.
+ */
+
+cr.define('interfaces', function() {
+ /**
+ * Initializes Mojo proxies for page and Bluetooth services.
ortuno 2016/11/03 22:14:15 Also mention that the interfaces are added to the
mbrunson 2016/11/03 23:59:40 Done.
+ * @return {!Promise<interfaces.BluetoothAdapter.Adapter>} resolves with
+ * Adapter if acquired, rejects if Bluetooth is not supported.
+ */
+ function initializeProxies() {
+ return importModules([
+ 'content/public/renderer/frame_interfaces',
+ 'device/bluetooth/public/interfaces/adapter.mojom',
+ 'device/bluetooth/public/interfaces/device.mojom',
+ 'mojo/public/js/connection',
+ ]).then(function([frameInterfaces, bluetoothAdapter, bluetoothDevice,
+ connection]) {
+ Object.assign(interfaces, {
+ BluetoothAdapter: bluetoothAdapter,
+ BluetoothDevice: bluetoothDevice,
+ Connection: connection,
+ });
+
+ var adapterFactory = connection.bindHandleToProxy(
ortuno 2016/11/03 22:14:15 Could you move the adapter code to the broker?
mbrunson 2016/11/03 23:59:40 Done.
+ frameInterfaces.getInterface(bluetoothAdapter.AdapterFactory.name),
+ bluetoothAdapter.AdapterFactory);
+
+ // Get an Adapter service.
+ return adapterFactory.getAdapter();
+ }).then(function(response) {
+ if (!response.adapter) {
+ throw new Error('Bluetooth Not Supported on this platform.');
+ }
+
+ return interfaces.Connection.bindHandleToProxy(
+ response.adapter,
+ interfaces.BluetoothAdapter.Adapter);
+ });
+ }
+
+ return {
+ initialize: initializeProxies,
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698