| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "device/bluetooth/bluetooth_adapter.h" | 14 #include "device/bluetooth/bluetooth_adapter.h" |
| 15 #include "device/bluetooth/bluetooth_adapter_factory.h" | 15 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 16 #include "device/bluetooth/bluetooth_common.h" |
| 16 #include "device/bluetooth/bluetooth_discovery_session.h" | 17 #include "device/bluetooth/bluetooth_discovery_session.h" |
| 17 #include "extensions/browser/api/bluetooth/bluetooth_api.h" | 18 #include "extensions/browser/api/bluetooth/bluetooth_api.h" |
| 18 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" | 19 #include "extensions/browser/api/bluetooth/bluetooth_api_pairing_delegate.h" |
| 19 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 20 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
| 20 #include "extensions/common/api/bluetooth_private.h" | 21 #include "extensions/common/api/bluetooth_private.h" |
| 21 | 22 |
| 22 namespace bt_private = extensions::api::bluetooth_private; | 23 namespace bt_private = extensions::api::bluetooth_private; |
| 23 namespace SetDiscoveryFilter = bt_private::SetDiscoveryFilter; | 24 namespace SetDiscoveryFilter = bt_private::SetDiscoveryFilter; |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 std::unique_ptr<SetDiscoveryFilter::Params> params( | 404 std::unique_ptr<SetDiscoveryFilter::Params> params( |
| 404 SetDiscoveryFilter::Params::Create(*args_)); | 405 SetDiscoveryFilter::Params::Create(*args_)); |
| 405 auto& df_param = params->discovery_filter; | 406 auto& df_param = params->discovery_filter; |
| 406 | 407 |
| 407 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter; | 408 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter; |
| 408 | 409 |
| 409 // If all filter fields are empty, we are clearing filter. If any field is | 410 // If all filter fields are empty, we are clearing filter. If any field is |
| 410 // set, then create proper filter. | 411 // set, then create proper filter. |
| 411 if (df_param.uuids.get() || df_param.rssi.get() || df_param.pathloss.get() || | 412 if (df_param.uuids.get() || df_param.rssi.get() || df_param.pathloss.get() || |
| 412 df_param.transport != bt_private::TransportType::TRANSPORT_TYPE_NONE) { | 413 df_param.transport != bt_private::TransportType::TRANSPORT_TYPE_NONE) { |
| 413 uint8_t transport; | 414 device::BluetoothTransport transport; |
| 414 | 415 |
| 415 switch (df_param.transport) { | 416 switch (df_param.transport) { |
| 416 case bt_private::TransportType::TRANSPORT_TYPE_LE: | 417 case bt_private::TransportType::TRANSPORT_TYPE_LE: |
| 417 transport = device::BluetoothDiscoveryFilter::Transport::TRANSPORT_LE; | 418 transport = device::BLUETOOTH_TRANSPORT_LE; |
| 418 break; | 419 break; |
| 419 case bt_private::TransportType::TRANSPORT_TYPE_BREDR: | 420 case bt_private::TransportType::TRANSPORT_TYPE_BREDR: |
| 420 transport = | 421 transport = device::BLUETOOTH_TRANSPORT_CLASSIC; |
| 421 device::BluetoothDiscoveryFilter::Transport::TRANSPORT_CLASSIC; | |
| 422 break; | 422 break; |
| 423 default: // TRANSPORT_TYPE_NONE is included here | 423 default: // TRANSPORT_TYPE_NONE is included here |
| 424 transport = device::BluetoothDiscoveryFilter::Transport::TRANSPORT_DUAL; | 424 transport = device::BLUETOOTH_TRANSPORT_DUAL; |
| 425 break; | 425 break; |
| 426 } | 426 } |
| 427 | 427 |
| 428 discovery_filter.reset(new device::BluetoothDiscoveryFilter(transport)); | 428 discovery_filter.reset(new device::BluetoothDiscoveryFilter(transport)); |
| 429 | 429 |
| 430 if (df_param.uuids.get()) { | 430 if (df_param.uuids.get()) { |
| 431 std::vector<device::BluetoothUUID> uuids; | 431 std::vector<device::BluetoothUUID> uuids; |
| 432 if (df_param.uuids->as_string.get()) { | 432 if (df_param.uuids->as_string.get()) { |
| 433 discovery_filter->AddUUID( | 433 discovery_filter->AddUUID( |
| 434 device::BluetoothUUID(*df_param.uuids->as_string)); | 434 device::BluetoothUUID(*df_param.uuids->as_string)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 device::BluetoothDevice::ConnectErrorCode error) { | 617 device::BluetoothDevice::ConnectErrorCode error) { |
| 618 SetError(kPairingFailed); | 618 SetError(kPairingFailed); |
| 619 SendResponse(false); | 619 SendResponse(false); |
| 620 } | 620 } |
| 621 | 621 |
| 622 //////////////////////////////////////////////////////////////////////////////// | 622 //////////////////////////////////////////////////////////////////////////////// |
| 623 | 623 |
| 624 } // namespace api | 624 } // namespace api |
| 625 | 625 |
| 626 } // namespace extensions | 626 } // namespace extensions |
| OLD | NEW |