| 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 "extensions/browser/api/bluetooth/bluetooth_event_router.h" | 5 #include "extensions/browser/api/bluetooth/bluetooth_event_router.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 MaybeReleaseAdapter(); | 322 MaybeReleaseAdapter(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 void BluetoothEventRouter::DispatchAdapterStateEvent() { | 325 void BluetoothEventRouter::DispatchAdapterStateEvent() { |
| 326 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 326 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 327 core_api::bluetooth::AdapterState state; | 327 core_api::bluetooth::AdapterState state; |
| 328 PopulateAdapterState(*adapter_.get(), &state); | 328 PopulateAdapterState(*adapter_.get(), &state); |
| 329 | 329 |
| 330 scoped_ptr<base::ListValue> args = | 330 scoped_ptr<base::ListValue> args = |
| 331 bluetooth::OnAdapterStateChanged::Create(state); | 331 bluetooth::OnAdapterStateChanged::Create(state); |
| 332 scoped_ptr<Event> event(new Event( | 332 scoped_ptr<Event> event( |
| 333 bluetooth::OnAdapterStateChanged::kEventName, | 333 new Event(events::UNKNOWN, bluetooth::OnAdapterStateChanged::kEventName, |
| 334 args.Pass())); | 334 args.Pass())); |
| 335 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 335 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void BluetoothEventRouter::DispatchDeviceEvent( | 338 void BluetoothEventRouter::DispatchDeviceEvent( |
| 339 const std::string& event_name, | 339 const std::string& event_name, |
| 340 device::BluetoothDevice* device) { | 340 device::BluetoothDevice* device) { |
| 341 bluetooth::Device extension_device; | 341 bluetooth::Device extension_device; |
| 342 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); | 342 bluetooth::BluetoothDeviceToApiDevice(*device, &extension_device); |
| 343 | 343 |
| 344 scoped_ptr<base::ListValue> args = | 344 scoped_ptr<base::ListValue> args = |
| 345 bluetooth::OnDeviceAdded::Create(extension_device); | 345 bluetooth::OnDeviceAdded::Create(extension_device); |
| 346 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 346 scoped_ptr<Event> event(new Event(events::UNKNOWN, event_name, args.Pass())); |
| 347 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 347 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
| 348 } | 348 } |
| 349 | 349 |
| 350 void BluetoothEventRouter::CleanUpForExtension( | 350 void BluetoothEventRouter::CleanUpForExtension( |
| 351 const std::string& extension_id) { | 351 const std::string& extension_id) { |
| 352 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 352 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 353 RemovePairingDelegate(extension_id); | 353 RemovePairingDelegate(extension_id); |
| 354 | 354 |
| 355 PreSetFilterMap::iterator pre_set_iter = | 355 PreSetFilterMap::iterator pre_set_iter = |
| 356 pre_set_filter_map_.find(extension_id); | 356 pre_set_filter_map_.find(extension_id); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 414 } |
| 415 | 415 |
| 416 void BluetoothEventRouter::OnExtensionUnloaded( | 416 void BluetoothEventRouter::OnExtensionUnloaded( |
| 417 content::BrowserContext* browser_context, | 417 content::BrowserContext* browser_context, |
| 418 const Extension* extension, | 418 const Extension* extension, |
| 419 UnloadedExtensionInfo::Reason reason) { | 419 UnloadedExtensionInfo::Reason reason) { |
| 420 CleanUpForExtension(extension->id()); | 420 CleanUpForExtension(extension->id()); |
| 421 } | 421 } |
| 422 | 422 |
| 423 } // namespace extensions | 423 } // namespace extensions |
| OLD | NEW |