diff options
author | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-02 23:53:27 +0000 |
---|---|---|
committer | kevers@chromium.org <kevers@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-02 23:53:27 +0000 |
commit | 47d2f41e5f17f1daab75668b742204d61fba014a (patch) | |
tree | e3ac1746e557b24a6cf8d42b566bb3a0b136b4c2 /chrome/browser/ui | |
parent | 8c2a2d5be02d9c2720441011256b0267cd8f323b (diff) | |
download | chromium_src-47d2f41e5f17f1daab75668b742204d61fba014a.zip chromium_src-47d2f41e5f17f1daab75668b742204d61fba014a.tar.gz chromium_src-47d2f41e5f17f1daab75668b742204d61fba014a.tar.bz2 |
Standardize on a common set of names for Bluetooth device properties.
BUG=100392
TEST=
Review URL: http://codereview.chromium.org/8428015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc | 57 | ||||
-rw-r--r-- | chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h | 10 |
2 files changed, 39 insertions, 28 deletions
diff --git a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc index d3ab23c..4c5bce8 100644 --- a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.cc @@ -200,21 +200,8 @@ void BluetoothOptionsHandler::DeviceFound(const std::string& adapter_id, chromeos::BluetoothDevice* device) { VLOG(2) << "Device found on " << adapter_id; DCHECK(device); - - // TODO(vlaviano): eliminate inconsistencies between the javascript rep and - // BluetoothDevice so that we can use BluetoothDevice::AsDictionary() here. - DictionaryValue device_js_rep; - device_js_rep.SetString("deviceName", device->GetName()); - device_js_rep.SetString("deviceId", device->GetAddress()); - device_js_rep.SetString("deviceType", device->GetIcon()); - if (device->IsPaired()) { - device_js_rep.SetString("deviceStatus", "bluetoothDeviceConnected"); - } else { - device_js_rep.SetString("deviceStatus", "bluetoothDeviceNotPaired"); - } - web_ui_->CallJavascriptFunction( - "options.SystemOptions.addBluetoothDevice", device_js_rep); + "options.SystemOptions.addBluetoothDevice", device->AsDictionary()); } void BluetoothOptionsHandler::ValidateDefaultAdapter( @@ -232,22 +219,36 @@ void BluetoothOptionsHandler::GenerateFakeDeviceList() { // process of discovering bluetooth devices takes time. // Fire each notification using OneShotTimer with a // varying delay. - std::string data[9] = { - "Fake Wireless Keyboard", "01-02-03-04-05", "keyboard", - "Fake Wireless Mouse", "02-03-04-05-01", "mouse", - "Fake Wireless Headset", "03-04-05-01-02", "headset"}; - - for (int i = 0; i < 3; i++) { - DictionaryValue device; - device.SetString("deviceName", data[3*i]); - device.SetString("deviceId", data[3*i+1]); - device.SetString("deviceType", data[3*i+2]); - device.SetString("deviceStatus", "bluetoothDeviceNotPaired"); - web_ui_->CallJavascriptFunction( - "options.SystemOptions.addBluetoothDevice", device); - } + GenerateFakeDiscoveredDevice( + "Fake Wireless Keyboard", + "01-02-03-04-05-06", + "keyboard"); + GenerateFakeDiscoveredDevice( + "Fake Wireless Mouse", + "02-03-04-05-06-01", + "mouse"); + GenerateFakeDiscoveredDevice( + "Fake Wireless Headset", + "03-04-05-06-01-02", + "headset"); web_ui_->CallJavascriptFunction( "options.SystemOptions.notifyBluetoothSearchComplete"); } +void BluetoothOptionsHandler::GenerateFakeDiscoveredDevice( + const std::string& name, + const std::string& address, + const std::string& icon) +{ + DictionaryValue device; + device.SetString("name", name); + device.SetString("address", address); + device.SetString("icon", icon); + device.SetBoolean("paired", false); + device.SetBoolean("connected", false); + web_ui_->CallJavascriptFunction( + "options.SystemOptions.addBluetoothDevice", device); + +} + } // namespace chromeos diff --git a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h index ee354d0..b88fc5f 100644 --- a/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h +++ b/chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h @@ -74,6 +74,16 @@ class BluetoothOptionsHandler : public chromeos::CrosOptionsPageUIHandler, // Called when emulating ChromeOS from a desktop environment. void GenerateFakeDeviceList(); + // Simulates the discovery of a Bluetooth device. Used when emulating + // ChromeOS from a desktop environment. + // |name| is the display name for the device. + // |address| is the unique Mac address of the device. + // |icon| is the base name of the icon to use for the device and corresponds + // to the general device category (e.g. mouse or keyboard) + void GenerateFakeDiscoveredDevice(const std::string& name, + const std::string& address, + const std::string& icon); + // The id of the current default bluetooth adapter. // The empty string represents "none". std::string default_adapter_id_; |