| 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..717b76d64c0c6871f98c6398135c5d09d3d07d35
|
| --- /dev/null
|
| +++ b/content/public/browser/bluetooth_chooser.h
|
| @@ -0,0 +1,75 @@
|
| +// 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. This
|
| + // defaults to POWERED_ON.
|
| + enum class AdapterPresence { ABSENT, POWERED_OFF, POWERED_ON };
|
| + virtual void SetAdapterPresence(AdapterPresence presence) = 0;
|
| +
|
| + // Lets the chooser tell the user whether discovery is happening. This
|
| + // defaults to DISCOVERING.
|
| + enum class DiscoveryState { FAILED_TO_START, DISCOVERING, IDLE };
|
| + virtual void ShowDiscoveryState(DiscoveryState state) = 0;
|
| +
|
| + // 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_
|
|
|