| 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 CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // ReleaseSocket is called for the socket. Returns an id for the socket. | 30 // ReleaseSocket is called for the socket. Returns an id for the socket. |
| 31 int RegisterSocket(scoped_refptr<BluetoothSocket> socket); | 31 int RegisterSocket(scoped_refptr<BluetoothSocket> socket); |
| 32 | 32 |
| 33 // Release the BluetoothSocket corresponding to |id|. Returns true if | 33 // Release the BluetoothSocket corresponding to |id|. Returns true if |
| 34 // the socket was found and released, false otherwise. | 34 // the socket was found and released, false otherwise. |
| 35 bool ReleaseSocket(int id); | 35 bool ReleaseSocket(int id); |
| 36 | 36 |
| 37 // Get the BluetoothSocket corresponding to |id|. | 37 // Get the BluetoothSocket corresponding to |id|. |
| 38 scoped_refptr<BluetoothSocket> GetSocket(int id); | 38 scoped_refptr<BluetoothSocket> GetSocket(int id); |
| 39 | 39 |
| 40 // Sets whether or not DeviceAdded events will be dispatched to extensions. |
| 41 void SetSendDiscoveryEvents(bool should_send); |
| 42 |
| 40 // Override from chromeos::BluetoothAdapter::Observer | 43 // Override from chromeos::BluetoothAdapter::Observer |
| 41 virtual void AdapterPresentChanged( | 44 virtual void AdapterPresentChanged(chromeos::BluetoothAdapter* adapter, |
| 42 chromeos::BluetoothAdapter* adapter, bool present) OVERRIDE; | 45 bool present) OVERRIDE; |
| 43 virtual void AdapterPoweredChanged( | 46 virtual void AdapterPoweredChanged(chromeos::BluetoothAdapter* adapter, |
| 44 chromeos::BluetoothAdapter* adapter, bool has_power) OVERRIDE; | 47 bool has_power) OVERRIDE; |
| 48 virtual void DeviceAdded(chromeos::BluetoothAdapter* adapter, |
| 49 chromeos::BluetoothDevice* device) OVERRIDE; |
| 45 | 50 |
| 46 // Exposed for testing. | 51 // Exposed for testing. |
| 47 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) { | 52 void SetAdapterForTest(chromeos::BluetoothAdapter* adapter) { |
| 48 adapter_.reset(adapter); | 53 adapter_.reset(adapter); |
| 49 } | 54 } |
| 50 private: | 55 private: |
| 51 void DispatchEvent(const char* event_name, bool value); | 56 void DispatchBooleanValueEvent(const char* event_name, bool value); |
| 57 |
| 58 bool send_discovery_events_; |
| 52 | 59 |
| 53 Profile* profile_; | 60 Profile* profile_; |
| 54 scoped_ptr<chromeos::BluetoothAdapter> adapter_; | 61 scoped_ptr<chromeos::BluetoothAdapter> adapter_; |
| 55 | 62 |
| 56 // The next id to use for referring to a BluetoothSocket. We avoid using | 63 // The next id to use for referring to a BluetoothSocket. We avoid using |
| 57 // the fd of the socket because we don't want to leak that information to | 64 // the fd of the socket because we don't want to leak that information to |
| 58 // the extension javascript. | 65 // the extension javascript. |
| 59 int next_socket_id_; | 66 int next_socket_id_; |
| 60 | 67 |
| 61 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap; | 68 typedef std::map<int, scoped_refptr<BluetoothSocket> > SocketMap; |
| 62 SocketMap socket_map_; | 69 SocketMap socket_map_; |
| 63 | 70 |
| 64 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter); | 71 DISALLOW_COPY_AND_ASSIGN(ExtensionBluetoothEventRouter); |
| 65 }; | 72 }; |
| 66 | 73 |
| 67 } // namespace chromeos | 74 } // namespace chromeos |
| 68 | 75 |
| 69 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ | 76 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_BLUETOOTH_EVENT_ROUTER_H_ |
| OLD | NEW |