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.
5 #include "content/browser/bluetooth/first_device_bluetooth_chooser.h"
7 #include "base/logging.h"
11 FirstDeviceBluetoothChooser::FirstDeviceBluetoothChooser(
12 const EventHandler
& event_handler
)
13 : event_handler_(event_handler
) {}
15 FirstDeviceBluetoothChooser::~FirstDeviceBluetoothChooser() {}
17 void FirstDeviceBluetoothChooser::SetAdapterPresence(AdapterPresence 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
, "");
25 case AdapterPresence::POWERED_ON
:
30 void FirstDeviceBluetoothChooser::ShowDiscoveryState(DiscoveryState 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
, "");
39 case DiscoveryState::DISCOVERING
:
44 void FirstDeviceBluetoothChooser::AddDevice(const std::string
& deviceId
,
45 const base::string16
& deviceName
) {
46 event_handler_
.Run(Event::SELECTED
, deviceId
);
49 } // namespace content