[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / bluetooth / first_device_bluetooth_chooser.cc
blob866d623d5d81b6640bd63bbb706c4f886b57d669
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"
9 namespace content {
11 FirstDeviceBluetoothChooser::FirstDeviceBluetoothChooser(
12 const EventHandler& event_handler)
13 : event_handler_(event_handler) {}
15 FirstDeviceBluetoothChooser::~FirstDeviceBluetoothChooser() {}
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;
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;
44 void FirstDeviceBluetoothChooser::AddDevice(const std::string& deviceId,
45 const base::string16& deviceName) {
46 event_handler_.Run(Event::SELECTED, deviceId);
49 } // namespace content