| 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/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 void DeviceRemoved(const dbus::ObjectPath& object_path) override; | 94 void DeviceRemoved(const dbus::ObjectPath& object_path) override; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 DeviceEmulatorMessageHandler* owner_; | 97 DeviceEmulatorMessageHandler* owner_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(BluetoothObserver); | 99 DISALLOW_COPY_AND_ASSIGN(BluetoothObserver); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceAdded( | 102 void DeviceEmulatorMessageHandler::BluetoothObserver::DeviceAdded( |
| 103 const dbus::ObjectPath& object_path) { | 103 const dbus::ObjectPath& object_path) { |
| 104 scoped_ptr<base::DictionaryValue> device = owner_->GetDeviceInfo( | 104 std::unique_ptr<base::DictionaryValue> device = |
| 105 object_path); | 105 owner_->GetDeviceInfo(object_path); |
| 106 | 106 |
| 107 // Request to add the device to the view's list of devices. | 107 // Request to add the device to the view's list of devices. |
| 108 owner_->web_ui()->CallJavascriptFunction(kAddBluetoothDeviceJSCallback, | 108 owner_->web_ui()->CallJavascriptFunction(kAddBluetoothDeviceJSCallback, |
| 109 *device); | 109 *device); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged( | 112 void DeviceEmulatorMessageHandler::BluetoothObserver::DevicePropertyChanged( |
| 113 const dbus::ObjectPath& object_path, | 113 const dbus::ObjectPath& object_path, |
| 114 const std::string& property_name) { | 114 const std::string& property_name) { |
| 115 if (property_name == kPairedPropertyName) { | 115 if (property_name == kPairedPropertyName) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 const base::ListValue* args) { | 232 const base::ListValue* args) { |
| 233 // Get a list containing paths of the devices which are connected to | 233 // Get a list containing paths of the devices which are connected to |
| 234 // the main adapter. | 234 // the main adapter. |
| 235 std::vector<dbus::ObjectPath> paths = | 235 std::vector<dbus::ObjectPath> paths = |
| 236 fake_bluetooth_device_client_->GetDevicesForAdapter( | 236 fake_bluetooth_device_client_->GetDevicesForAdapter( |
| 237 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); | 237 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath)); |
| 238 | 238 |
| 239 base::ListValue devices; | 239 base::ListValue devices; |
| 240 // Get each device's properties. | 240 // Get each device's properties. |
| 241 for (const dbus::ObjectPath& path : paths) { | 241 for (const dbus::ObjectPath& path : paths) { |
| 242 scoped_ptr<base::DictionaryValue> device = GetDeviceInfo(path); | 242 std::unique_ptr<base::DictionaryValue> device = GetDeviceInfo(path); |
| 243 devices.Append(std::move(device)); | 243 devices.Append(std::move(device)); |
| 244 } | 244 } |
| 245 | 245 |
| 246 scoped_ptr<base::ListValue> predefined_devices = | 246 std::unique_ptr<base::ListValue> predefined_devices = |
| 247 fake_bluetooth_device_client_->GetBluetoothDevicesAsDictionaries(); | 247 fake_bluetooth_device_client_->GetBluetoothDevicesAsDictionaries(); |
| 248 | 248 |
| 249 base::ListValue pairing_method_options; | 249 base::ListValue pairing_method_options; |
| 250 pairing_method_options.AppendString( | 250 pairing_method_options.AppendString( |
| 251 bluez::FakeBluetoothDeviceClient::kPairingMethodNone); | 251 bluez::FakeBluetoothDeviceClient::kPairingMethodNone); |
| 252 pairing_method_options.AppendString( | 252 pairing_method_options.AppendString( |
| 253 bluez::FakeBluetoothDeviceClient::kPairingMethodPinCode); | 253 bluez::FakeBluetoothDeviceClient::kPairingMethodPinCode); |
| 254 pairing_method_options.AppendString( | 254 pairing_method_options.AppendString( |
| 255 bluez::FakeBluetoothDeviceClient::kPairingMethodPassKey); | 255 bluez::FakeBluetoothDeviceClient::kPairingMethodPassKey); |
| 256 | 256 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 286 base::StringValue(path)); | 286 base::StringValue(path)); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 void DeviceEmulatorMessageHandler::HandleRequestAudioNodes( | 290 void DeviceEmulatorMessageHandler::HandleRequestAudioNodes( |
| 291 const base::ListValue* args) { | 291 const base::ListValue* args) { |
| 292 // Get every active audio node and create a dictionary to | 292 // Get every active audio node and create a dictionary to |
| 293 // send it to JavaScript. | 293 // send it to JavaScript. |
| 294 base::ListValue audio_nodes; | 294 base::ListValue audio_nodes; |
| 295 for (const AudioNode& node : fake_cras_audio_client_->node_list()) { | 295 for (const AudioNode& node : fake_cras_audio_client_->node_list()) { |
| 296 scoped_ptr<base::DictionaryValue> audio_node(new base::DictionaryValue()); | 296 std::unique_ptr<base::DictionaryValue> audio_node( |
| 297 new base::DictionaryValue()); |
| 297 | 298 |
| 298 audio_node->SetBoolean("isInput", node.is_input); | 299 audio_node->SetBoolean("isInput", node.is_input); |
| 299 audio_node->SetString("id", base::Uint64ToString(node.id)); | 300 audio_node->SetString("id", base::Uint64ToString(node.id)); |
| 300 audio_node->SetString("deviceName", node.device_name); | 301 audio_node->SetString("deviceName", node.device_name); |
| 301 audio_node->SetString("type", node.type); | 302 audio_node->SetString("type", node.type); |
| 302 audio_node->SetString("name", node.name); | 303 audio_node->SetString("name", node.name); |
| 303 audio_node->SetBoolean("active", node.active); | 304 audio_node->SetBoolean("active", node.active); |
| 304 | 305 |
| 305 audio_nodes.Append(std::move(audio_node)); | 306 audio_nodes.Append(std::move(audio_node)); |
| 306 } | 307 } |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 CHECK(device_dict->GetBoolean("incoming", &props.incoming)); | 525 CHECK(device_dict->GetBoolean("incoming", &props.incoming)); |
| 525 | 526 |
| 526 // Create the device and store it in the FakeBluetoothDeviceClient's observed | 527 // Create the device and store it in the FakeBluetoothDeviceClient's observed |
| 527 // list of devices. | 528 // list of devices. |
| 528 fake_bluetooth_device_client_->CreateDeviceWithProperties( | 529 fake_bluetooth_device_client_->CreateDeviceWithProperties( |
| 529 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), props); | 530 dbus::ObjectPath(bluez::FakeBluetoothAdapterClient::kAdapterPath), props); |
| 530 | 531 |
| 531 return props.device_path; | 532 return props.device_path; |
| 532 } | 533 } |
| 533 | 534 |
| 534 scoped_ptr<base::DictionaryValue> DeviceEmulatorMessageHandler::GetDeviceInfo( | 535 std::unique_ptr<base::DictionaryValue> |
| 536 DeviceEmulatorMessageHandler::GetDeviceInfo( |
| 535 const dbus::ObjectPath& object_path) { | 537 const dbus::ObjectPath& object_path) { |
| 536 // Get the device's properties. | 538 // Get the device's properties. |
| 537 bluez::FakeBluetoothDeviceClient::Properties* props = | 539 bluez::FakeBluetoothDeviceClient::Properties* props = |
| 538 fake_bluetooth_device_client_->GetProperties(object_path); | 540 fake_bluetooth_device_client_->GetProperties(object_path); |
| 539 scoped_ptr<base::DictionaryValue> device(new base::DictionaryValue()); | 541 std::unique_ptr<base::DictionaryValue> device(new base::DictionaryValue()); |
| 540 scoped_ptr<base::ListValue> uuids(new base::ListValue); | 542 std::unique_ptr<base::ListValue> uuids(new base::ListValue); |
| 541 bluez::FakeBluetoothDeviceClient::SimulatedPairingOptions* options = | 543 bluez::FakeBluetoothDeviceClient::SimulatedPairingOptions* options = |
| 542 fake_bluetooth_device_client_->GetPairingOptions(object_path); | 544 fake_bluetooth_device_client_->GetPairingOptions(object_path); |
| 543 | 545 |
| 544 device->SetString("path", object_path.value()); | 546 device->SetString("path", object_path.value()); |
| 545 device->SetString("name", props->name.value()); | 547 device->SetString("name", props->name.value()); |
| 546 device->SetString("alias", props->alias.value()); | 548 device->SetString("alias", props->alias.value()); |
| 547 device->SetString("address", props->address.value()); | 549 device->SetString("address", props->address.value()); |
| 548 if (options) { | 550 if (options) { |
| 549 device->SetString("pairingMethod", options->pairing_method); | 551 device->SetString("pairingMethod", options->pairing_method); |
| 550 device->SetString("pairingAuthToken", options->pairing_auth_token); | 552 device->SetString("pairingAuthToken", options->pairing_auth_token); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 561 for (const std::string& uuid : props->uuids.value()) { | 563 for (const std::string& uuid : props->uuids.value()) { |
| 562 uuids->AppendString(uuid); | 564 uuids->AppendString(uuid); |
| 563 } | 565 } |
| 564 | 566 |
| 565 device->Set("uuids", std::move(uuids)); | 567 device->Set("uuids", std::move(uuids)); |
| 566 | 568 |
| 567 return device; | 569 return device; |
| 568 } | 570 } |
| 569 | 571 |
| 570 } // namespace chromeos | 572 } // namespace chromeos |
| OLD | NEW |