Index: extensions/browser/ui/extension_bluetooth_chooser.h |
diff --git a/extensions/browser/ui/extension_bluetooth_chooser.h b/extensions/browser/ui/extension_bluetooth_chooser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..50cb52719b67298297b79fba69da35493a5420b9 |
--- /dev/null |
+++ b/extensions/browser/ui/extension_bluetooth_chooser.h |
@@ -0,0 +1,66 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |
+#define EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |
+ |
+#include <stddef.h> |
+ |
+#include <memory> |
+#include <string> |
+#include <utility> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/strings/string16.h" |
+#include "components/ui/chooser_controller/chooser_controller.h" |
+#include "content/public/browser/bluetooth_chooser.h" |
+ |
+namespace content { |
+class RenderFrameHost; |
+} |
+ |
+namespace extensions { |
+ |
+class ExtensionChooserDialog; |
+ |
+// Represents a Bluetooth chooser to ask the user to select a Bluetooth |
+// device from a list of options. This implementation is for extensions. |
+class ExtensionBluetoothChooser : public content::BluetoothChooser, |
+ public ChooserController { |
+ public: |
+ ExtensionBluetoothChooser( |
+ content::RenderFrameHost* frame, |
+ const content::BluetoothChooser::EventHandler& event_handler); |
+ ~ExtensionBluetoothChooser() override; |
+ |
+ // BluetoothChooser: |
+ void SetAdapterPresence(AdapterPresence presence) override; |
+ void ShowDiscoveryState(DiscoveryState state) override; |
+ void AddDevice(const std::string& device_id, |
+ const base::string16& device_name) override; |
+ void RemoveDevice(const std::string& device_id) override; |
+ |
+ // ChooserController: |
+ size_t NumOptions() const override; |
+ const base::string16& GetOption(size_t index) const override; |
+ void Select(size_t index) override; |
+ void Cancel() override; |
+ void Close() override; |
+ GURL GetHelpCenterUrl() const override; |
+ void OpenHelpCenterUrl() const override; |
+ |
+ private: |
+ Observer* observer_ = nullptr; |
+ content::BluetoothChooser::EventHandler event_handler_; |
+ // Each pair is a (device name, device id). |
+ std::vector<std::pair<base::string16, std::string>> device_names_and_ids_; |
+ std::unique_ptr<ExtensionChooserDialog> dialog_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothChooser); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // EXTENSIONS_BROWSER_UI_EXTENSION_BLUETOOTH_CHOOSER_H_ |