Skip to content

Commit

Permalink
Wire up Web Bluetooth API in WebLayer.
Browse files Browse the repository at this point in the history
Bug: 1076462
Change-Id: I081f1bcb12a72a69075d2f125970fca418c9cf90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3048437
Reviewed-by: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Colin Blundell <blundell@chromium.org>
Commit-Queue: Michael van Ouwerkerk <mvanouwerkerk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#924698}
  • Loading branch information
mvano authored and Chromium LUCI CQ committed Sep 24, 2021
1 parent f406c71 commit 5b755a1
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions weblayer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ if (is_android) {
output_locales = locales
source_patterns = [
"${root_gen_dir}/components/strings/components_locale_settings_",
"${root_gen_dir}/device/bluetooth/strings/bluetooth_strings_",
"${root_gen_dir}/weblayer/components_chromium_strings_",
"${root_gen_dir}/weblayer/components_strings_",
]
deps = [
":generate_components_chromium_strings",
":generate_components_strings",
"//components/strings:components_locale_settings",
"//device/bluetooth/strings",
]
output_dir = "$root_out_dir/weblayer/locales"
}
Expand Down
10 changes: 10 additions & 0 deletions weblayer/browser/content_browser_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
#include "components/embedder_support/android/metrics/android_metrics_service_client.h"
#include "components/media_router/browser/presentation/presentation_service_delegate_impl.h" // nogncheck
#include "components/navigation_interception/intercept_navigation_delegate.h"
#include "components/permissions/bluetooth_delegate_impl.h"
#include "components/safe_browsing/core/browser/realtime/policy_engine.h" // nogncheck
#include "components/safe_browsing/core/browser/realtime/url_lookup_service.h" // nogncheck
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
Expand All @@ -139,6 +140,7 @@
#include "weblayer/browser/android/metrics/weblayer_metrics_navigation_throttle.h"
#include "weblayer/browser/android/metrics/weblayer_metrics_service_client.h"
#include "weblayer/browser/android_descriptors.h"
#include "weblayer/browser/bluetooth/weblayer_bluetooth_delegate_impl_client.h"
#include "weblayer/browser/browser_context_impl.h"
#include "weblayer/browser/devtools_manager_delegate_android.h"
#include "weblayer/browser/http_auth_handler_impl.h"
Expand Down Expand Up @@ -1175,6 +1177,14 @@ bool ContentBrowserClientImpl::
return true;
}

content::BluetoothDelegate* ContentBrowserClientImpl::GetBluetoothDelegate() {
if (!bluetooth_delegate_) {
bluetooth_delegate_ = std::make_unique<permissions::BluetoothDelegateImpl>(
std::make_unique<WebLayerBluetoothDelegateImplClient>());
}
return bluetooth_delegate_.get();
}

#endif // OS_ANDROID

content::SpeechRecognitionManagerDelegate*
Expand Down
7 changes: 7 additions & 0 deletions weblayer/browser/content_browser_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ namespace net {
class SiteForCookies;
} // namespace net

namespace permissions {
class BluetoothDelegateImpl;
}

namespace weblayer {

class FeatureListCreator;
Expand Down Expand Up @@ -214,6 +218,7 @@ class ContentBrowserClientImpl : public content::ContentBrowserClient {
std::unique_ptr<content::TtsEnvironmentAndroid> CreateTtsEnvironmentAndroid()
override;
bool ShouldObserveContainerViewLocationForDialogOverlays() override;
content::BluetoothDelegate* GetBluetoothDelegate() override;
#endif // OS_ANDROID
content::SpeechRecognitionManagerDelegate*
CreateSpeechRecognitionManagerDelegate() override;
Expand All @@ -232,6 +237,8 @@ class ContentBrowserClientImpl : public content::ContentBrowserClient {

#if defined(OS_ANDROID)
SafeBrowsingService* GetSafeBrowsingService();

std::unique_ptr<permissions::BluetoothDelegateImpl> bluetooth_delegate_;
#endif

MainParams* params_;
Expand Down
13 changes: 13 additions & 0 deletions weblayer/grit_strings_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ IDS_BEFORERELOAD_APP_MESSAGEBOX_TITLE
IDS_BEFORERELOAD_MESSAGEBOX_TITLE
IDS_BEFOREUNLOAD_APP_MESSAGEBOX_TITLE
IDS_BEFOREUNLOAD_MESSAGEBOX_TITLE
IDS_BLUETOOTH_DEVICE_AUDIO
IDS_BLUETOOTH_DEVICE_CAR_AUDIO
IDS_BLUETOOTH_DEVICE_COMPUTER
IDS_BLUETOOTH_DEVICE_GAMEPAD
IDS_BLUETOOTH_DEVICE_JOYSTICK
IDS_BLUETOOTH_DEVICE_KEYBOARD
IDS_BLUETOOTH_DEVICE_KEYBOARD_MOUSE_COMBO
IDS_BLUETOOTH_DEVICE_MODEM
IDS_BLUETOOTH_DEVICE_MOUSE
IDS_BLUETOOTH_DEVICE_PHONE
IDS_BLUETOOTH_DEVICE_TABLET
IDS_BLUETOOTH_DEVICE_UNKNOWN
IDS_BLUETOOTH_DEVICE_VIDEO
IDS_CANCEL
IDS_CAPTIVE_PORTAL_BUTTON_OPEN_LOGIN_PAGE
IDS_CAPTIVE_PORTAL_HEADING_WIFI
Expand Down
12 changes: 12 additions & 0 deletions weblayer/public/java/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<uses-permission-sdk-23 android:name="android.permission.BLUETOOTH"/>
<uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30"/>
<uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_CONNECT"/>
<!--
Bluetooth scanning is used to implement the Web Bluetooth API, which is
not intended to allow sites to derive location and so can accept a
filtered view of devices.
-->
<uses-permission-sdk-23 android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"/>

<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.INTERNET"/>
Expand Down

0 comments on commit 5b755a1

Please sign in to comment.