| 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_event_router.h" | 5 #include "chrome/browser/extensions/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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 send_discovery_events_ = should_send; | 118 send_discovery_events_ = should_send; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void ExtensionBluetoothEventRouter::DispatchDeviceEvent( | 121 void ExtensionBluetoothEventRouter::DispatchDeviceEvent( |
| 122 const char* event_name, const extensions::api::bluetooth::Device& device) { | 122 const char* event_name, const extensions::api::bluetooth::Device& device) { |
| 123 scoped_ptr<ListValue> args(new ListValue()); | 123 scoped_ptr<ListValue> args(new ListValue()); |
| 124 args->Append(device.ToValue().release()); | 124 args->Append(device.ToValue().release()); |
| 125 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 125 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 126 DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL()); | 126 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass()); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void ExtensionBluetoothEventRouter::AdapterPresentChanged( | 129 void ExtensionBluetoothEventRouter::AdapterPresentChanged( |
| 130 device::BluetoothAdapter* adapter, bool present) { | 130 device::BluetoothAdapter* adapter, bool present) { |
| 131 if (adapter != adapter_) { | 131 if (adapter != adapter_) { |
| 132 DVLOG(1) << "Ignoring event for adapter " << adapter->address(); | 132 DVLOG(1) << "Ignoring event for adapter " << adapter->address(); |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 | 135 |
| 136 DispatchBooleanValueEvent( | 136 DispatchBooleanValueEvent( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (adapter_ && num_event_listeners_ == 0) { | 200 if (adapter_ && num_event_listeners_ == 0) { |
| 201 adapter_->RemoveObserver(this); | 201 adapter_->RemoveObserver(this); |
| 202 adapter_ = NULL; | 202 adapter_ = NULL; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( | 206 void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( |
| 207 const char* event_name, bool value) { | 207 const char* event_name, bool value) { |
| 208 scoped_ptr<ListValue> args(new ListValue()); | 208 scoped_ptr<ListValue> args(new ListValue()); |
| 209 args->Append(Value::CreateBooleanValue(value)); | 209 args->Append(Value::CreateBooleanValue(value)); |
| 210 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 210 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 211 DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL()); | 211 ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass()); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace extensions | 214 } // namespace extensions |
| OLD | NEW |