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

Unified 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: Fix nits 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/resources/policy_templates.json ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('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 22ad2c63fd955f1db5bb3032a2cc1020f01c2ff4..cc5ac7a924c83293297c5a39017fba5747c1b431 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -25,6 +25,7 @@
#include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/common/bluetooth/bluetooth_messages.h"
+#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "device/bluetooth/bluetooth_adapter.h"
@@ -1065,18 +1066,25 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl(
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
+ WebContents* web_contents =
+ WebContents::FromRenderFrameHost(render_frame_host);
- if (!render_frame_host) {
- DLOG(WARNING)
- << "Got a requestDevice IPC without a matching RenderFrameHost: "
- << render_process_id_ << ", " << frame_routing_id;
+ if (!render_frame_host || !web_contents) {
+ DLOG(WARNING) << "Got a requestDevice IPC without a matching "
+ << "RenderFrameHost or WebContents: " << render_process_id_
+ << ", " << frame_routing_id;
RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_RENDER_FRAME);
Send(new BluetoothMsg_RequestDeviceError(
thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame));
return;
}
- if (render_frame_host->GetLastCommittedOrigin().unique()) {
+ const url::Origin requesting_origin =
+ render_frame_host->GetLastCommittedOrigin();
+ const url::Origin embedding_origin =
+ web_contents->GetMainFrame()->GetLastCommittedOrigin();
+
+ if (requesting_origin.unique()) {
VLOG(1) << "Request device with unique origin.";
Send(new BluetoothMsg_RequestDeviceError(
thread_id, request_id,
@@ -1102,23 +1110,29 @@ void BluetoothDispatcherHost::OnRequestDeviceImpl(
return;
}
+ if (!GetContentClient()->browser()->AllowWebBluetooth(
+ web_contents->GetBrowserContext(), requesting_origin,
+ embedding_origin)) {
+ RecordRequestDeviceOutcome(
+ UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_GLOBALLY_DISABLED);
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id, WebBluetoothError::ChooserDisabled));
+ return;
+ }
+
// Create storage for the information that backs the chooser, and show the
// chooser.
- RequestDeviceSession* const session =
- new RequestDeviceSession(thread_id, request_id, frame_routing_id,
- render_frame_host->GetLastCommittedOrigin(),
- filters, optional_services_blacklist_filtered);
+ RequestDeviceSession* const session = new RequestDeviceSession(
+ thread_id, request_id, frame_routing_id, requesting_origin, filters,
+ optional_services_blacklist_filtered);
int chooser_id = request_device_sessions_.Add(session);
BluetoothChooser::EventHandler chooser_event_handler =
base::Bind(&BluetoothDispatcherHost::OnBluetoothChooserEvent,
weak_ptr_on_ui_thread_, chooser_id);
- if (WebContents* web_contents =
- WebContents::FromRenderFrameHost(render_frame_host)) {
- if (WebContentsDelegate* delegate = web_contents->GetDelegate()) {
- session->chooser = delegate->RunBluetoothChooser(render_frame_host,
- chooser_event_handler);
- }
+ if (WebContentsDelegate* delegate = web_contents->GetDelegate()) {
+ session->chooser =
+ delegate->RunBluetoothChooser(render_frame_host, chooser_event_handler);
}
if (!session->chooser) {
LOG(WARNING)
« no previous file with comments | « components/policy/resources/policy_templates.json ('k') | content/browser/bluetooth/bluetooth_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698