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

Side by Side Diff: content/browser/bluetooth/first_device_bluetooth_chooser.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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
6
7 #include "base/logging.h"
8
9 namespace content {
10
11 FirstDeviceBluetoothChooser::FirstDeviceBluetoothChooser(
12 const EventHandler& event_handler)
13 : event_handler_(event_handler) {}
14
15 FirstDeviceBluetoothChooser::~FirstDeviceBluetoothChooser() {}
16
17 void FirstDeviceBluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
18 switch (presence) {
19 case AdapterPresence::ABSENT:
20 case AdapterPresence::POWERED_OFF:
21 // Without a user-visible dialog, if the adapter is off, there's no way to
22 // ask the user to turn it on again, so we should cancel.
23 event_handler_.Run(Event::CANCELLED, "");
24 break;
25 case AdapterPresence::POWERED_ON:
26 break;
27 }
28 }
29
30 void FirstDeviceBluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
31 switch (state) {
32 case DiscoveryState::FAILED_TO_START:
33 case DiscoveryState::IDLE:
34 // Without a user-visible dialog, if discovery finishes without finding a
35 // device, we'll never find one, so we should cancel.
36 VLOG(1) << "FirstDeviceBluetoothChooser found nothing before going idle.";
37 event_handler_.Run(Event::CANCELLED, "");
38 break;
39 case DiscoveryState::DISCOVERING:
40 break;
41 }
42 }
43
44 void FirstDeviceBluetoothChooser::AddDevice(const std::string& deviceId,
45 const base::string16& deviceName) {
46 event_handler_.Run(Event::SELECTED, deviceId);
47 }
48
49 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698