summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorortuno <ortuno@chromium.org>2016-02-11 12:06:49 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-11 20:08:16 +0000
commit6c3fd3ccf5925c7d52d886cdcb308b4862ad690b (patch)
tree4f358c50fbfb53aa146e895a17aab134bfcdf40b
parentf4ac65f49a25025e54c0daa2097852f0d8c48277 (diff)
downloadchromium_src-6c3fd3ccf5925c7d52d886cdcb308b4862ad690b.zip
chromium_src-6c3fd3ccf5925c7d52d886cdcb308b4862ad690b.tar.gz
chromium_src-6c3fd3ccf5925c7d52d886cdcb308b4862ad690b.tar.bz2
bluetooth: Enable Web Bluetooth through experimental framework
This enables Web Bluetooth through experimental frameworks in supported platforms. Intent to Experiment: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/coyvHj1u2Z8 Adds the APIExperimentEnabled extended binding so that the bindings are visible to domains specified by the Experimental Framework. Also adds WebBluetooth to frames and BluetoothDispatcherHost to processes' filters for supported platforms. TEST=Manual testing required: Launch chrome with the following command line flag: --enable-blink-features=ExperimentalFramework and perform the following tests: On a Chrome OS device and an Android device: 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth Works". 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/not-allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth Unavailable". On a Linux, OSX and Windows devices: 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth blocked". 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/not-allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth Unavailable". Launch Chrome with the following command line flags: --enable-blink-features=ExperimentalFramework --enable-web-bluetooth On a Chrome OS, Android, Linux, OSX, and Windows devices: 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth Works". On a Chrome OS, Android, Linux, OSX, and Windows devices: 1. Visit: https://g-ortuno.github.io/web-bluetooth-sandbox/not-allowed.html 2. Press the "Run Test" button. 3. "Web Bluetooth bindings" should be "Present" and "Use Web Bluetooth" should be "Bluetooth Works". BUG=584113 Review URL: https://codereview.chromium.org/1662183002 Cr-Commit-Position: refs/heads/master@{#374954}
-rw-r--r--content/browser/bluetooth/bluetooth_dispatcher_host.cc5
-rw-r--r--content/browser/renderer_host/render_process_host_impl.cc9
-rw-r--r--content/renderer/render_frame_impl.cc3
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt8
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp12
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/Bluetooth.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothCharacteristicProperties.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothGATTService.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.idl1
-rw-r--r--third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.idl5
-rw-r--r--third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in2
-rw-r--r--third_party/WebKit/Source/web/WebLocalFrameImpl.cpp9
16 files changed, 51 insertions, 10 deletions
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index 69a7376..c5fca31 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -254,11 +254,6 @@ BluetoothDispatcherHost::BluetoothDispatcherHost(int render_process_id)
// Bind all future weak pointers to the UI thread.
weak_ptr_on_ui_thread_ = weak_ptr_factory_.GetWeakPtr();
weak_ptr_on_ui_thread_.get(); // Associates with UI thread.
-
- if (BluetoothAdapterFactory::IsBluetoothAdapterAvailable())
- BluetoothAdapterFactory::GetAdapter(
- base::Bind(&BluetoothDispatcherHost::set_adapter,
- weak_ptr_factory_.GetWeakPtr()));
}
void BluetoothDispatcherHost::OnDestruct() const {
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 80f1f0e..623c40a 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1057,7 +1057,14 @@ void RenderProcessHostImpl::CreateMessageFilters() {
#endif
AddFilter(new GeofencingDispatcherHost(
storage_partition_impl_->GetGeofencingManager()));
- if (browser_command_line.HasSwitch(switches::kEnableWebBluetooth)) {
+
+ bool enable_web_bluetooth =
+ browser_command_line.HasSwitch(switches::kEnableWebBluetooth);
+#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
+ enable_web_bluetooth = true;
+#endif
+
+ if (enable_web_bluetooth) {
bluetooth_dispatcher_host_ = new BluetoothDispatcherHost(GetID());
AddFilter(bluetooth_dispatcher_host_.get());
}
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index a2242cc..6bbc484 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -4363,7 +4363,8 @@ void RenderFrameImpl::unregisterProtocolHandler(const WebString& scheme,
}
blink::WebBluetooth* RenderFrameImpl::bluetooth() {
- if (!bluetooth_) {
+ // ChildThreadImpl::current() is null in some tests.
+ if (!bluetooth_ && ChildThreadImpl::current()) {
bluetooth_.reset(new WebBluetoothImpl(
ChildThreadImpl::current()->thread_safe_sender(), routing_id_));
}
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
index 1e9a3c2..6145009 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -3027,6 +3027,7 @@ interface Navigator
getter appCodeName
getter appName
getter appVersion
+ getter bluetooth
getter cookieEnabled
getter doNotTrack
getter geolocation
@@ -5835,6 +5836,13 @@ interface webkitURL
setter search
setter username
[GLOBAL OBJECT]
+ attribute BluetoothAdvertisingData
+ attribute BluetoothCharacteristicProperties
+ attribute BluetoothDevice
+ attribute BluetoothGATTCharacteristic
+ attribute BluetoothGATTRemoteServer
+ attribute BluetoothGATTService
+ attribute BluetoothUUID
attribute GCController
attribute accessibilityController
attribute applicationCache
diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
index 91ba172..35f7646 100644
--- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
@@ -14,6 +14,7 @@
#include "modules/bluetooth/BluetoothSupplement.h"
#include "modules/bluetooth/BluetoothUUID.h"
#include "modules/bluetooth/RequestDeviceOptions.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "public/platform/modules/bluetooth/WebBluetooth.h"
#include "public/platform/modules/bluetooth/WebRequestDeviceOptions.h"
@@ -128,6 +129,17 @@ static void convertRequestDeviceOptions(const RequestDeviceOptions& options, Web
// https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetooth-requestdevice
ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, const RequestDeviceOptions& options, ExceptionState& exceptionState)
{
+ // By adding the "APIExperimentEnabled" extended binding, we enable the
+ // requestDevice function on all platforms for whitelisted domains. Since we
+ // only support Chrome OS and Android for this experiment we reject any
+ // promises from other platforms unless they have the enable-web-bluetooth
+ // flag on.
+#if !OS(CHROMEOS) && !OS(ANDROID)
+ if (!RuntimeEnabledFeatures::webBluetoothEnabled()) {
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NotSupportedError, "Web Bluetooth is not enabled on this platform. To find out how to enable it and the current implementation status visit https://goo.gl/HKa2If"));
+ }
+#endif
+
// 1. If the incumbent settings object is not a secure context, reject promise with a SecurityError and abort these steps.
String errorMessage;
if (!scriptState->executionContext()->isSecureContext(errorMessage)) {
diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.idl b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.idl
index 28cf361..6bea2a7 100644
--- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.idl
@@ -8,6 +8,7 @@
GarbageCollected,
NoInterfaceObject,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface Bluetooth {
[CallWith=ScriptState, RaisesException] Promise<BluetoothDevice> requestDevice (
RequestDeviceOptions options
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl
index 6e0454d..f60763e 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothAdvertisingData.idl
@@ -9,6 +9,7 @@
[
GarbageCollected,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothAdvertisingData {
// readonly attribute unsigned short? appearance;
readonly attribute byte? txPower;
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothCharacteristicProperties.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothCharacteristicProperties.idl
index 93854da..c8dc68f 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothCharacteristicProperties.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothCharacteristicProperties.idl
@@ -9,6 +9,7 @@
[
GarbageCollected,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothCharacteristicProperties {
readonly attribute boolean broadcast;
readonly attribute boolean read;
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl
index c753ad2..3251ffe 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.idl
@@ -15,6 +15,7 @@ enum VendorIDSource {
GarbageCollected,
ActiveDOMObject,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothDevice : EventTarget
// Implement ServiceEventHandlers interface: http://crbug.com/421670
// : ServiceEventHandlers
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl
index b9a5379..10a13f2 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTCharacteristic.idl
@@ -10,6 +10,7 @@
GarbageCollected,
ActiveDOMObject,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothGATTCharacteristic : EventTarget {//: CharacteristicEventHandlers {
// TODO(ortuno): Add test to make sure service matches the service
// used to call getCharacteristic.
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.idl
index 828540f..d8f4635 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTRemoteServer.idl
@@ -9,6 +9,7 @@
[
GarbageCollected,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothGATTRemoteServer
{
readonly attribute BluetoothDevice device;
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTService.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTService.idl
index b6cef73..0dfc8c0 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTService.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothGATTService.idl
@@ -9,6 +9,7 @@
[
GarbageCollected,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothGATTService { // : ServiceEventHandlers {
readonly attribute UUID uuid;
readonly attribute boolean isPrimary;
diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.idl b/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.idl
index f3eea33..6db619e 100644
--- a/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothUUID.idl
@@ -10,6 +10,7 @@
[
GarbageCollected,
RuntimeEnabled=WebBluetooth,
+ APIExperimentEnabled=WebBluetooth,
] interface BluetoothUUID {
[RaisesException] static UUID getService((DOMString or unsigned long) name);
[RaisesException] static UUID getCharacteristic((DOMString or unsigned long) name);
diff --git a/third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.idl b/third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.idl
index 671f652..ce9971a 100644
--- a/third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.idl
+++ b/third_party/WebKit/Source/modules/bluetooth/NavigatorBluetooth.idl
@@ -7,5 +7,8 @@
[
RuntimeEnabled=WebBluetooth,
] partial interface Navigator {
- readonly attribute Bluetooth bluetooth;
+ // Experimental Framework doesn't support adding bindings to partial
+ // interfaces yet, so we add it to the bluetooth attribute instead.
+ // https://crbug.com/585656
+ [APIExperimentEnabled=WebBluetooth] readonly attribute Bluetooth bluetooth;
};
diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
index a483746..d229ea7 100644
--- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
+++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in
@@ -199,7 +199,7 @@ UserSelectAll status=experimental
WebAnimationsAPI status=experimental
WebAnimationsSVG status=experimental
WebAudio status=stable
-WebBluetooth
+WebBluetooth origin_trial_feature_name=WebBluetooth
WebGLDraftExtensions status=experimental
WebGLImageChromium
WebUSB status=experimental
diff --git a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
index bb48a3c..eb62136 100644
--- a/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
+++ b/third_party/WebKit/Source/web/WebLocalFrameImpl.cpp
@@ -1565,8 +1565,15 @@ void WebLocalFrameImpl::setCoreFrame(PassRefPtrWillBeRawPtr<LocalFrame> frame)
provideLocalFileSystemTo(*m_frame, LocalFileSystemClient::create());
provideNavigatorContentUtilsTo(*m_frame, NavigatorContentUtilsClientImpl::create(this));
- if (RuntimeEnabledFeatures::webBluetoothEnabled())
+ bool enableWebBluetooth = RuntimeEnabledFeatures::webBluetoothEnabled();
+#if OS(CHROMEOS) || OS(ANDROID)
+ enableWebBluetooth = true;
+#endif
+
+ if (enableWebBluetooth) {
BluetoothSupplement::provideTo(*m_frame, m_client ? m_client->bluetooth() : nullptr);
+ }
+
if (RuntimeEnabledFeatures::screenOrientationEnabled())
ScreenOrientationController::provideTo(*m_frame, m_client ? m_client->webScreenOrientationClient() : nullptr);
if (RuntimeEnabledFeatures::presentationEnabled())