Chromium Code Reviews| Index: content/public/browser/bluetooth_chooser.h |
| diff --git a/content/public/browser/bluetooth_chooser.h b/content/public/browser/bluetooth_chooser.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c460fd6b7cad72b92ef115d5316c1adc0374025 |
| --- /dev/null |
| +++ b/content/public/browser/bluetooth_chooser.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2015 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 CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ |
| +#define CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/strings/string16.h" |
| +#include "content/common/content_export.h" |
| + |
| +class GURL; |
| + |
| +namespace content { |
| + |
| +// Represents a way to ask the user to select a Bluetooth device from a list of |
| +// options. |
| +class CONTENT_EXPORT BluetoothChooser { |
| + public: |
| + class Observer { |
| + public: |
| + // The user cancelled the chooser instead of selecting a device. |
| + virtual void DialogCancelled(int chooser_id) = 0; |
| + // The user selected device |device_id|. |
| + virtual void DeviceSelected(int chooser_id, |
| + const std::string& device_id) = 0; |
| + |
| + // As the dialog implementations grow more user-visible buttons and knobs, |
| + // those knobs will cause new functions to be called here. |
| + |
| + protected: |
| + ~Observer() {} |
| + }; |
| + |
| + // |observer| must outlive |this|. |chooser_id| is propagated to the Observer |
| + // methods. |
| + BluetoothChooser(Observer* observer, int chooser_id) |
| + : observer_(observer), chooser_id_(chooser_id) {} |
| + virtual ~BluetoothChooser(); |
| + |
| + // Lets the chooser tell the user the state of the Bluetooth adapter. |
| + enum class AdapterPresence { ABSENT, POWERED_OFF, POWERED_ON }; |
| + virtual void SetAdapterPresence(AdapterPresence presence) = 0; |
| + |
| + // Lets the chooser tell the user whether discovery is happening. |
| + enum class DiscoveryState { FAILED_TO_START, DISCOVERING, IDLE }; |
| + virtual void ShowDiscovering(DiscoveryState state) = 0; |
|
ortuno
2015/08/17 21:12:59
Hmm not sure about the name of this function. What
Jeffrey Yasskin
2015/08/17 23:38:16
I'm not sure of it either, but I don't like your s
ortuno
2015/08/18 00:21:55
I like ShowDiscoveryState :)
|
| + |
| + // Shows a new device in the chooser. |
| + virtual void AddDevice(const std::string& device_id, |
| + const base::string16& device_name) = 0; |
| + // Tells the chooser that a device is no longer available. The chooser should |
| + // not call DeviceSelected() for a device that's been removed. |
| + virtual void RemoveDevice(const std::string& device_id) = 0; |
| + |
| + protected: |
| + // Subclasses call the observer methods through these wrappers, which add in |
| + // the chooser ID. |
| + void CallDialogCancelled() { observer_->DialogCancelled(chooser_id_); } |
| + void CallDeviceSelected(const std::string& device_id) { |
| + observer_->DeviceSelected(chooser_id_, device_id); |
| + } |
| + |
| + private: |
| + Observer* const observer_; |
| + const int chooser_id_; |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_ |