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

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

Issue 1706503002: Add enterprise policy to turn off Bluetooth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Release the BrowserMessageFilter::Internal once it has attached the Sender. Created 4 years, 10 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.
11 11
12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h" 12 #include "content/browser/bluetooth/bluetooth_dispatcher_host.h"
13 13
14 #include <stddef.h> 14 #include <stddef.h>
15 15
16 #include <utility> 16 #include <utility>
17 17
18 #include "base/bind.h" 18 #include "base/bind.h"
19 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
20 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
21 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
22 #include "content/browser/bad_message.h" 22 #include "content/browser/bad_message.h"
23 #include "content/browser/bluetooth/bluetooth_blacklist.h" 23 #include "content/browser/bluetooth/bluetooth_blacklist.h"
24 #include "content/browser/bluetooth/bluetooth_metrics.h" 24 #include "content/browser/bluetooth/bluetooth_metrics.h"
25 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h" 25 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
26 #include "content/browser/frame_host/render_frame_host_impl.h" 26 #include "content/browser/frame_host/render_frame_host_impl.h"
27 #include "content/common/bluetooth/bluetooth_messages.h" 27 #include "content/common/bluetooth/bluetooth_messages.h"
28 #include "content/public/browser/content_browser_client.h"
28 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
29 #include "content/public/browser/web_contents_delegate.h" 30 #include "content/public/browser/web_contents_delegate.h"
30 #include "device/bluetooth/bluetooth_adapter.h" 31 #include "device/bluetooth/bluetooth_adapter.h"
31 #include "device/bluetooth/bluetooth_adapter_factory.h" 32 #include "device/bluetooth/bluetooth_adapter_factory.h"
32 #include "device/bluetooth/bluetooth_device.h" 33 #include "device/bluetooth/bluetooth_device.h"
33 #include "device/bluetooth/bluetooth_discovery_session.h" 34 #include "device/bluetooth/bluetooth_discovery_session.h"
34 #include "device/bluetooth/bluetooth_gatt_characteristic.h" 35 #include "device/bluetooth/bluetooth_gatt_characteristic.h"
35 #include "device/bluetooth/bluetooth_gatt_service.h" 36 #include "device/bluetooth/bluetooth_gatt_service.h"
36 37
37 using blink::WebBluetoothError; 38 using blink::WebBluetoothError;
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 return; 1086 return;
1086 } 1087 }
1087 1088
1088 // The renderer should never send empty filters. 1089 // The renderer should never send empty filters.
1089 if (HasEmptyOrInvalidFilter(filters)) { 1090 if (HasEmptyOrInvalidFilter(filters)) {
1090 bad_message::ReceivedBadMessage(this, 1091 bad_message::ReceivedBadMessage(this,
1091 bad_message::BDH_EMPTY_OR_INVALID_FILTERS); 1092 bad_message::BDH_EMPTY_OR_INVALID_FILTERS);
1092 return; 1093 return;
1093 } 1094 }
1094 1095
1096 if (!GetContentClient()->browser()->AllowWebBluetooth()) {
1097 RecordRequestDeviceOutcome(
1098 UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED);
1099 Send(new BluetoothMsg_RequestDeviceError(
1100 thread_id, request_id, WebBluetoothError::ChooserDisabled));
1101 return;
1102 }
1103
1095 // Create storage for the information that backs the chooser, and show the 1104 // Create storage for the information that backs the chooser, and show the
1096 // chooser. 1105 // chooser.
1097 RequestDeviceSession* const session = 1106 RequestDeviceSession* const session =
1098 new RequestDeviceSession(thread_id, request_id, frame_routing_id, 1107 new RequestDeviceSession(thread_id, request_id, frame_routing_id,
1099 render_frame_host->GetLastCommittedOrigin(), 1108 render_frame_host->GetLastCommittedOrigin(),
1100 filters, optional_services_blacklist_filtered); 1109 filters, optional_services_blacklist_filtered);
1101 int chooser_id = request_device_sessions_.Add(session); 1110 int chooser_id = request_device_sessions_.Add(session);
1102 1111
1103 BluetoothChooser::EventHandler chooser_event_handler = 1112 BluetoothChooser::EventHandler chooser_event_handler =
1104 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent, 1113 base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent,
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 1531
1523 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance( 1532 bool BluetoothDispatcherHost::CanFrameAccessCharacteristicInstance(
1524 int frame_routing_id, 1533 int frame_routing_id,
1525 const std::string& characteristic_instance_id) { 1534 const std::string& characteristic_instance_id) {
1526 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id), 1535 return QueryCacheForCharacteristic(GetOrigin(frame_routing_id),
1527 characteristic_instance_id) 1536 characteristic_instance_id)
1528 .outcome != CacheQueryOutcome::BAD_RENDERER; 1537 .outcome != CacheQueryOutcome::BAD_RENDERER;
1529 } 1538 }
1530 1539
1531 } // namespace content 1540 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698