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

Side by Side Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1841763002: Add a kill switch for all of Web Bluetooth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Avoid exposing the "kill switch" concept to content/ 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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 return; 1212 return;
1213 } 1213 }
1214 1214
1215 // The renderer should never send empty filters. 1215 // The renderer should never send empty filters.
1216 if (HasEmptyOrInvalidFilter(filters)) { 1216 if (HasEmptyOrInvalidFilter(filters)) {
1217 bad_message::ReceivedBadMessage(this, 1217 bad_message::ReceivedBadMessage(this,
1218 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); 1218 bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
1219 return; 1219 return;
1220 } 1220 }
1221 1221
1222 if (!GetContentClient()->browser()->AllowWebBluetooth( 1222 switch (GetContentClient()->browser()->AllowWebBluetooth(
1223 web_contents->GetBrowserContext(), requesting_origin, 1223 web_contents->GetBrowserContext(), requesting_origin, embedding_origin)) {
1224 embedding_origin)) { 1224 case ContentBrowserClient::AllowWebBluetoothResult::BLOCK_POLICY: {
1225 RecordRequestDeviceOutcome( 1225 RecordRequestDeviceOutcome(
1226 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED); 1226 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_POLICY_DISABLED);
1227 Send(new BluetoothMsg_RequestDeviceError( 1227 Send(new BluetoothMsg_RequestDeviceError(
1228 thread_id, request_id, WebBluetoothError::ChooserDisabled)); 1228 thread_id, request_id,
1229 return; 1229 WebBluetoothError::ChooserNotShown_APILocallyDisabled));
1230 return;
1231 }
1232 case ContentBrowserClient::AllowWebBluetoothResult::
1233 BLOCK_GLOBALLY_DISABLED: {
1234 // Log to the developer console.
1235 web_contents->GetMainFrame()->AddMessageToConsole(
1236 content::CONSOLE_MESSAGE_LEVEL_LOG,
1237 "Bluetooth permission has been blocked.");
1238 // Block requests.
1239 RecordRequestDeviceOutcome(
1240 UMARequestDeviceOutcome::BLUETOOTH_GLOBALLY_DISABLED);
1241 Send(new BluetoothMsg_RequestDeviceError(
1242 thread_id, request_id,
1243 WebBluetoothError::ChooserNotShown_APIGloballyDisabled));
1244 return;
1245 }
1246 case ContentBrowserClient::AllowWebBluetoothResult::ALLOW:
1247 break;
1230 } 1248 }
1231 1249
1232 // Create storage for the information that backs the chooser, and show the 1250 // Create storage for the information that backs the chooser, and show the
1233 // chooser. 1251 // chooser.
1234 RequestDeviceSession* const session = new RequestDeviceSession( 1252 RequestDeviceSession* const session = new RequestDeviceSession(
1235 thread_id, request_id, frame_routing_id, requesting_origin, filters, 1253 thread_id, request_id, frame_routing_id, requesting_origin, filters,
1236 optional_services_blacklist_filtered); 1254 optional_services_blacklist_filtered);
1237 int chooser_id = request_device_sessions_.Add(session); 1255 int chooser_id = request_device_sessions_.Add(session);
1238 1256
1239 BluetoothChooser::EventHandler chooser_event_handler = 1257 BluetoothChooser::EventHandler chooser_event_handler =
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 WebBluetoothError::ChooserCancelled)); 1390 WebBluetoothError::ChooserCancelled));
1373 request_device_sessions_.Remove(chooser_id); 1391 request_device_sessions_.Remove(chooser_id);
1374 return; 1392 return;
1375 } 1393 }
1376 if (event == BluetoothChooser::Event::DENIED_PERMISSION) { 1394 if (event == BluetoothChooser::Event::DENIED_PERMISSION) {
1377 RecordRequestDeviceOutcome( 1395 RecordRequestDeviceOutcome(
1378 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION); 1396 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION);
1379 VLOG(1) << "Bluetooth chooser denied permission"; 1397 VLOG(1) << "Bluetooth chooser denied permission";
1380 Send(new BluetoothMsg_RequestDeviceError( 1398 Send(new BluetoothMsg_RequestDeviceError(
1381 session->thread_id, session->request_id, 1399 session->thread_id, session->request_id,
1382 WebBluetoothError::ChooserDeniedPermission)); 1400 WebBluetoothError::ChooserNotShown_BrowserDeniedPermissionToScan));
ortuno 2016/03/30 19:19:46 I think you might have meant to change the error i
Jeffrey Yasskin 2016/03/30 19:31:24 Line 1274 is just the chooser event saying that it
ortuno 2016/03/30 19:41:51 Ah you're totally right.
1383 request_device_sessions_.Remove(chooser_id); 1401 request_device_sessions_.Remove(chooser_id);
1384 return; 1402 return;
1385 } 1403 }
1386 DCHECK_EQ(static_cast<int>(event), 1404 DCHECK_EQ(static_cast<int>(event),
1387 static_cast<int>(BluetoothChooser::Event::SELECTED)); 1405 static_cast<int>(BluetoothChooser::Event::SELECTED));
1388 1406
1389 // |device_id| is the Device Address that RequestDeviceSession passed to 1407 // |device_id| is the Device Address that RequestDeviceSession passed to
1390 // chooser->AddDevice(). 1408 // chooser->AddDevice().
1391 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id); 1409 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id);
1392 if (device == nullptr) { 1410 if (device == nullptr) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 1682
1665 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1683 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1666 int frame_routing_id, 1684 int frame_routing_id,
1667 const std::string& characteristic_instance_id) { 1685 const std::string& characteristic_instance_id) {
1668 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1686 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1669 characteristic_instance_id) 1687 characteristic_instance_id)
1670 .outcome != CacheQueryOutcome::BAD_RENDERER; 1688 .outcome != CacheQueryOutcome::BAD_RENDERER;
1671 } 1689 }
1672 1690
1673 } // namespace content 1691 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698