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

Side by Side Diff: chrome/browser/extensions/api/bluetooth/bluetooth_api.h

Issue 420663003: Extensions: Move bluetooth APIs to extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix android, gn Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_extension_function.h "
13 #include "chrome/common/extensions/api/bluetooth.h"
14 #include "device/bluetooth/bluetooth_device.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h"
16 #include "extensions/browser/event_router.h"
17 #include "extensions/browser/extension_function.h"
18
19 namespace content {
20 class BrowserContext;
21 }
22
23 namespace device {
24 class BluetoothAdapter;
25 }
26
27 namespace extensions {
28
29 class BluetoothEventRouter;
30
31 // The profile-keyed service that manages the bluetooth extension API.
32 // All methods of this class must be called on the UI thread.
33 // TODO(rpaquay): Rename this and move to separate file.
34 class BluetoothAPI : public BrowserContextKeyedAPI,
35 public EventRouter::Observer {
36 public:
37 // Convenience method to get the BluetoothAPI for a browser context.
38 static BluetoothAPI* Get(content::BrowserContext* context);
39
40 static BrowserContextKeyedAPIFactory<BluetoothAPI>* GetFactoryInstance();
41
42 explicit BluetoothAPI(content::BrowserContext* context);
43 virtual ~BluetoothAPI();
44
45 BluetoothEventRouter* event_router();
46
47 // KeyedService implementation.
48 virtual void Shutdown() OVERRIDE;
49
50 // EventRouter::Observer implementation.
51 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE;
52 virtual void OnListenerRemoved(const EventListenerInfo& details) OVERRIDE;
53
54 private:
55 // BrowserContextKeyedAPI implementation.
56 friend class BrowserContextKeyedAPIFactory<BluetoothAPI>;
57 static const char* service_name() { return "BluetoothAPI"; }
58 static const bool kServiceRedirectedInIncognito = true;
59 static const bool kServiceIsNULLWhileTesting = true;
60
61 content::BrowserContext* browser_context_;
62
63 // Created lazily on first access.
64 scoped_ptr<BluetoothEventRouter> event_router_;
65 };
66
67 namespace api {
68
69 class BluetoothGetAdapterStateFunction : public BluetoothExtensionFunction {
70 public:
71 DECLARE_EXTENSION_FUNCTION("bluetooth.getAdapterState",
72 BLUETOOTH_GETADAPTERSTATE)
73
74 protected:
75 virtual ~BluetoothGetAdapterStateFunction();
76
77 // BluetoothExtensionFunction:
78 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
79 };
80
81 class BluetoothGetDevicesFunction : public BluetoothExtensionFunction {
82 public:
83 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevices", BLUETOOTH_GETDEVICES)
84
85 protected:
86 virtual ~BluetoothGetDevicesFunction();
87
88 // BluetoothExtensionFunction:
89 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
90 };
91
92 class BluetoothGetDeviceFunction : public BluetoothExtensionFunction {
93 public:
94 DECLARE_EXTENSION_FUNCTION("bluetooth.getDevice", BLUETOOTH_GETDEVICE)
95
96 // BluetoothExtensionFunction:
97 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
98
99 protected:
100 virtual ~BluetoothGetDeviceFunction();
101 };
102
103 class BluetoothStartDiscoveryFunction : public BluetoothExtensionFunction {
104 public:
105 DECLARE_EXTENSION_FUNCTION("bluetooth.startDiscovery",
106 BLUETOOTH_STARTDISCOVERY)
107
108 protected:
109 virtual ~BluetoothStartDiscoveryFunction() {}
110
111 // BluetoothExtensionFunction:
112 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
113
114 private:
115 void OnSuccessCallback();
116 void OnErrorCallback();
117 };
118
119 class BluetoothStopDiscoveryFunction : public BluetoothExtensionFunction {
120 public:
121 DECLARE_EXTENSION_FUNCTION("bluetooth.stopDiscovery", BLUETOOTH_STOPDISCOVERY)
122
123 protected:
124 virtual ~BluetoothStopDiscoveryFunction() {}
125
126 // BluetoothExtensionFunction:
127 virtual bool DoWork(scoped_refptr<device::BluetoothAdapter> adapter) OVERRIDE;
128
129 private:
130 void OnSuccessCallback();
131 void OnErrorCallback();
132 };
133
134 } // namespace api
135 } // namespace extensions
136
137 #endif // CHROME_BROWSER_EXTENSIONS_API_BLUETOOTH_BLUETOOTH_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/bluetooth/OWNERS ('k') | chrome/browser/extensions/api/bluetooth/bluetooth_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698