Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Unified Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1862953002: Disallow use of Web Bluetooth from cross-origin iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Add a test. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/requestDevice-sandboxed-iframe.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_dispatcher_host.cc
diff --git a/content/browser/bluetooth/bluetooth_dispatcher_host.cc b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
index c7a2dd3c5d1d75e97a7c619156e51d6fee24e341..23718c9339296dd858a2b3304680ccb6f3053c06 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -1137,13 +1137,18 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl(
const url::Origin embedding_origin =
web_contents->GetMainFrame()->GetLastCommittedOrigin();
- if (requesting_origin.unique()) {
- VLOG(1) << "Request device with unique origin.";
+ // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of
+ // matching origins. When relaxing this, take care to handle non-sandboxed
+ // unique origins.
+ if (!embedding_origin.IsSameOriginWith(requesting_origin)) {
Send(new BluetoothMsg_RequestDeviceError(
thread_id, request_id,
- WebBluetoothError::REQUEST_DEVICE_WITH_UNIQUE_ORIGIN));
+ WebBluetoothError::REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME));
return;
}
+ // The above also excludes unique origins, which are not even same-origin with
+ // themselves.
+ DCHECK(!requesting_origin.unique());
DCHECK(adapter_.get());
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/bluetooth/requestDevice-sandboxed-iframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698