| 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 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" | 5 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.h" | |
| 11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" | 11 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" |
| 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" | 12 #include "chrome/browser/extensions/api/bluetooth/bluetooth_event_router.h" |
| 13 #include "chrome/browser/extensions/event_names.h" | 13 #include "chrome/browser/extensions/event_names.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/extensions/api/bluetooth.h" | 15 #include "chrome/common/extensions/api/bluetooth.h" |
| 16 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" | 16 #include "chrome/common/extensions/api/bluetooth/bluetooth_manifest_data.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "device/bluetooth/bluetooth_adapter.h" | 18 #include "device/bluetooth/bluetooth_adapter.h" |
| 19 #include "device/bluetooth/bluetooth_device.h" | 19 #include "device/bluetooth/bluetooth_device.h" |
| 20 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 20 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 namespace GetProfiles = extensions::api::bluetooth::GetProfiles; | 70 namespace GetProfiles = extensions::api::bluetooth::GetProfiles; |
| 71 namespace GetServices = extensions::api::bluetooth::GetServices; | 71 namespace GetServices = extensions::api::bluetooth::GetServices; |
| 72 namespace Read = extensions::api::bluetooth::Read; | 72 namespace Read = extensions::api::bluetooth::Read; |
| 73 namespace RemoveProfile = extensions::api::bluetooth::RemoveProfile; | 73 namespace RemoveProfile = extensions::api::bluetooth::RemoveProfile; |
| 74 namespace SetOutOfBandPairingData = | 74 namespace SetOutOfBandPairingData = |
| 75 extensions::api::bluetooth::SetOutOfBandPairingData; | 75 extensions::api::bluetooth::SetOutOfBandPairingData; |
| 76 namespace Write = extensions::api::bluetooth::Write; | 76 namespace Write = extensions::api::bluetooth::Write; |
| 77 | 77 |
| 78 namespace extensions { | 78 namespace extensions { |
| 79 | 79 |
| 80 static base::LazyInstance<ProfileKeyedAPIFactory<BluetoothAPI> > g_factory = |
| 81 LAZY_INSTANCE_INITIALIZER; |
| 82 |
| 83 // static |
| 84 ProfileKeyedAPIFactory<BluetoothAPI>* BluetoothAPI::GetFactoryInstance() { |
| 85 return g_factory.Pointer(); |
| 86 } |
| 87 |
| 80 // static | 88 // static |
| 81 BluetoothAPI* BluetoothAPI::Get(Profile* profile) { | 89 BluetoothAPI* BluetoothAPI::Get(Profile* profile) { |
| 82 return BluetoothAPIFactory::GetForProfile(profile); | 90 return GetFactoryInstance()->GetForProfile(profile); |
| 83 } | 91 } |
| 84 | 92 |
| 85 BluetoothAPI::BluetoothAPI(Profile* profile) : profile_(profile) { | 93 BluetoothAPI::BluetoothAPI(Profile* profile) : profile_(profile) { |
| 86 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( | 94 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( |
| 87 this, bluetooth::OnAdapterStateChanged::kEventName); | 95 this, bluetooth::OnAdapterStateChanged::kEventName); |
| 88 } | 96 } |
| 89 | 97 |
| 90 BluetoothAPI::~BluetoothAPI() { | 98 BluetoothAPI::~BluetoothAPI() { |
| 91 } | 99 } |
| 92 | 100 |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 adapter->StopDiscovering( | 672 adapter->StopDiscovering( |
| 665 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 673 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
| 666 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 674 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
| 667 } | 675 } |
| 668 | 676 |
| 669 return true; | 677 return true; |
| 670 } | 678 } |
| 671 | 679 |
| 672 } // namespace api | 680 } // namespace api |
| 673 } // namespace extensions | 681 } // namespace extensions |
| OLD | NEW |