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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // ID Not In Map Note: 5 // ID Not In Map Note:
6 // A service, characteristic, or descriptor ID not in the corresponding 6 // A service, characteristic, or descriptor ID not in the corresponding
7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_, 7 // BluetoothDispatcherHost map [service_to_device_, characteristic_to_service_,
8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer 8 // descriptor_to_characteristic_] implies a hostile renderer because a renderer
9 // obtains the corresponding ID from this class and it will be added to the map 9 // obtains the corresponding ID from this class and it will be added to the map
10 // at that time. 10 // at that time.
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 thread_id, request_id, 1130 thread_id, request_id,
1131 WebBluetoothError::REQUEST_DEVICE_WITHOUT_FRAME)); 1131 WebBluetoothError::REQUEST_DEVICE_WITHOUT_FRAME));
1132 return; 1132 return;
1133 } 1133 }
1134 1134
1135 const url::Origin requesting_origin = 1135 const url::Origin requesting_origin =
1136 render_frame_host->GetLastCommittedOrigin(); 1136 render_frame_host->GetLastCommittedOrigin();
1137 const url::Origin embedding_origin = 1137 const url::Origin embedding_origin =
1138 web_contents->GetMainFrame()->GetLastCommittedOrigin(); 1138 web_contents->GetMainFrame()->GetLastCommittedOrigin();
1139 1139
1140 if (requesting_origin.unique()) { 1140 // TODO(crbug.com/518042): Enforce correctly-delegated permissions instead of
1141 VLOG(1) << "Request device with unique origin."; 1141 // matching origins. When relaxing this, take care to handle non-sandboxed
Jeffrey Yasskin 2016/04/06 05:38:31 I'm dropping the VLOG because we send the same inf
1142 // unique origins.
1143 if (embedding_origin != requesting_origin) {
Mike West 2016/04/06 06:06:59 I'd prefer `!embedding_origin.IsSameOriginWith(req
Jeffrey Yasskin 2016/04/06 06:17:15 Done, thanks for the clear opinion and rationale.
1142 Send(new BluetoothMsg_RequestDeviceError( 1144 Send(new BluetoothMsg_RequestDeviceError(
1143 thread_id, request_id, 1145 thread_id, request_id,
1144 WebBluetoothError::REQUEST_DEVICE_WITH_UNIQUE_ORIGIN)); 1146 WebBluetoothError::REQUEST_DEVICE_FROM_CROSS_ORIGIN_IFRAME));
1145 return; 1147 return;
1146 } 1148 }
1149 // The above also excludes unique origins, which are not even same-origin with
1150 // themselves.
1151 DCHECK(!requesting_origin.unique());
1147 1152
1148 DCHECK(adapter_.get()); 1153 DCHECK(adapter_.get());
1149 1154
1150 if (!adapter_->IsPresent()) { 1155 if (!adapter_->IsPresent()) {
1151 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice."; 1156 VLOG(1) << "Bluetooth Adapter not present. Can't serve requestDevice.";
1152 RecordRequestDeviceOutcome( 1157 RecordRequestDeviceOutcome(
1153 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT); 1158 UMARequestDeviceOutcome::BLUETOOTH_ADAPTER_NOT_PRESENT);
1154 Send(new BluetoothMsg_RequestDeviceError( 1159 Send(new BluetoothMsg_RequestDeviceError(
1155 thread_id, request_id, WebBluetoothError::NO_BLUETOOTH_ADAPTER)); 1160 thread_id, request_id, WebBluetoothError::NO_BLUETOOTH_ADAPTER));
1156 return; 1161 return;
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 1621
1617 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1622 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1618 int frame_routing_id, 1623 int frame_routing_id,
1619 const std::string& characteristic_instance_id) { 1624 const std::string& characteristic_instance_id) {
1620 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1625 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1621 characteristic_instance_id) 1626 characteristic_instance_id)
1622 .outcome != CacheQueryOutcome::BAD_RENDERER; 1627 .outcome != CacheQueryOutcome::BAD_RENDERER;
1623 } 1628 }
1624 1629
1625 } // namespace content 1630 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698