| 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/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_factory.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/extensions/event_router.h" | 14 #include "chrome/browser/extensions/event_router.h" |
| 15 #include "chrome/browser/extensions/extension_system.h" | 15 #include "chrome/browser/extensions/extension_system.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/common/extensions/api/bluetooth.h" | 17 #include "chrome/common/extensions/api/bluetooth.h" |
| 18 #include "chrome/common/extensions/permissions/bluetooth_device_permission.h" | 18 #include "chrome/common/extensions/permissions/bluetooth_device_permission.h" |
| 19 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 20 #include "device/bluetooth/bluetooth_adapter.h" | 21 #include "device/bluetooth/bluetooth_adapter.h" |
| 21 #include "device/bluetooth/bluetooth_device.h" | 22 #include "device/bluetooth/bluetooth_device.h" |
| 22 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 23 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
| 23 #include "device/bluetooth/bluetooth_profile.h" | 24 #include "device/bluetooth/bluetooth_profile.h" |
| 24 #include "device/bluetooth/bluetooth_service_record.h" | 25 #include "device/bluetooth/bluetooth_service_record.h" |
| 25 #include "device/bluetooth/bluetooth_socket.h" | 26 #include "device/bluetooth/bluetooth_socket.h" |
| 26 #include "device/bluetooth/bluetooth_utils.h" | 27 #include "device/bluetooth/bluetooth_utils.h" |
| 27 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
| 28 | 29 |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 SetError(kFailedToConnect); | 369 SetError(kFailedToConnect); |
| 369 SendResponse(false); | 370 SendResponse(false); |
| 370 } | 371 } |
| 371 | 372 |
| 372 bool BluetoothConnectFunction::DoWork(scoped_refptr<BluetoothAdapter> adapter) { | 373 bool BluetoothConnectFunction::DoWork(scoped_refptr<BluetoothAdapter> adapter) { |
| 373 scoped_ptr<Connect::Params> params(Connect::Params::Create(*args_)); | 374 scoped_ptr<Connect::Params> params(Connect::Params::Create(*args_)); |
| 374 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 375 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
| 375 const bluetooth::ConnectOptions& options = params->options; | 376 const bluetooth::ConnectOptions& options = params->options; |
| 376 | 377 |
| 377 BluetoothDevicePermission::CheckParam param(options.device.address); | 378 BluetoothDevicePermission::CheckParam param(options.device.address); |
| 378 if (!GetExtension()->CheckAPIPermissionWithParam( | 379 if (!PermissionsData::CheckAPIPermissionWithParam( |
| 379 APIPermission::kBluetoothDevice, ¶m)) { | 380 GetExtension(), APIPermission::kBluetoothDevice, ¶m)) { |
| 380 SetError(kDevicePermissionDenied); | 381 SetError(kDevicePermissionDenied); |
| 381 SendResponse(false); | 382 SendResponse(false); |
| 382 return false; | 383 return false; |
| 383 } | 384 } |
| 384 | 385 |
| 385 if (!BluetoothDevice::IsUUIDValid(options.profile.uuid)) { | 386 if (!BluetoothDevice::IsUUIDValid(options.profile.uuid)) { |
| 386 SetError(kInvalidUuid); | 387 SetError(kInvalidUuid); |
| 387 SendResponse(false); | 388 SendResponse(false); |
| 388 return false; | 389 return false; |
| 389 } | 390 } |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 adapter->StopDiscovering( | 664 adapter->StopDiscovering( |
| 664 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 665 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
| 665 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 666 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
| 666 } | 667 } |
| 667 | 668 |
| 668 return true; | 669 return true; |
| 669 } | 670 } |
| 670 | 671 |
| 671 } // namespace api | 672 } // namespace api |
| 672 } // namespace extensions | 673 } // namespace extensions |
| OLD | NEW |