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

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: cleanup 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
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 chromeHidden.registerCustomHook('experimental.bluetooth', function(api) {
11 var apiFunctions = api.apiFunctions;
12
13 chromeHidden.bluetooth = { handler: null };
14
15 function deviceDiscoveredListener(device) {
16 if (chromeHidden.experimental.bluetooth.handler)
17 chromeHidden.experimental.bluetooth.handler(device);
18 }
19
20 chrome.experimental.bluetooth._onDeviceDiscovered.addListener(
21 deviceDiscoveredListener);
22
23 apiFunctions.setHandleRequest('startDiscovery', function() {
24 var args = arguments;
25 if (args.length > 0 && args[0] && args[0].device_callback) {
26 chromeHidden.bluetooth.handler = args[0].device_callback;
27 }
28 sendRequest(this.name, args, this.definition.parameters);
29 });
30 apiFunctions.setHandleRequest('stopDiscovery', function() {
31 chromeHidden.bluetooth.handler = null;
32 sendRequest(this.name, args, this.definition.parameters);
33 });
34 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698