OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |
| 6 #define EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 |
| 10 #include <memory> |
| 11 #include <string> |
| 12 #include <utility> |
| 13 #include <vector> |
| 14 |
| 15 #include "base/macros.h" |
| 16 #include "base/strings/string16.h" |
| 17 #include "components/ui/chooser_controller/chooser_controller.h" |
| 18 #include "content/public/browser/bluetooth_chooser.h" |
| 19 |
| 20 namespace content { |
| 21 class RenderFrameHost; |
| 22 } |
| 23 |
| 24 namespace extensions { |
| 25 |
| 26 class ExtensionChooserDialog; |
| 27 |
| 28 // Represents a Bluetooth chooser to ask the user to select a Bluetooth |
| 29 // device from a list of options. This implementation is for extensions. |
| 30 class ExtensionBluetoothChooser : public content::BluetoothChooser, |
| 31 public ChooserController { |
| 32 public: |
| 33 ExtensionBluetoothChooser( |
| 34 content::RenderFrameHost* frame, |
| 35 const content::BluetoothChooser::EventHandler& event_handler); |
| 36 ~ExtensionBluetoothChooser() override; |
| 37 |
| 38 // BluetoothChooser: |
| 39 void SetAdapterPresence(AdapterPresence presence) override; |
| 40 void ShowDiscoveryState(DiscoveryState state) override; |
| 41 void AddDevice(const std::string& device_id, |
| 42 const base::string16& device_name) override; |
| 43 void RemoveDevice(const std::string& device_id) override; |
| 44 |
| 45 // ChooserController: |
| 46 size_t NumOptions() const override; |
| 47 const base::string16& GetOption(size_t index) const override; |
| 48 void Select(size_t index) override; |
| 49 void Cancel() override; |
| 50 void Close() override; |
| 51 GURL GetHelpCenterUrl() const override; |
| 52 void OpenHelpCenterUrl() const override; |
| 53 |
| 54 private: |
| 55 Observer* observer_ = nullptr; |
| 56 content::BluetoothChooser::EventHandler event_handler_; |
| 57 // Each pair is a (device name, device id). |
| 58 std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; |
| 59 std::unique_ptr<ExtensionChooserDialog> dialog_; |
| 60 |
| 61 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothChooser); |
| 62 }; |
| 63 |
| 64 } // namespace extensions |
| 65 |
| 66 #endif // EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |
OLD | NEW |