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/chromeos/extensions/bluetooth_event_router.h" | 5 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 chromeos::BluetoothAdapter* adapter, chromeos::BluetoothDevice* device) { | 107 chromeos::BluetoothAdapter* adapter, chromeos::BluetoothDevice* device) { |
108 if (!send_discovery_events_) | 108 if (!send_discovery_events_) |
109 return; | 109 return; |
110 | 110 |
111 DCHECK(adapter == adapter_.get()); | 111 DCHECK(adapter == adapter_.get()); |
112 | 112 |
113 extensions::api::experimental_bluetooth::Device extension_device; | 113 extensions::api::experimental_bluetooth::Device extension_device; |
114 extensions::api::experimental_bluetooth::BluetoothDeviceToApiDevice( | 114 extensions::api::experimental_bluetooth::BluetoothDeviceToApiDevice( |
115 *device, &extension_device); | 115 *device, &extension_device); |
116 | 116 |
117 ListValue args; | 117 scoped_ptr<ListValue> args(new ListValue()); |
118 args.Append(extension_device.ToValue().release()); | 118 args->Append(extension_device.ToValue().release()); |
119 std::string json_args; | |
120 base::JSONWriter::Write(&args, &json_args); | |
121 | 119 |
122 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 120 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
123 extensions::event_names::kBluetoothOnDeviceDiscovered, | 121 extensions::event_names::kBluetoothOnDeviceDiscovered, |
124 json_args, | 122 args.Pass(), |
125 NULL, | 123 NULL, |
126 GURL()); | 124 GURL()); |
127 } | 125 } |
128 | 126 |
129 void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( | 127 void ExtensionBluetoothEventRouter::DispatchBooleanValueEvent( |
130 const char* event_name, bool value) { | 128 const char* event_name, bool value) { |
131 ListValue args; | 129 scoped_ptr<ListValue> args(new ListValue()); |
132 args.Append(Value::CreateBooleanValue(value)); | 130 args->Append(Value::CreateBooleanValue(value)); |
133 std::string json_args; | |
134 base::JSONWriter::Write(&args, &json_args); | |
135 | 131 |
136 // TODO(bryeung): only dispatch the event to interested renderers | 132 // TODO(bryeung): only dispatch the event to interested renderers |
137 // crbug.com/133179 | 133 // crbug.com/133179 |
138 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( | 134 profile_->GetExtensionEventRouter()->DispatchEventToRenderers( |
139 event_name, json_args, NULL, GURL()); | 135 event_name, args.Pass(), NULL, GURL()); |
140 } | 136 } |
141 | 137 |
142 } // namespace chromeos | 138 } // namespace chromeos |
OLD | NEW |