| 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 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" | 14 #include "chrome/browser/extensions/api/bluetooth/bluetooth_api_utils.h" |
| 15 #include "chrome/browser/extensions/bluetooth_event_router.h" | 15 #include "chrome/browser/extensions/bluetooth_event_router.h" |
| 16 #include "chrome/browser/extensions/event_names.h" | 16 #include "chrome/browser/extensions/event_names.h" |
| 17 #include "chrome/browser/extensions/event_router.h" | 17 #include "chrome/browser/extensions/event_router.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/common/extensions/api/bluetooth.h" | 21 #include "chrome/common/extensions/api/bluetooth.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 22 #include "device/bluetooth/bluetooth_adapter.h" | 23 #include "device/bluetooth/bluetooth_adapter.h" |
| 23 #include "device/bluetooth/bluetooth_device.h" | 24 #include "device/bluetooth/bluetooth_device.h" |
| 24 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 25 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
| 25 #include "device/bluetooth/bluetooth_service_record.h" | 26 #include "device/bluetooth/bluetooth_service_record.h" |
| 26 #include "device/bluetooth/bluetooth_socket.h" | 27 #include "device/bluetooth/bluetooth_socket.h" |
| 27 #include "device/bluetooth/bluetooth_utils.h" | 28 #include "device/bluetooth/bluetooth_utils.h" |
| 28 | 29 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (callbacks_pending_ == -1) | 154 if (callbacks_pending_ == -1) |
| 154 FinishDeviceSearch(); | 155 FinishDeviceSearch(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void BluetoothGetDevicesFunction::FinishDeviceSearch() { | 158 void BluetoothGetDevicesFunction::FinishDeviceSearch() { |
| 158 scoped_ptr<base::ListValue> args(new base::ListValue()); | 159 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 159 scoped_ptr<base::DictionaryValue> info(new base::DictionaryValue()); | 160 scoped_ptr<base::DictionaryValue> info(new base::DictionaryValue()); |
| 160 info->SetInteger("expectedEventCount", device_events_sent_); | 161 info->SetInteger("expectedEventCount", device_events_sent_); |
| 161 args->Append(info.release()); | 162 args->Append(info.release()); |
| 162 | 163 |
| 163 profile()->GetExtensionEventRouter()->DispatchEventToRenderers( | 164 extensions::ExtensionSystem::Get(profile())->event_router()-> |
| 164 extensions::event_names::kBluetoothOnDeviceSearchFinished, | 165 DispatchEventToRenderers( |
| 165 args.Pass(), | 166 extensions::event_names::kBluetoothOnDeviceSearchFinished, |
| 166 NULL, | 167 args.Pass(), |
| 167 GURL()); | 168 NULL, |
| 169 GURL()); |
| 168 | 170 |
| 169 SendResponse(true); | 171 SendResponse(true); |
| 170 } | 172 } |
| 171 | 173 |
| 172 bool BluetoothGetDevicesFunction::RunImpl() { | 174 bool BluetoothGetDevicesFunction::RunImpl() { |
| 173 if (!IsBluetoothSupported(profile())) { | 175 if (!IsBluetoothSupported(profile())) { |
| 174 SetError(kPlatformNotSupported); | 176 SetError(kPlatformNotSupported); |
| 175 return false; | 177 return false; |
| 176 } | 178 } |
| 177 | 179 |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 if (GetEventRouter(profile())->IsResponsibleForDiscovery()) { | 604 if (GetEventRouter(profile())->IsResponsibleForDiscovery()) { |
| 603 GetMutableAdapter(profile())->SetDiscovering(false, | 605 GetMutableAdapter(profile())->SetDiscovering(false, |
| 604 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), | 606 base::Bind(&BluetoothStopDiscoveryFunction::OnSuccessCallback, this), |
| 605 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); | 607 base::Bind(&BluetoothStopDiscoveryFunction::OnErrorCallback, this)); |
| 606 } | 608 } |
| 607 return true; | 609 return true; |
| 608 } | 610 } |
| 609 | 611 |
| 610 } // namespace api | 612 } // namespace api |
| 611 } // namespace extensions | 613 } // namespace extensions |
| OLD | NEW |