Bluetooth: add Device events, and cleanup JS API
commit6bdba32ba75db9a92e04b632edf7efb7c54ebe1d
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Fri, 7 Mar 2014 22:12:49 +0000 (7 22:12 +0000)
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Fri, 7 Mar 2014 22:12:49 +0000 (7 22:12 +0000)
tree8d2265794030cdec6eb5123a180fba57773e0bce
parent311544d163440b69d47496e3ecbb88f6650147fe
Bluetooth: add Device events, and cleanup JS API

The JavaScript API for getting the set of devices known to the adapter
and dealing with discovery was difficult to use, and had a messy
implementation. By streamlining the API not only does it become much
easier to work with, but the implementation becomes much cleaner as
well.

chrome.bluetooth.getDevices() now simply returns an array of devices in
its callback, it's up to the application to filter these since profile
filtering is unreliable during discovery and on Low Energy.

chrome.bluetooth.startDiscovery() now only has a callback to indicate
a success to the command, the hidden event and listener has been
removed in favor of the new device events.

Add chrome.bluetooth.onDeviceAdded, chrome.bluetooth.onDeviceChanged
and chrome.bluetooth.onDeviceRemoved events. These return updated
device objects when they are first known, changed and removed
respectively.

Take the opportunity of writing a proper documentation page for these
new methods and events showing their usage.

BUG=345050
TEST=BluetoothApiTest updated and included
R=armansito@chromium.org, miket@chromium.org, rpaquay@chromium.org, sky@chromium.org

Review URL: https://codereview.chromium.org/177113013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255706 0039d316-1c4b-4281-b951-d872f2087c98
17 files changed:
chrome/browser/extensions/api/bluetooth/bluetooth_api.cc
chrome/browser/extensions/api/bluetooth/bluetooth_api.h
chrome/browser/extensions/api/bluetooth/bluetooth_apitest.cc
chrome/browser/extensions/api/bluetooth/bluetooth_event_router.cc
chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h
chrome/browser/extensions/event_names.cc
chrome/browser/extensions/event_names.h
chrome/common/extensions/api/bluetooth.idl
chrome/renderer/extensions/dispatcher.cc
chrome/renderer/resources/extensions/bluetooth_custom_bindings.js [deleted file]
chrome/renderer/resources/renderer_resources.grd
chrome/test/data/extensions/api_test/bluetooth/device_events/manifest.json [moved from chrome/test/data/extensions/api_test/bluetooth/get_devices_error/manifest.json with 59% similarity]
chrome/test/data/extensions/api_test/bluetooth/device_events/runtest.js [new file with mode: 0644]
chrome/test/data/extensions/api_test/bluetooth/discovery_callback/runtest.js
chrome/test/data/extensions/api_test/bluetooth/discovery_in_progress/runtest.js
chrome/test/data/extensions/api_test/bluetooth/get_devices/runtest.js
chrome/test/data/extensions/api_test/bluetooth/get_devices_error/runtest.js [deleted file]