Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: content/public/browser/bluetooth_chooser.h

Issue 1286063002: Add a path for content/ to open and control a Bluetooth chooser dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Fix Gio's comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #ifndef CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_
6 #define CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_
7
8 #include <string>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h"
12 #include "content/common/content_export.h"
13
14 class GURL;
15
16 namespace content {
17
18 // Represents a way to ask the user to select a Bluetooth device from a list of
19 // options.
20 class CONTENT_EXPORT BluetoothChooser {
21 public:
22 class Observer {
23 public:
24 // The user cancelled the chooser instead of selecting a device.
25 virtual void DialogCancelled(int chooser_id) = 0;
26 // The user selected device |device_id|.
27 virtual void DeviceSelected(int chooser_id,
28 const std::string& device_id) = 0;
29
30 // As the dialog implementations grow more user-visible buttons and knobs,
31 // those knobs will cause new functions to be called here.
32
33 protected:
34 ~Observer() {}
35 };
36
37 // |observer| must outlive |this|. |chooser_id| is propagated to the Observer
38 // methods.
39 BluetoothChooser(Observer* observer, int chooser_id)
40 : observer_(observer), chooser_id_(chooser_id) {}
41 virtual ~BluetoothChooser();
42
43 // Lets the chooser tell the user the state of the Bluetooth adapter. This
44 // defaults to POWERED_ON.
45 enum class AdapterPresence { ABSENT, POWERED_OFF, POWERED_ON };
46 virtual void SetAdapterPresence(AdapterPresence presence) = 0;
47
48 // Lets the chooser tell the user whether discovery is happening. This
49 // defaults to DISCOVERING.
50 enum class DiscoveryState { FAILED_TO_START, DISCOVERING, IDLE };
51 virtual void ShowDiscoveryState(DiscoveryState state) = 0;
52
53 // Shows a new device in the chooser.
54 virtual void AddDevice(const std::string& device_id,
55 const base::string16& device_name) = 0;
56 // Tells the chooser that a device is no longer available. The chooser should
57 // not call DeviceSelected() for a device that's been removed.
58 virtual void RemoveDevice(const std::string& device_id) = 0;
59
60 protected:
61 // Subclasses call the observer methods through these wrappers, which add in
62 // the chooser ID.
63 void CallDialogCancelled() { observer_->DialogCancelled(chooser_id_); }
64 void CallDeviceSelected(const std::string& device_id) {
65 observer_->DeviceSelected(chooser_id_, device_id);
66 }
67
68 private:
69 Observer* const observer_;
70 const int chooser_id_;
71 };
72
73 } // namespace content
74
75 #endif // CONTENT_PUBLIC_BROWSER_BLUETOOTH_CHOOSER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698