| 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_socket/bluetooth_socket_api.h" | 5 #include "extensions/browser/api/bluetooth_socket/bluetooth_socket_api.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return; | 294 return; |
| 295 } | 295 } |
| 296 | 296 |
| 297 BluetoothPermissionRequest param(uuid()); | 297 BluetoothPermissionRequest param(uuid()); |
| 298 if (!BluetoothManifestData::CheckRequest(extension(), param)) { | 298 if (!BluetoothManifestData::CheckRequest(extension(), param)) { |
| 299 error_ = kPermissionDeniedError; | 299 error_ = kPermissionDeniedError; |
| 300 AsyncWorkCompleted(); | 300 AsyncWorkCompleted(); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| 303 | 303 |
| 304 scoped_ptr<std::string> name; | 304 std::unique_ptr<std::string> name; |
| 305 if (socket->name()) | 305 if (socket->name()) |
| 306 name.reset(new std::string(*socket->name())); | 306 name.reset(new std::string(*socket->name())); |
| 307 | 307 |
| 308 CreateService( | 308 CreateService( |
| 309 adapter, bluetooth_uuid, std::move(name), | 309 adapter, bluetooth_uuid, std::move(name), |
| 310 base::Bind(&BluetoothSocketListenFunction::OnCreateService, this), | 310 base::Bind(&BluetoothSocketListenFunction::OnCreateService, this), |
| 311 base::Bind(&BluetoothSocketListenFunction::OnCreateServiceError, this)); | 311 base::Bind(&BluetoothSocketListenFunction::OnCreateServiceError, this)); |
| 312 } | 312 } |
| 313 | 313 |
| 314 | 314 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 357 |
| 358 bool BluetoothSocketListenUsingRfcommFunction::CreateParams() { | 358 bool BluetoothSocketListenUsingRfcommFunction::CreateParams() { |
| 359 params_ = bluetooth_socket::ListenUsingRfcomm::Params::Create(*args_); | 359 params_ = bluetooth_socket::ListenUsingRfcomm::Params::Create(*args_); |
| 360 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 360 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 361 return true; | 361 return true; |
| 362 } | 362 } |
| 363 | 363 |
| 364 void BluetoothSocketListenUsingRfcommFunction::CreateService( | 364 void BluetoothSocketListenUsingRfcommFunction::CreateService( |
| 365 scoped_refptr<device::BluetoothAdapter> adapter, | 365 scoped_refptr<device::BluetoothAdapter> adapter, |
| 366 const device::BluetoothUUID& uuid, | 366 const device::BluetoothUUID& uuid, |
| 367 scoped_ptr<std::string> name, | 367 std::unique_ptr<std::string> name, |
| 368 const device::BluetoothAdapter::CreateServiceCallback& callback, | 368 const device::BluetoothAdapter::CreateServiceCallback& callback, |
| 369 const device::BluetoothAdapter::CreateServiceErrorCallback& | 369 const device::BluetoothAdapter::CreateServiceErrorCallback& |
| 370 error_callback) { | 370 error_callback) { |
| 371 device::BluetoothAdapter::ServiceOptions service_options; | 371 device::BluetoothAdapter::ServiceOptions service_options; |
| 372 service_options.name = std::move(name); | 372 service_options.name = std::move(name); |
| 373 | 373 |
| 374 ListenOptions* options = params_->options.get(); | 374 ListenOptions* options = params_->options.get(); |
| 375 if (options) { | 375 if (options) { |
| 376 if (options->channel.get()) | 376 if (options->channel.get()) |
| 377 service_options.channel.reset(new int(*(options->channel))); | 377 service_options.channel.reset(new int(*(options->channel))); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 400 | 400 |
| 401 bool BluetoothSocketListenUsingL2capFunction::CreateParams() { | 401 bool BluetoothSocketListenUsingL2capFunction::CreateParams() { |
| 402 params_ = bluetooth_socket::ListenUsingL2cap::Params::Create(*args_); | 402 params_ = bluetooth_socket::ListenUsingL2cap::Params::Create(*args_); |
| 403 EXTENSION_FUNCTION_VALIDATE(params_.get()); | 403 EXTENSION_FUNCTION_VALIDATE(params_.get()); |
| 404 return true; | 404 return true; |
| 405 } | 405 } |
| 406 | 406 |
| 407 void BluetoothSocketListenUsingL2capFunction::CreateService( | 407 void BluetoothSocketListenUsingL2capFunction::CreateService( |
| 408 scoped_refptr<device::BluetoothAdapter> adapter, | 408 scoped_refptr<device::BluetoothAdapter> adapter, |
| 409 const device::BluetoothUUID& uuid, | 409 const device::BluetoothUUID& uuid, |
| 410 scoped_ptr<std::string> name, | 410 std::unique_ptr<std::string> name, |
| 411 const device::BluetoothAdapter::CreateServiceCallback& callback, | 411 const device::BluetoothAdapter::CreateServiceCallback& callback, |
| 412 const device::BluetoothAdapter::CreateServiceErrorCallback& | 412 const device::BluetoothAdapter::CreateServiceErrorCallback& |
| 413 error_callback) { | 413 error_callback) { |
| 414 device::BluetoothAdapter::ServiceOptions service_options; | 414 device::BluetoothAdapter::ServiceOptions service_options; |
| 415 service_options.name = std::move(name); | 415 service_options.name = std::move(name); |
| 416 | 416 |
| 417 ListenOptions* options = params_->options.get(); | 417 ListenOptions* options = params_->options.get(); |
| 418 if (options) { | 418 if (options) { |
| 419 if (options->psm) { | 419 if (options->psm) { |
| 420 int psm = *options->psm; | 420 int psm = *options->psm; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 if (socket) { | 663 if (socket) { |
| 664 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); | 664 socket_infos.push_back(CreateSocketInfo(socket_id, socket)); |
| 665 } | 665 } |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); | 668 results_ = bluetooth_socket::GetSockets::Results::Create(socket_infos); |
| 669 } | 669 } |
| 670 | 670 |
| 671 } // namespace api | 671 } // namespace api |
| 672 } // namespace extensions | 672 } // namespace extensions |
| OLD | NEW |