#include "extensions/browser/api/bluetooth/bluetooth_event_router.h"
#include <map>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
#include "content/public/browser/browser_thread.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
#include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h"
#include "extensions/browser/api/bluetooth/bluetooth_api_utils.h"
#include "extensions/browser/api/bluetooth/bluetooth_private_api.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host.h"
#include "extensions/common/api/bluetooth.h"
#include "extensions/common/api/bluetooth_private.h"
#include "extensions/common/extension_id.h"
namespace extensions {
namespace {
constexpr char kScanClientName[] = …;
void IgnoreAdapterResult(scoped_refptr<device::BluetoothAdapter> adapter) { … }
void IgnoreAdapterResultAndThen(
base::OnceClosure callback,
scoped_refptr<device::BluetoothAdapter> adapter) { … }
std::string GetListenerId(const extensions::EventListenerInfo& details) { … }
}
bluetooth;
bt_private;
BluetoothEventRouter::BluetoothEventRouter(content::BrowserContext* context)
: … { … }
BluetoothEventRouter::~BluetoothEventRouter() { … }
bool BluetoothEventRouter::IsBluetoothSupported() const { … }
void BluetoothEventRouter::GetAdapter(
device::BluetoothAdapterFactory::AdapterCallback callback) { … }
void BluetoothEventRouter::StartDiscoverySession(
device::BluetoothAdapter* adapter,
const ExtensionId& extension_id,
base::OnceClosure callback,
base::OnceClosure error_callback) { … }
void BluetoothEventRouter::StartDiscoverySessionImpl(
device::BluetoothAdapter* adapter,
const ExtensionId& extension_id,
base::OnceClosure callback,
base::OnceClosure error_callback) { … }
void BluetoothEventRouter::StopDiscoverySession(
device::BluetoothAdapter* adapter,
const ExtensionId& extension_id,
base::OnceClosure callback,
base::OnceClosure error_callback) { … }
void BluetoothEventRouter::SetDiscoveryFilter(
std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter,
device::BluetoothAdapter* adapter,
const ExtensionId& extension_id,
base::OnceClosure callback,
base::OnceClosure error_callback) { … }
BluetoothApiPairingDelegate* BluetoothEventRouter::GetPairingDelegate(
const ExtensionId& extension_id) { … }
void BluetoothEventRouter::OnAdapterInitialized(
device::BluetoothAdapterFactory::AdapterCallback callback,
scoped_refptr<device::BluetoothAdapter> adapter) { … }
void BluetoothEventRouter::MaybeReleaseAdapter() { … }
void BluetoothEventRouter::AddPairingDelegate(const ExtensionId& extension_id) { … }
void BluetoothEventRouter::AddPairingDelegateImpl(
const ExtensionId& extension_id) { … }
void BluetoothEventRouter::RemovePairingDelegate(
const ExtensionId& extension_id) { … }
void BluetoothEventRouter::AdapterPresentChanged(
device::BluetoothAdapter* adapter,
bool present) { … }
void BluetoothEventRouter::AdapterPoweredChanged(
device::BluetoothAdapter* adapter,
bool has_power) { … }
void BluetoothEventRouter::AdapterDiscoveringChanged(
device::BluetoothAdapter* adapter,
bool discovering) { … }
void BluetoothEventRouter::DeviceAdded(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) { … }
void BluetoothEventRouter::DeviceChanged(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) { … }
void BluetoothEventRouter::DeviceRemoved(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) { … }
void BluetoothEventRouter::DeviceAddressChanged(
device::BluetoothAdapter* adapter,
device::BluetoothDevice* device,
const std::string& old_address) { … }
void BluetoothEventRouter::OnListenerAdded(const EventListenerInfo& details) { … }
void BluetoothEventRouter::OnListenerRemoved(const EventListenerInfo& details) { … }
void BluetoothEventRouter::DispatchAdapterStateEvent() { … }
void BluetoothEventRouter::DispatchDeviceEvent(
events::HistogramValue histogram_value,
const std::string& event_name,
device::BluetoothDevice* device) { … }
void BluetoothEventRouter::CleanUpForExtension(
const ExtensionId& extension_id) { … }
void BluetoothEventRouter::CleanUpAllExtensions() { … }
void BluetoothEventRouter::OnStartDiscoverySession(
const ExtensionId& extension_id,
base::OnceClosure callback,
std::unique_ptr<device::BluetoothDiscoverySession> discovery_session) { … }
void BluetoothEventRouter::OnExtensionHostDestroyed(
content::BrowserContext* browser_context,
ExtensionHost* host) { … }
void BluetoothEventRouter::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
UnloadedExtensionReason reason) { … }
}