OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/webui/chromeos/emulator/device_emulator_message_hand
ler.h" | 5 #include "chrome/browser/ui/webui/chromeos/emulator/device_emulator_message_hand
ler.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Request to add the device to the view's list of devices. | 116 // Request to add the device to the view's list of devices. |
117 owner_->web_ui()->CallJavascriptFunctionUnsafe(kAddBluetoothDeviceJSCallback, | 117 owner_->web_ui()->CallJavascriptFunctionUnsafe(kAddBluetoothDeviceJSCallback, |
118 *device); | 118 *device); |
119 } | 119 } |
120 | 120 |
121 void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged( | 121 void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged( |
122 const dbus::ObjectPath& object_path, | 122 const dbus::ObjectPath& object_path, |
123 const std::string& property_name) { | 123 const std::string& property_name) { |
124 if (property_name == kPairedPropertyName) { | 124 if (property_name == kPairedPropertyName) { |
125 owner_->web_ui()->CallJavascriptFunctionUnsafe( | 125 owner_->web_ui()->CallJavascriptFunctionUnsafe( |
126 kDevicePairedFromTrayJSCallback, | 126 kDevicePairedFromTrayJSCallback, base::Value(object_path.value())); |
127 base::StringValue(object_path.value())); | |
128 } | 127 } |
129 } | 128 } |
130 | 129 |
131 void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceRemoved( | 130 void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceRemoved( |
132 const dbus::ObjectPath& object_path) { | 131 const dbus::ObjectPath& object_path) { |
133 owner_->web_ui()->CallJavascriptFunctionUnsafe( | 132 owner_->web_ui()->CallJavascriptFunctionUnsafe( |
134 kDeviceRemovedFromMainAdapterJSCallback, | 133 kDeviceRemovedFromMainAdapterJSCallback, |
135 base::StringValue(object_path.value())); | 134 base::Value(object_path.value())); |
136 } | 135 } |
137 | 136 |
138 class DeviceEmulatorMessageHandler::CrasAudioObserver | 137 class DeviceEmulatorMessageHandler::CrasAudioObserver |
139 : public CrasAudioClient::Observer { | 138 : public CrasAudioClient::Observer { |
140 public: | 139 public: |
141 explicit CrasAudioObserver(DeviceEmulatorMessageHandler* owner) | 140 explicit CrasAudioObserver(DeviceEmulatorMessageHandler* owner) |
142 : owner_(owner) { | 141 : owner_(owner) { |
143 owner_->fake_cras_audio_client_->AddObserver(this); | 142 owner_->fake_cras_audio_client_->AddObserver(this); |
144 } | 143 } |
145 | 144 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 std::string path = CreateBluetoothDeviceFromListValue(args); | 284 std::string path = CreateBluetoothDeviceFromListValue(args); |
286 bluez::FakeBluetoothDeviceClient::Properties* props = | 285 bluez::FakeBluetoothDeviceClient::Properties* props = |
287 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(path)); | 286 fake_bluetooth_device_client_->GetProperties(dbus::ObjectPath(path)); |
288 | 287 |
289 // Try to pair the device with the main adapter. The device is identified | 288 // Try to pair the device with the main adapter. The device is identified |
290 // by its device ID, which, in this case is the same as its address. | 289 // by its device ID, which, in this case is the same as its address. |
291 ash::WmShell::Get()->system_tray_delegate()->ConnectToBluetoothDevice( | 290 ash::WmShell::Get()->system_tray_delegate()->ConnectToBluetoothDevice( |
292 props->address.value()); | 291 props->address.value()); |
293 if (!props->paired.value()) { | 292 if (!props->paired.value()) { |
294 web_ui()->CallJavascriptFunctionUnsafe(kPairFailedJSCallback, | 293 web_ui()->CallJavascriptFunctionUnsafe(kPairFailedJSCallback, |
295 base::StringValue(path)); | 294 base::Value(path)); |
296 } | 295 } |
297 } | 296 } |
298 | 297 |
299 void DeviceEmulatorMessageHandler::HandleRequestAudioNodes( | 298 void DeviceEmulatorMessageHandler::HandleRequestAudioNodes( |
300 const base::ListValue* args) { | 299 const base::ListValue* args) { |
301 // Get every active audio node and create a dictionary to | 300 // Get every active audio node and create a dictionary to |
302 // send it to JavaScript. | 301 // send it to JavaScript. |
303 base::ListValue audio_nodes; | 302 base::ListValue audio_nodes; |
304 for (const AudioNode& node : fake_cras_audio_client_->node_list()) { | 303 for (const AudioNode& node : fake_cras_audio_client_->node_list()) { |
305 std::unique_ptr<base::DictionaryValue> audio_node( | 304 std::unique_ptr<base::DictionaryValue> audio_node( |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 633 } |
635 | 634 |
636 void DeviceEmulatorMessageHandler::MouseExists(bool exists) { | 635 void DeviceEmulatorMessageHandler::MouseExists(bool exists) { |
637 if (!IsJavascriptAllowed()) | 636 if (!IsJavascriptAllowed()) |
638 return; | 637 return; |
639 web_ui()->CallJavascriptFunctionUnsafe(kMouseExistsCallback, | 638 web_ui()->CallJavascriptFunctionUnsafe(kMouseExistsCallback, |
640 base::Value(exists)); | 639 base::Value(exists)); |
641 } | 640 } |
642 | 641 |
643 } // namespace chromeos | 642 } // namespace chromeos |
OLD | NEW |