diff options
14 files changed, 37 insertions, 345 deletions
diff --git a/chrome/browser/chromeos/extensions/bluetooth_event_router.cc b/chrome/browser/chromeos/extensions/bluetooth_event_router.cc index f690527..d02649e 100644 --- a/chrome/browser/chromeos/extensions/bluetooth_event_router.cc +++ b/chrome/browser/chromeos/extensions/bluetooth_event_router.cc @@ -8,14 +8,10 @@ #include "base/json/json_writer.h" #include "base/memory/ref_counted.h" -#include "base/utf_string_conversions.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" -#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h" -#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" #include "chrome/browser/extensions/extension_event_names.h" #include "chrome/browser/extensions/extension_event_router.h" -#include "chrome/common/extensions/api/experimental_bluetooth.h" namespace chromeos { @@ -63,58 +59,26 @@ scoped_refptr<BluetoothSocket> ExtensionBluetoothEventRouter::GetSocket( return socket_entry->second; } -void ExtensionBluetoothEventRouter::SetSendDiscoveryEvents(bool should_send) { - send_discovery_events_ = should_send; -} - void ExtensionBluetoothEventRouter::AdapterPresentChanged( chromeos::BluetoothAdapter* adapter, bool present) { DCHECK(adapter == adapter_.get()); - DispatchBooleanValueEvent( - extension_event_names::kBluetoothOnAvailabilityChanged, + DispatchEvent(extension_event_names::kBluetoothOnAvailabilityChanged, present); } void ExtensionBluetoothEventRouter::AdapterPoweredChanged( chromeos::BluetoothAdapter* adapter, bool has_power) { DCHECK(adapter == adapter_.get()); - DispatchBooleanValueEvent( - extension_event_names::kBluetoothOnPowerChanged, - has_power); -} - -void ExtensionBluetoothEventRouter::DeviceAdded( - chromeos::BluetoothAdapter* adapter, chromeos::BluetoothDevice* device) { - if (!send_discovery_events_) - return; - - DCHECK(adapter == adapter_.get()); - - extensions::api::experimental_bluetooth::Device extension_device; - extensions::api::experimental_bluetooth::BluetoothDeviceToApiDevice( - *device, &extension_device); - - ListValue args; - args.Append(extension_device.ToValue().release()); - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - - profile_->GetExtensionEventRouter()->DispatchEventToRenderers( - extension_event_names::kBluetoothOnDeviceDiscovered, - json_args, - NULL, - GURL()); + DispatchEvent(extension_event_names::kBluetoothOnPowerChanged, has_power); } -void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( +void ExtensionBluetoothEventRouter::DispatchEvent( const char* event_name, bool value) { ListValue args; args.Append(Value::CreateBooleanValue(value)); std::string json_args; base::JSONWriter::Write(&args, &json_args); - // TODO(bryeung): only dispatch the event to interested renderers - // crbug.com/133179 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( event_name, json_args, NULL, GURL()); } diff --git a/chrome/browser/chromeos/extensions/bluetooth_event_router.h b/chrome/browser/chromeos/extensions/bluetooth_event_router.h index 2b38b38..e33b689 100644 --- a/chrome/browser/chromeos/extensions/bluetooth_event_router.h +++ b/chrome/browser/chromeos/extensions/bluetooth_event_router.h @@ -37,25 +37,18 @@ class ExtensionBluetoothEventRouter // Get the BluetoothSocket corresponding to |id|. scoped_refptr<BluetoothSocket> GetSocket(int id); - // Sets whether or not DeviceAdded events will be dispatched to extensions. - void SetSendDiscoveryEvents(bool should_send); - // Override from chromeos::BluetoothAdapter::Observer - virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter, - bool present) OVERRIDE; - virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter, - bool has_power) OVERRIDE; - virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter, - chromeos::BluetoothDevice* device) OVERRIDE; + virtual void AdapterPresentChanged( + chromeos::BluetoothAdapter* adapter, bool present) OVERRIDE; + virtual void AdapterPoweredChanged( + chromeos::BluetoothAdapter* adapter, bool has_power) OVERRIDE; // Exposed for testing. void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) { adapter_.reset(adapter); } private: - void DispatchBooleanValueEvent(const char* event_name, bool value); - - bool send_discovery_events_; + void DispatchEvent(const char* event_name, bool value); Profile* profile_; scoped_ptr<chromeos::BluetoothAdapter> adapter_; diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc index 76d2233..9e7eebd 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.cc @@ -10,7 +10,7 @@ #include <string> -#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/extensions/api/experimental_bluetooth.h" @@ -19,6 +19,7 @@ #if defined(OS_CHROMEOS) #include "base/memory/ref_counted.h" #include "base/safe_strerror_posix.h" +#include "base/synchronization/lock.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_adapter.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_socket.h" @@ -39,6 +40,23 @@ chromeos::BluetoothAdapter* GetMutableAdapter(Profile* profile) { return GetEventRouter(profile)->GetMutableAdapter(); } +// Fill in a Device object from a chromeos::BluetoothDevice. +void PopulateApiDevice(const chromeos::BluetoothDevice& device, + extensions::api::experimental_bluetooth::Device* out) { + out->name = UTF16ToUTF8(device.GetName()); + out->address = device.address(); + out->paired = device.IsPaired(); + out->bonded = device.IsBonded(); + out->connected = device.IsConnected(); +} + +// The caller takes ownership of the returned pointer. +base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device) { + extensions::api::experimental_bluetooth::Device api_device; + PopulateApiDevice(device, &api_device); + return api_device.ToValue().release(); +} + } // namespace #endif @@ -51,9 +69,6 @@ const char kCouldNotSetOutOfBandPairingData[] = const char kFailedToConnect[] = "Connection failed"; const char kInvalidDevice[] = "Invalid device"; const char kSocketNotFoundError[] = "Socket not found: invalid socket id"; -const char kStartDiscoveryFailed[] = - "Starting discovery failed, or already discovering"; -const char kStopDiscoveryFailed[] = "Failed to stop discovery"; } // namespace @@ -95,7 +110,7 @@ void BluetoothGetDevicesFunction::AddDeviceIfTrueCallback( DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); if (shouldAdd) - list->Append(experimental_bluetooth::BluetoothDeviceToValue(*device)); + list->Append(BluetoothDeviceToValue(*device)); callbacks_pending_--; if (callbacks_pending_ == -1) { @@ -132,7 +147,7 @@ bool BluetoothGetDevicesFunction::RunImpl() { continue; if (options.name.get() == NULL) { - matches->Append(experimental_bluetooth::BluetoothDeviceToValue(*device)); + matches->Append(BluetoothDeviceToValue(*device)); continue; } @@ -162,8 +177,7 @@ void BluetoothConnectFunction::ConnectToServiceCallback( int socket_id = GetEventRouter(profile())->RegisterSocket(socket); experimental_bluetooth::Socket result_socket; - experimental_bluetooth::BluetoothDeviceToApiDevice( - *device, &result_socket.device); + PopulateApiDevice(*device, &result_socket.device); result_socket.service_uuid = service_uuid; result_socket.id = socket_id; result_.reset(result_socket.ToValue().release()); @@ -410,54 +424,6 @@ bool BluetoothGetLocalOutOfBandPairingDataFunction::RunImpl() { return true; } -void BluetoothStartDiscoveryFunction::OnSuccessCallback() { - SendResponse(true); - Release(); // Added in RunImpl -} - -void BluetoothStartDiscoveryFunction::OnErrorCallback() { - SetError(kStartDiscoveryFailed); - SendResponse(false); - Release(); // Added in RunImpl -} - -bool BluetoothStartDiscoveryFunction::RunImpl() { - GetEventRouter(profile())->SetSendDiscoveryEvents(true); - - // BluetoothAdapter will throw an error if we SetDiscovering(true) when - // discovery is already in progress - if (GetMutableAdapter(profile())->IsDiscovering()) { - SendResponse(true); - return true; - } - - AddRef(); // Removed in whichever callback is called. - GetMutableAdapter(profile())->SetDiscovering(true, - base::Bind(&BluetoothStartDiscoveryFunction::OnSuccessCallback, this), - base::Bind(&BluetoothStartDiscoveryFunction::OnErrorCallback, this)); - return true; -} - -void BluetoothStopDiscoveryFunction::OnSuccessCallback() { - SendResponse(true); - Release(); // Added in RunImpl -} - -void BluetoothStopDiscoveryFunction::OnErrorCallback() { - SetError(kStopDiscoveryFailed); - SendResponse(false); - Release(); // Added in RunImpl -} - -bool BluetoothStopDiscoveryFunction::RunImpl() { - GetEventRouter(profile())->SetSendDiscoveryEvents(false); - AddRef(); // Removed in whichever callback is called. - GetMutableAdapter(profile())->SetDiscovering(false, - base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), - base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); - return true; -} - #else // ----------------------------------------------------------------------------- @@ -517,16 +483,6 @@ bool BluetoothWriteFunction::Respond() { return false; } -bool BluetoothStartDiscoveryFunction::RunImpl() { - NOTREACHED() << "Not implemented yet"; - return false; -} - -bool BluetoothStopDiscoveryFunction::RunImpl() { - NOTREACHED() << "Not implemented yet"; - return false; -} - bool BluetoothSetOutOfBandPairingDataFunction::RunImpl() { NOTREACHED() << "Not implemented yet"; return false; diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h index 4abe159..669873a 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api.h +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_api.h @@ -190,40 +190,6 @@ class BluetoothGetLocalOutOfBandPairingDataFunction virtual bool RunImpl() OVERRIDE; }; -class BluetoothStartDiscoveryFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.startDiscovery") - - protected: - virtual ~BluetoothStartDiscoveryFunction() {} - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; - -#if defined(OS_CHROMEOS) - private: - void OnSuccessCallback(); - void OnErrorCallback(); -#endif -}; - -class BluetoothStopDiscoveryFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME("experimental.bluetooth.stopDiscovery") - - protected: - virtual ~BluetoothStopDiscoveryFunction() {} - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; - -#if defined(OS_CHROMEOS) - private: - void OnSuccessCallback(); - void OnErrorCallback(); -#endif -}; - } // namespace api } // namespace extensions diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc deleted file mode 100644 index 5503434..0000000 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2012 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. - -#include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" - -#if defined(OS_CHROMEOS) - -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" -#include "chrome/common/extensions/api/experimental_bluetooth.h" - -namespace extensions { -namespace api { -namespace experimental_bluetooth { - -// Fill in a Device object from a chromeos::BluetoothDevice. -void BluetoothDeviceToApiDevice( - const chromeos::BluetoothDevice& device, - Device* out) { - out->name = UTF16ToUTF8(device.GetName()); - out->address = device.address(); - out->paired = device.IsPaired(); - out->bonded = device.IsBonded(); - out->connected = device.IsConnected(); -} - -// The caller takes ownership of the returned pointer. -base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device) { - extensions::api::experimental_bluetooth::Device api_device; - BluetoothDeviceToApiDevice(device, &api_device); - return api_device.ToValue().release(); -} - -} // namespace experimental_bluetooth -} // namespace api -} // namespace extensions - -#endif diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h b/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h deleted file mode 100644 index bc1ba9e..0000000 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2012 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. - -#ifndef CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_UTILS_H_ -#define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_UTILS_H_ -#pragma once - -#if defined(OS_CHROMEOS) - -#include "base/values.h" -#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" -#include "chrome/common/extensions/api/experimental_bluetooth.h" - -namespace extensions { -namespace api { -namespace experimental_bluetooth { - -// Fill in a Device object from a chromeos::BluetoothDevice. -void BluetoothDeviceToApiDevice( - const chromeos::BluetoothDevice& device, - Device* out); - -// The caller takes ownership of the returned pointer. -base::Value* BluetoothDeviceToValue(const chromeos::BluetoothDevice& device); - -} // namespace experimental_bluetooth -} // namespace api -} // namespace extensions - -#endif - -#endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_UTILS_H_ diff --git a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc index a8e016c..f181607 100644 --- a/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc +++ b/chrome/browser/extensions/api/bluetooth/bluetooth_apitest_chromeos.cc @@ -22,6 +22,13 @@ using extensions::Extension; namespace utils = extension_function_test_utils; namespace api = extensions::api; +namespace chromeos { + +class BluetoothAdapater; + +} // namespace chromeos + + namespace { class BluetoothApiTest : public PlatformAppApiTest { @@ -281,52 +288,3 @@ IN_PROC_BROWSER_TEST_F(BluetoothApiTest, MAYBE_SetOutOfBandPairingData) { // ArrayBuffers in the arguments to the RunFunctionAnd* methods. // crbug.com/132796 } - -IN_PROC_BROWSER_TEST_F(BluetoothApiTest, Discovery) { - // TODO(bryeung): test that no events are sent now (crbug.com/132616) - - // Try with a failure to start - EXPECT_CALL(*mock_adapter_, - SetDiscovering(true, - testing::_, - testing::Truly(CallClosure))); - scoped_refptr<api::BluetoothStartDiscoveryFunction> start_function; - start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); - std::string error( - utils::RunFunctionAndReturnError(start_function, "[]", browser())); - ASSERT_TRUE(!error.empty()); - - // Reset for a successful start - testing::Mock::VerifyAndClearExpectations(mock_adapter_); - EXPECT_CALL(*mock_adapter_, - SetDiscovering(true, - testing::Truly(CallClosure), - testing::_)); - - start_function = setupFunction(new api::BluetoothStartDiscoveryFunction); - (void)utils::RunFunctionAndReturnError(start_function, "[]", browser()); - - // TODO(bryeung): test that events are sent now (crbug.com/132616) - - // Reset to try stopping - testing::Mock::VerifyAndClearExpectations(mock_adapter_); - EXPECT_CALL(*mock_adapter_, - SetDiscovering(false, - testing::Truly(CallClosure), - testing::_)); - scoped_refptr<api::BluetoothStopDiscoveryFunction> stop_function; - stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); - (void)utils::RunFunctionAndReturnResult(stop_function, "[]", browser()); - - // TODO(bryeung): test that no events are sent now (crbug.com/132616) - - // Reset to try stopping with an error - testing::Mock::VerifyAndClearExpectations(mock_adapter_); - EXPECT_CALL(*mock_adapter_, - SetDiscovering(false, - testing::_, - testing::Truly(CallClosure))); - stop_function = setupFunction(new api::BluetoothStopDiscoveryFunction); - error = utils::RunFunctionAndReturnError(stop_function, "[]", browser()); - ASSERT_TRUE(!error.empty()); -} diff --git a/chrome/browser/extensions/extension_event_names.cc b/chrome/browser/extensions/extension_event_names.cc index 9d76081..5a8391f 100644 --- a/chrome/browser/extensions/extension_event_names.cc +++ b/chrome/browser/extensions/extension_event_names.cc @@ -58,8 +58,6 @@ const char kOnOffscreenTabUpdated[] = "experimental.offscreenTabs.onUpdated"; #if defined(OS_CHROMEOS) const char kBluetoothOnAvailabilityChanged[] = "experimental.bluetooth.onAvailabilityChanged"; -const char kBluetoothOnDeviceDiscovered[] = - "experimental.bluetooth.onDeviceDiscovered"; const char kBluetoothOnPowerChanged[] = "experimental.bluetooth.onPowerChanged"; #endif diff --git a/chrome/browser/extensions/extension_event_names.h b/chrome/browser/extensions/extension_event_names.h index ca01863..b65fbafe 100644 --- a/chrome/browser/extensions/extension_event_names.h +++ b/chrome/browser/extensions/extension_event_names.h @@ -67,7 +67,6 @@ extern const char kOnOffscreenTabUpdated[]; #if defined(OS_CHROMEOS) // Bluetooth. extern const char kBluetoothOnAvailabilityChanged[]; -extern const char kBluetoothOnDeviceDiscovered[]; extern const char kBluetoothOnPowerChanged[]; #endif diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 70d3332..9c3ba84 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -75,8 +75,6 @@ 'browser/extensions/api/app_window/app_window_api.h', 'browser/extensions/api/bluetooth/bluetooth_api.cc', 'browser/extensions/api/bluetooth/bluetooth_api.h', - 'browser/extensions/api/bluetooth/bluetooth_api_utils.cc', - 'browser/extensions/api/bluetooth/bluetooth_api_utils.h', 'browser/extensions/api/browsing_data/browsing_data_api.cc', 'browser/extensions/api/browsing_data/browsing_data_api.h', 'browser/extensions/api/content_settings/content_settings_api.cc', diff --git a/chrome/common/extensions/api/experimental_bluetooth.idl b/chrome/common/extensions/api/experimental_bluetooth.idl index 5ef65b8..34dffe7d 100644 --- a/chrome/common/extensions/api/experimental_bluetooth.idl +++ b/chrome/common/extensions/api/experimental_bluetooth.idl @@ -44,7 +44,6 @@ callback AddressCallback = void (DOMString result); callback BooleanCallback = void (boolean result); callback DataCallback = void (ArrayBuffer result); - callback DeviceCallback = void (Device device); callback DevicesCallback = void (Device[] result); callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); callback ResultCallback = void (); @@ -105,12 +104,6 @@ OutOfBandPairingData? data; }; - // Options for the startDiscovery function. - dictionary StartDiscoveryOptions { - // Called for each device that is discovered. - DeviceCallback deviceCallback; - }; - // These functions all report failures via chrome.extension.lastError. interface Functions { // Checks if the system has bluetooth support. @@ -167,20 +160,6 @@ // |callback| : Called to indicate success or failure. static void setOutOfBandPairingData(SetOutOfBandPairingDataOptions options, optional ResultCallback callback); - - // Start discovery. Discovered devices will be returned via the - // |onDeviceDiscovered| callback. Note that discovery can be resource - // intensive. stopDiscovery should be called as soon as is convenient. - // |options| : The options for this function. - // |callback| : Called to indicate success or failure. - static void startDiscovery( - StartDiscoveryOptions options, - optional ResultCallback callback); - - // Stop discovery. - // |callback| : Called to indicate success or failure. - static void stopDiscovery( - optional ResultCallback callback); }; interface Events { @@ -191,9 +170,5 @@ // Fired when the power state of bluetooth on the system changes. // |powered| : True if bluetooth is powered, false otherwise. static void onPowerChanged(boolean has_power); - - // Used to return discovered devices to the extension. Users should not - // add listeners to this event directly. - static void onDeviceDiscovered_(Device device); }; }; diff --git a/chrome/renderer/extensions/extension_dispatcher.cc b/chrome/renderer/extensions/extension_dispatcher.cc index 2539cfd..add0813 100644 --- a/chrome/renderer/extensions/extension_dispatcher.cc +++ b/chrome/renderer/extensions/extension_dispatcher.cc @@ -568,8 +568,6 @@ void ExtensionDispatcher::PopulateSourceMap() { source_map_.RegisterSource("devtools", IDR_DEVTOOLS_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("experimental.app", IDR_EXPERIMENTAL_APP_CUSTOM_BINDINGS_JS); - source_map_.RegisterSource("experimental.bluetooth", - IDR_EXPERIMENTAL_BLUETOOTH_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("experimental.mediaGalleries", IDR_MEDIA_GALLERY_CUSTOM_BINDINGS_JS); source_map_.RegisterSource("experimental.offscreen", diff --git a/chrome/renderer/renderer_resources.grd b/chrome/renderer/renderer_resources.grd index 85675bc..475bf8c 100644 --- a/chrome/renderer/renderer_resources.grd +++ b/chrome/renderer/renderer_resources.grd @@ -45,7 +45,6 @@ without changes to the corresponding grd file. fb9 --> <include name="IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS" file="resources\extensions\declarative_webrequest_custom_bindings.js" type="BINDATA" /> <include name="IDR_DEVTOOLS_CUSTOM_BINDINGS_JS" file="resources\extensions\devtools_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXPERIMENTAL_APP_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.app_custom_bindings.js" type="BINDATA" /> - <include name="IDR_EXPERIMENTAL_BLUETOOTH_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.bluetooth_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXPERIMENTAL_OFFSCREENTABS_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.offscreenTabs_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXPERIMENTAL_USB_CUSTOM_BINDINGS_JS" file="resources\extensions\experimental.usb_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXTENSION_CUSTOM_BINDINGS_JS" file="resources\extensions\extension_custom_bindings.js" type="BINDATA" /> diff --git a/chrome/renderer/resources/extensions/experimental.bluetooth_custom_bindings.js b/chrome/renderer/resources/extensions/experimental.bluetooth_custom_bindings.js deleted file mode 100644 index 58a8d95..0000000 --- a/chrome/renderer/resources/extensions/experimental.bluetooth_custom_bindings.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) 2012 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. - -// Custom bindings for the Bluetooth API. - -var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); -var sendRequest = require('sendRequest').sendRequest; - -// Use custom bindings to create an undocumented event listener that will -// receive events about device discovery and call the event listener that was -// provided with the request to begin discovery. -chromeHidden.registerCustomHook('experimental.bluetooth', function(api) { - var apiFunctions = api.apiFunctions; - - chromeHidden.bluetooth = {}; - chromeHidden.bluetooth.handler = null; - chromeHidden.bluetooth.onDeviceDiscovered = - new chrome.Event("experimental.bluetooth.onDeviceDiscovered"); - - function deviceDiscoveredListener(device) { - if (chromeHidden.bluetooth.handler != null) - chromeHidden.bluetooth.handler(device); - } - chromeHidden.bluetooth.onDeviceDiscovered.addListener( - deviceDiscoveredListener); - - apiFunctions.setHandleRequest('startDiscovery', function() { - var args = arguments; - if (args.length > 0 && args[0] && args[0].deviceCallback) { - chromeHidden.bluetooth.handler = args[0].deviceCallback; - } - sendRequest(this.name, args, this.definition.parameters); - }); - apiFunctions.setHandleRequest('stopDiscovery', function() { - chromeHidden.bluetooth.handler = null; - sendRequest(this.name, args, this.definition.parameters); - }); -}); |