OLD | NEW |
(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 namespace content { |
| 8 |
| 9 FirstDeviceBluetoothChooser::FirstDeviceBluetoothChooser( |
| 10 const EventHandler& event_handler) |
| 11 : event_handler_(event_handler) {} |
| 12 |
| 13 FirstDeviceBluetoothChooser::~FirstDeviceBluetoothChooser() {} |
| 14 |
| 15 void FirstDeviceBluetoothChooser::SetAdapterPresence(AdapterPresence presence) { |
| 16 switch (presence) { |
| 17 case AdapterPresence::ABSENT: |
| 18 case AdapterPresence::POWERED_OFF: |
| 19 // Without a user-visible dialog, if the adapter is off, there's no way to |
| 20 // ask the user to turn it on again, so we should cancel. |
| 21 event_handler_.Run(Event::CANCELLED, ""); |
| 22 break; |
| 23 case AdapterPresence::POWERED_ON: |
| 24 break; |
| 25 } |
| 26 } |
| 27 |
| 28 void FirstDeviceBluetoothChooser::ShowDiscoveryState(DiscoveryState state) { |
| 29 switch (state) { |
| 30 case DiscoveryState::FAILED_TO_START: |
| 31 case DiscoveryState::IDLE: |
| 32 // Without a user-visible dialog, if discovery finishes without finding a |
| 33 // device, we'll never find one, so we should cancel. |
| 34 event_handler_.Run(Event::CANCELLED, ""); |
| 35 break; |
| 36 case DiscoveryState::DISCOVERING: |
| 37 break; |
| 38 } |
| 39 } |
| 40 |
| 41 void FirstDeviceBluetoothChooser::AddDevice(const std::string& deviceId, |
| 42 const base::string16& deviceName) { |
| 43 event_handler_.Run(Event::SELECTED, deviceId); |
| 44 } |
| 45 |
| 46 } // namespace content |
OLD | NEW |