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

Unified Diff: content/browser/bluetooth/bluetooth_dispatcher_host.cc

Issue 1228113004: Put the RenderFrame's ID into a per-frame WebBluetooth, and plumb that back to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@store-request-device-state-in-dispatcher
Patch Set: Rebase Created 5 years, 5 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
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 5f751c1d9a98d02a8b9921affc04fbb395db5fa2..386ede0af36116bdbe0781c4380d9a49a981bc5e 100644
--- a/content/browser/bluetooth/bluetooth_dispatcher_host.cc
+++ b/content/browser/bluetooth/bluetooth_dispatcher_host.cc
@@ -13,6 +13,7 @@
#include "base/metrics/histogram.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/bad_message.h"
+#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/common/bluetooth/bluetooth_messages.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -135,8 +136,9 @@ blink::WebBluetoothError TranslateGATTError(
namespace content {
-BluetoothDispatcherHost::BluetoothDispatcherHost()
+BluetoothDispatcherHost::BluetoothDispatcherHost(int render_process_id)
: BrowserMessageFilter(BluetoothMsgStart),
+ render_process_id_(render_process_id),
weak_ptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
current_delay_time_ = kDelayTime;
@@ -225,9 +227,22 @@ static scoped_ptr<device::BluetoothDiscoveryFilter> ComputeScanFilter(
void BluetoothDispatcherHost::OnRequestDevice(
int thread_id,
int request_id,
+ int frame_routing_id,
const std::vector<BluetoothScanFilter>& filters,
const std::vector<BluetoothUUID>& optional_services) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
+
+ RenderFrameHostImpl* render_frame_host =
+ RenderFrameHostImpl::FromID(render_process_id_, frame_routing_id);
+
+ if (!render_frame_host) {
+ DLOG(WARNING)
+ << "Got a requestDevice IPC without a matching RenderFrameHost: "
+ << render_process_id_ << ", " << frame_routing_id;
+ Send(new BluetoothMsg_RequestDeviceError(
+ thread_id, request_id, WebBluetoothError::RequestDeviceWithoutFrame));
+ }
+
// TODO(scheib): Device selection UI: crbug.com/436280
// TODO(scheib): Utilize BluetoothAdapter::Observer::DeviceAdded/Removed.
if (adapter_.get()) {
« no previous file with comments | « content/browser/bluetooth/bluetooth_dispatcher_host.h ('k') | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698