| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // Custom binding for the Bluetooth API. | 5 // Custom binding for the Bluetooth API. |
| 6 | 6 |
| 7 var binding = require('binding').Binding.create('bluetooth'); | 7 var binding = require('binding').Binding.create('bluetooth'); |
| 8 | 8 |
| 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 9 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 10 var chrome = requireNative('chrome').GetChrome(); | 10 var chrome = requireNative('chrome').GetChrome(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 chromeHidden.bluetooth.deviceDiscoveredHandler); | 48 chromeHidden.bluetooth.deviceDiscoveredHandler); |
| 49 sendRequest(this.name, | 49 sendRequest(this.name, |
| 50 args, | 50 args, |
| 51 this.definition.parameters, | 51 this.definition.parameters, |
| 52 {customCallback:this.customCallback}); | 52 {customCallback:this.customCallback}); |
| 53 } else { | 53 } else { |
| 54 callCallbackIfPresent( | 54 callCallbackIfPresent( |
| 55 args, "deviceCallback is required in the options object"); | 55 args, "deviceCallback is required in the options object"); |
| 56 return; | 56 return; |
| 57 } | 57 } |
| 58 }); | 58 }, true); |
| 59 apiFunctions.setCustomCallback('startDiscovery', | 59 apiFunctions.setCustomCallback('startDiscovery', |
| 60 function(name, request, response) { | 60 function(name, request, response) { |
| 61 if (chrome.runtime.lastError) { | 61 if (chrome.runtime.lastError) { |
| 62 clearDeviceDiscoveredHandler(); | 62 clearDeviceDiscoveredHandler(); |
| 63 return; | 63 return; |
| 64 } | 64 } |
| 65 }); | 65 }); |
| 66 apiFunctions.setHandleRequest('stopDiscovery', | 66 apiFunctions.setHandleRequest('stopDiscovery', |
| 67 function() { | 67 function() { |
| 68 clearDeviceDiscoveredHandler(); | 68 clearDeviceDiscoveredHandler(); |
| 69 sendRequest(this.name, arguments, this.definition.parameters); | 69 sendRequest(this.name, arguments, this.definition.parameters); |
| 70 }); | 70 }, true); |
| 71 | 71 |
| 72 // An object to hold state during one call to getDevices. | 72 // An object to hold state during one call to getDevices. |
| 73 chromeHidden.bluetooth.getDevicesState = null; | 73 chromeHidden.bluetooth.getDevicesState = null; |
| 74 | 74 |
| 75 // Hidden events used to deliver getDevices data to the client callbacks | 75 // Hidden events used to deliver getDevices data to the client callbacks |
| 76 chromeHidden.bluetooth.onDeviceSearchResult = | 76 chromeHidden.bluetooth.onDeviceSearchResult = |
| 77 new chrome.Event("bluetooth.onDeviceSearchResult"); | 77 new chrome.Event("bluetooth.onDeviceSearchResult"); |
| 78 chromeHidden.bluetooth.onDeviceSearchFinished = | 78 chromeHidden.bluetooth.onDeviceSearchFinished = |
| 79 new chrome.Event("bluetooth.onDeviceSearchFinished"); | 79 new chrome.Event("bluetooth.onDeviceSearchFinished"); |
| 80 | 80 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 } | 152 } |
| 153 | 153 |
| 154 chromeHidden.bluetooth.getDevicesState = state; | 154 chromeHidden.bluetooth.getDevicesState = state; |
| 155 addDeviceSearchListeners(); | 155 addDeviceSearchListeners(); |
| 156 | 156 |
| 157 return args; | 157 return args; |
| 158 }); | 158 }); |
| 159 }); | 159 }); |
| 160 | 160 |
| 161 exports.binding = binding.generate(); | 161 exports.binding = binding.generate(); |
| OLD | NEW |