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

Side by Side Diff: chrome/renderer/resources/extensions/experimental.bluetooth_custom_bindings.js

Issue 10536159: Bluetooth Extension API: Add a discovery API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reland Created 8 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Custom bindings for the Bluetooth API.
6
7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8 var sendRequest = require('sendRequest').sendRequest;
9
10 // Use custom bindings to create an undocumented event listener that will
11 // receive events about device discovery and call the event listener that was
12 // provided with the request to begin discovery.
13 chromeHidden.registerCustomHook('experimental.bluetooth', function(api) {
14 var apiFunctions = api.apiFunctions;
15
16 chromeHidden.bluetooth = {};
17 chromeHidden.bluetooth.handler = null;
18 chromeHidden.bluetooth.onDeviceDiscovered =
19 new chrome.Event("experimental.bluetooth.onDeviceDiscovered");
20
21 function deviceDiscoveredListener(device) {
22 if (chromeHidden.bluetooth.handler != null)
23 chromeHidden.bluetooth.handler(device);
24 }
25 chromeHidden.bluetooth.onDeviceDiscovered.addListener(
26 deviceDiscoveredListener);
27
28 apiFunctions.setHandleRequest('startDiscovery', function() {
29 var args = arguments;
30 if (args.length > 0 && args[0] && args[0].deviceCallback) {
31 chromeHidden.bluetooth.handler = args[0].deviceCallback;
32 }
33 sendRequest(this.name, args, this.definition.parameters);
34 });
35 apiFunctions.setHandleRequest('stopDiscovery', function() {
36 chromeHidden.bluetooth.handler = null;
37 sendRequest(this.name, args, this.definition.parameters);
38 });
39 });
OLDNEW
« no previous file with comments | « chrome/renderer/renderer_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698