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

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

Issue 2110813002: bluetooth: Move First Device Chooser to tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" 5 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <unordered_set> 9 #include <unordered_set>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/browser/bluetooth/bluetooth_blacklist.h" 15 #include "content/browser/bluetooth/bluetooth_blacklist.h"
16 #include "content/browser/bluetooth/bluetooth_metrics.h" 16 #include "content/browser/bluetooth/bluetooth_metrics.h"
17 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
18 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" 17 #include "content/browser/bluetooth/web_bluetooth_service_impl.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/content_browser_client.h" 19 #include "content/public/browser/content_browser_client.h"
21 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
22 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
24 #include "device/bluetooth/bluetooth_adapter.h" 23 #include "device/bluetooth/bluetooth_adapter.h"
25 #include "device/bluetooth/bluetooth_common.h" 24 #include "device/bluetooth/bluetooth_common.h"
26 #include "device/bluetooth/bluetooth_discovery_session.h" 25 #include "device/bluetooth/bluetooth_discovery_session.h"
27 26
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 BluetoothChooser::EventHandler chooser_event_handler = 295 BluetoothChooser::EventHandler chooser_event_handler =
297 base::Bind(&BluetoothDeviceChooserController::OnBluetoothChooserEvent, 296 base::Bind(&BluetoothDeviceChooserController::OnBluetoothChooserEvent,
298 base::Unretained(this)); 297 base::Unretained(this));
299 298
300 if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) { 299 if (WebContentsDelegate* delegate = web_contents_->GetDelegate()) {
301 chooser_ = delegate->RunBluetoothChooser(render_frame_host_, 300 chooser_ = delegate->RunBluetoothChooser(render_frame_host_,
302 chooser_event_handler); 301 chooser_event_handler);
303 } 302 }
304 303
305 if (!chooser_.get()) { 304 if (!chooser_.get()) {
306 LOG(WARNING) 305 PostErrorCallback(
307 << "No Bluetooth chooser implementation; falling back to first device."; 306 blink::mojom::WebBluetoothError::WEB_BLUETOOTH_NOT_SUPPORTED);
308 chooser_.reset(new FirstDeviceBluetoothChooser(chooser_event_handler));
309 } 307 }
310 308
311 if (!chooser_->CanAskForScanningPermission()) { 309 if (!chooser_->CanAskForScanningPermission()) {
312 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; 310 VLOG(1) << "Closing immediately because Chooser cannot obtain permission.";
313 OnBluetoothChooserEvent(BluetoothChooser::Event::DENIED_PERMISSION, 311 OnBluetoothChooserEvent(BluetoothChooser::Event::DENIED_PERMISSION,
314 "" /* device_address */); 312 "" /* device_address */);
315 return; 313 return;
316 } 314 }
317 315
318 PopulateFoundDevices(); 316 PopulateFoundDevices();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 469
472 void BluetoothDeviceChooserController::PostErrorCallback( 470 void BluetoothDeviceChooserController::PostErrorCallback(
473 blink::mojom::WebBluetoothError error) { 471 blink::mojom::WebBluetoothError error) {
474 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( 472 if (!base::ThreadTaskRunnerHandle::Get()->PostTask(
475 FROM_HERE, base::Bind(error_callback_, error))) { 473 FROM_HERE, base::Bind(error_callback_, error))) {
476 LOG(WARNING) << "No TaskRunner."; 474 LOG(WARNING) << "No TaskRunner.";
477 } 475 }
478 } 476 }
479 477
480 } // namespace content 478 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698