OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_private_api.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "device/bluetooth/bluetooth_adapter.h" | 10 #include "device/bluetooth/bluetooth_adapter.h" |
11 #include "device/bluetooth/bluetooth_adapter_factory.h" | 11 #include "device/bluetooth/bluetooth_adapter_factory.h" |
12 #include "device/bluetooth/bluetooth_discovery_session.h" | 12 #include "device/bluetooth/bluetooth_discovery_session.h" |
13 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 13 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
14 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 14 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
15 #include "extensions/common/api/bluetooth_private.h" | 15 #include "extensions/common/api/bluetooth_private.h" |
16 | 16 |
17 namespace bt_private = extensions::core_api::bluetooth_private; | 17 namespace bt_private = extensions::api::bluetooth_private; |
18 namespace SetDiscoveryFilter = bt_private::SetDiscoveryFilter; | 18 namespace SetDiscoveryFilter = bt_private::SetDiscoveryFilter; |
19 | 19 |
20 namespace extensions { | 20 namespace extensions { |
21 | 21 |
22 static base::LazyInstance<BrowserContextKeyedAPIFactory<BluetoothPrivateAPI> > | 22 static base::LazyInstance<BrowserContextKeyedAPIFactory<BluetoothPrivateAPI> > |
23 g_factory = LAZY_INSTANCE_INITIALIZER; | 23 g_factory = LAZY_INSTANCE_INITIALIZER; |
24 | 24 |
25 // static | 25 // static |
26 BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>* | 26 BrowserContextKeyedAPIFactory<BluetoothPrivateAPI>* |
27 BluetoothPrivateAPI::GetFactoryInstance() { | 27 BluetoothPrivateAPI::GetFactoryInstance() { |
(...skipping 25 matching lines...) Expand all Loading... |
53 void BluetoothPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) { | 53 void BluetoothPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) { |
54 // This function can be called multiple times for the same JS listener, for | 54 // This function can be called multiple times for the same JS listener, for |
55 // example, once for the addListener call and again if it is a lazy listener. | 55 // example, once for the addListener call and again if it is a lazy listener. |
56 if (!details.browser_context) | 56 if (!details.browser_context) |
57 return; | 57 return; |
58 | 58 |
59 BluetoothAPI::Get(browser_context_)->event_router()->RemovePairingDelegate( | 59 BluetoothAPI::Get(browser_context_)->event_router()->RemovePairingDelegate( |
60 details.extension_id); | 60 details.extension_id); |
61 } | 61 } |
62 | 62 |
63 namespace core_api { | 63 namespace api { |
64 | 64 |
65 namespace { | 65 namespace { |
66 | 66 |
67 const char kNameProperty[] = "name"; | 67 const char kNameProperty[] = "name"; |
68 const char kPoweredProperty[] = "powered"; | 68 const char kPoweredProperty[] = "powered"; |
69 const char kDiscoverableProperty[] = "discoverable"; | 69 const char kDiscoverableProperty[] = "discoverable"; |
70 | 70 |
71 const char kSetAdapterPropertyError[] = "Error setting adapter properties: $1"; | 71 const char kSetAdapterPropertyError[] = "Error setting adapter properties: $1"; |
72 | 72 |
73 const char kDeviceNotFoundError[] = | 73 const char kDeviceNotFoundError[] = |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 discovery_filter.Pass(), adapter.get(), extension_id(), | 408 discovery_filter.Pass(), adapter.get(), extension_id(), |
409 base::Bind( | 409 base::Bind( |
410 &BluetoothPrivateSetDiscoveryFilterFunction::OnSuccessCallback, | 410 &BluetoothPrivateSetDiscoveryFilterFunction::OnSuccessCallback, |
411 this), | 411 this), |
412 base::Bind( | 412 base::Bind( |
413 &BluetoothPrivateSetDiscoveryFilterFunction::OnErrorCallback, | 413 &BluetoothPrivateSetDiscoveryFilterFunction::OnErrorCallback, |
414 this)); | 414 this)); |
415 return true; | 415 return true; |
416 } | 416 } |
417 | 417 |
418 } // namespace core_api | 418 } // namespace api |
419 | 419 |
420 } // namespace extensions | 420 } // namespace extensions |
OLD | NEW |