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

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: Sync and rename an enum value. 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
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 return; 1223 return;
1224 } 1224 }
1225 1225
1226 // The renderer should never send empty filters. 1226 // The renderer should never send empty filters.
1227 if (HasEmptyOrInvalidFilter(filters)) { 1227 if (HasEmptyOrInvalidFilter(filters)) {
1228 bad_message::ReceivedBadMessage(this, 1228 bad_message::ReceivedBadMessage(this,
1229 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); 1229 bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
1230 return; 1230 return;
1231 } 1231 }
1232 1232
1233 if (!GetContentClient()->browser()->AllowWebBluetooth( 1233 switch (GetContentClient()->browser()->AllowWebBluetooth(
1234 web_contents->GetBrowserContext(), requesting_origin, 1234 web_contents->GetBrowserContext(), requesting_origin, embedding_origin)) {
1235 embedding_origin)) { 1235 case ContentBrowserClient::AllowWebBluetoothResult::BLOCK_POLICY: {
1236 RecordRequestDeviceOutcome( 1236 RecordRequestDeviceOutcome(
1237 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED); 1237 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_POLICY_DISABLED);
1238 Send(new BluetoothMsg_RequestDeviceError( 1238 Send(new BluetoothMsg_RequestDeviceError(
1239 thread_id, request_id, WebBluetoothError::CHOOSER_DISABLED)); 1239 thread_id, request_id,
1240 return; 1240 WebBluetoothError::CHOOSER_NOT_SHOWN_API_LOCALLY_DISABLED));
1241 return;
1242 }
1243 case ContentBrowserClient::AllowWebBluetoothResult::
1244 BLOCK_GLOBALLY_DISABLED: {
1245 // Log to the developer console.
1246 web_contents->GetMainFrame()->AddMessageToConsole(
1247 content::CONSOLE_MESSAGE_LEVEL_LOG,
1248 "Bluetooth permission has been blocked.");
1249 // Block requests.
1250 RecordRequestDeviceOutcome(
1251 UMARequestDeviceOutcome::BLUETOOTH_GLOBALLY_DISABLED);
1252 Send(new BluetoothMsg_RequestDeviceError(
1253 thread_id, request_id,
1254 WebBluetoothError::CHOOSER_NOT_SHOWN_API_GLOBALLY_DISABLED));
1255 return;
1256 }
1257 case ContentBrowserClient::AllowWebBluetoothResult::ALLOW:
1258 break;
1241 } 1259 }
1242 1260
1243 // Create storage for the information that backs the chooser, and show the 1261 // Create storage for the information that backs the chooser, and show the
1244 // chooser. 1262 // chooser.
1245 RequestDeviceSession* const session = new RequestDeviceSession( 1263 RequestDeviceSession* const session = new RequestDeviceSession(
1246 thread_id, request_id, frame_routing_id, requesting_origin, filters, 1264 thread_id, request_id, frame_routing_id, requesting_origin, filters,
1247 optional_services_blacklist_filtered); 1265 optional_services_blacklist_filtered);
1248 int chooser_id = request_device_sessions_.Add(session); 1266 int chooser_id = request_device_sessions_.Add(session);
1249 1267
1250 BluetoothChooser::EventHandler chooser_event_handler = 1268 BluetoothChooser::EventHandler chooser_event_handler =
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1383 WebBluetoothError::CHOOSER_CANCELLED)); 1401 WebBluetoothError::CHOOSER_CANCELLED));
1384 request_device_sessions_.Remove(chooser_id); 1402 request_device_sessions_.Remove(chooser_id);
1385 return; 1403 return;
1386 } 1404 }
1387 if (event == BluetoothChooser::Event::DENIED_PERMISSION) { 1405 if (event == BluetoothChooser::Event::DENIED_PERMISSION) {
1388 RecordRequestDeviceOutcome( 1406 RecordRequestDeviceOutcome(
1389 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION); 1407 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION);
1390 VLOG(1) << "Bluetooth chooser denied permission"; 1408 VLOG(1) << "Bluetooth chooser denied permission";
1391 Send(new BluetoothMsg_RequestDeviceError( 1409 Send(new BluetoothMsg_RequestDeviceError(
1392 session->thread_id, session->request_id, 1410 session->thread_id, session->request_id,
1393 WebBluetoothError::CHOOSER_DENIED_PERMISSION)); 1411 WebBluetoothError::CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN));
1394 request_device_sessions_.Remove(chooser_id); 1412 request_device_sessions_.Remove(chooser_id);
1395 return; 1413 return;
1396 } 1414 }
1397 DCHECK_EQ(static_cast<int>(event), 1415 DCHECK_EQ(static_cast<int>(event),
1398 static_cast<int>(BluetoothChooser::Event::SELECTED)); 1416 static_cast<int>(BluetoothChooser::Event::SELECTED));
1399 1417
1400 // |device_id| is the Device Address that RequestDeviceSession passed to 1418 // |device_id| is the Device Address that RequestDeviceSession passed to
1401 // chooser->AddDevice(). 1419 // chooser->AddDevice().
1402 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id); 1420 const device::BluetoothDevice* const device = adapter_->GetDevice(device_id);
1403 if (device == nullptr) { 1421 if (device == nullptr) {
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 1701
1684 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1702 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1685 int frame_routing_id, 1703 int frame_routing_id,
1686 const std::string& characteristic_instance_id) { 1704 const std::string& characteristic_instance_id) {
1687 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1705 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1688 characteristic_instance_id) 1706 characteristic_instance_id)
1689 .outcome != CacheQueryOutcome::BAD_RENDERER; 1707 .outcome != CacheQueryOutcome::BAD_RENDERER;
1690 } 1708 }
1691 1709
1692 } // namespace content 1710 } // namespace content
OLDNEW
« no previous file with comments | « chrome/chrome_tests.gypi ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698