OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ |
6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ | 6 #define EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace extensions { | 34 namespace extensions { |
35 class BluetoothApiPairingDelegate; | 35 class BluetoothApiPairingDelegate; |
36 class ExtensionRegistry; | 36 class ExtensionRegistry; |
37 | 37 |
38 class BluetoothEventRouter : public device::BluetoothAdapter::Observer, | 38 class BluetoothEventRouter : public device::BluetoothAdapter::Observer, |
39 public content::NotificationObserver, | 39 public content::NotificationObserver, |
40 public ExtensionRegistryObserver { | 40 public ExtensionRegistryObserver { |
41 public: | 41 public: |
42 explicit BluetoothEventRouter(content::BrowserContext* context); | 42 explicit BluetoothEventRouter(content::BrowserContext* context); |
43 virtual ~BluetoothEventRouter(); | 43 ~BluetoothEventRouter() override; |
44 | 44 |
45 // Returns true if adapter_ has been initialized for testing or bluetooth | 45 // Returns true if adapter_ has been initialized for testing or bluetooth |
46 // adapter is available for the current platform. | 46 // adapter is available for the current platform. |
47 bool IsBluetoothSupported() const; | 47 bool IsBluetoothSupported() const; |
48 | 48 |
49 void GetAdapter( | 49 void GetAdapter( |
50 const device::BluetoothAdapterFactory::AdapterCallback& callback); | 50 const device::BluetoothAdapterFactory::AdapterCallback& callback); |
51 | 51 |
52 // Requests that a new device discovery session be initiated for extension | 52 // Requests that a new device discovery session be initiated for extension |
53 // with id |extension_id|. |callback| is called, if a session has been | 53 // with id |extension_id|. |callback| is called, if a session has been |
(...skipping 30 matching lines...) Expand all Loading... |
84 // pairing delegate. | 84 // pairing delegate. |
85 BluetoothApiPairingDelegate* GetPairingDelegate( | 85 BluetoothApiPairingDelegate* GetPairingDelegate( |
86 const std::string& extension_id); | 86 const std::string& extension_id); |
87 | 87 |
88 // Exposed for testing. | 88 // Exposed for testing. |
89 void SetAdapterForTest(device::BluetoothAdapter* adapter) { | 89 void SetAdapterForTest(device::BluetoothAdapter* adapter) { |
90 adapter_ = adapter; | 90 adapter_ = adapter; |
91 } | 91 } |
92 | 92 |
93 // Override from device::BluetoothAdapter::Observer. | 93 // Override from device::BluetoothAdapter::Observer. |
94 virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 94 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
95 bool present) override; | 95 bool present) override; |
96 virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 96 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
97 bool has_power) override; | 97 bool has_power) override; |
98 virtual void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, | 98 void AdapterDiscoveringChanged(device::BluetoothAdapter* adapter, |
99 bool discovering) override; | 99 bool discovering) override; |
100 virtual void DeviceAdded(device::BluetoothAdapter* adapter, | 100 void DeviceAdded(device::BluetoothAdapter* adapter, |
101 device::BluetoothDevice* device) override; | 101 device::BluetoothDevice* device) override; |
102 virtual void DeviceChanged(device::BluetoothAdapter* adapter, | 102 void DeviceChanged(device::BluetoothAdapter* adapter, |
103 device::BluetoothDevice* device) override; | 103 device::BluetoothDevice* device) override; |
104 virtual void DeviceRemoved(device::BluetoothAdapter* adapter, | 104 void DeviceRemoved(device::BluetoothAdapter* adapter, |
105 device::BluetoothDevice* device) override; | 105 device::BluetoothDevice* device) override; |
106 | 106 |
107 // Overridden from content::NotificationObserver. | 107 // Overridden from content::NotificationObserver. |
108 virtual void Observe(int type, | 108 void Observe(int type, |
109 const content::NotificationSource& source, | 109 const content::NotificationSource& source, |
110 const content::NotificationDetails& details) override; | 110 const content::NotificationDetails& details) override; |
111 | 111 |
112 // Overridden from ExtensionRegistryObserver. | 112 // Overridden from ExtensionRegistryObserver. |
113 virtual void OnExtensionUnloaded( | 113 void OnExtensionUnloaded(content::BrowserContext* browser_context, |
114 content::BrowserContext* browser_context, | 114 const Extension* extension, |
115 const Extension* extension, | 115 UnloadedExtensionInfo::Reason reason) override; |
116 UnloadedExtensionInfo::Reason reason) override; | |
117 | 116 |
118 // BrowserContextKeyedAPI implementation. | 117 // BrowserContextKeyedAPI implementation. |
119 static const char* service_name() { return "BluetoothEventRouter"; } | 118 static const char* service_name() { return "BluetoothEventRouter"; } |
120 static const bool kServiceRedirectedInIncognito = true; | 119 static const bool kServiceRedirectedInIncognito = true; |
121 static const bool kServiceIsNULLWhileTesting = true; | 120 static const bool kServiceIsNULLWhileTesting = true; |
122 | 121 |
123 private: | 122 private: |
124 void OnAdapterInitialized(const base::Closure& callback, | 123 void OnAdapterInitialized(const base::Closure& callback, |
125 scoped_refptr<device::BluetoothAdapter> adapter); | 124 scoped_refptr<device::BluetoothAdapter> adapter); |
126 void MaybeReleaseAdapter(); | 125 void MaybeReleaseAdapter(); |
(...skipping 28 matching lines...) Expand all Loading... |
155 extension_registry_observer_; | 154 extension_registry_observer_; |
156 | 155 |
157 base::WeakPtrFactory<BluetoothEventRouter> weak_ptr_factory_; | 156 base::WeakPtrFactory<BluetoothEventRouter> weak_ptr_factory_; |
158 | 157 |
159 DISALLOW_COPY_AND_ASSIGN(BluetoothEventRouter); | 158 DISALLOW_COPY_AND_ASSIGN(BluetoothEventRouter); |
160 }; | 159 }; |
161 | 160 |
162 } // namespace extensions | 161 } // namespace extensions |
163 | 162 |
164 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ | 163 #endif // EXTENSIONS_BROWSER_API_BLUETOOTH_BLUETOOTH_EVENT_ROUTER_H_ |
OLD | NEW |