Chromium Code Reviews| Index: chrome/browser/ui/webui/options/chromeos/system_options_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc |
| index 3055b8fff3073487b1bd7a72d564d8caba5479bd..a00870689068092023a7ac8374c6e6321fa7642b 100644 |
| --- a/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc |
| @@ -73,6 +73,12 @@ void SystemOptionsHandler::GetLocalizedValues( |
| l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENABLE)); |
| localized_strings->SetString("findBluetoothDevices", |
| l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_FIND_BLUETOOTH_DEVICES)); |
| + localized_strings->SetString("bluetoothScanning", |
| + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_SCANNING)); |
| + localized_strings->SetString("bluetoothDeviceConnected", |
| + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTED)); |
| + localized_strings->SetString("bluetoothDeviceNotPaired", |
| + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_NOT_PAIRED)); |
| localized_strings->SetString("language", |
| l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); |
| @@ -116,6 +122,10 @@ void SystemOptionsHandler::RegisterMessages() { |
| DCHECK(web_ui_); |
| web_ui_->RegisterMessageCallback("accessibilityChange", |
| NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); |
| + web_ui_->RegisterMessageCallback("bluetoothEnableChange", |
| + NewCallback(this, &SystemOptionsHandler::BluetoothEnableChangeCallback)); |
| + web_ui_->RegisterMessageCallback("findBluetoothDevices", |
| + NewCallback(this, &SystemOptionsHandler::FindBluetoothDevicesCallback)); |
| } |
| void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
| @@ -125,3 +135,49 @@ void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
| chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); |
| } |
| + |
| +void SystemOptionsHandler::BluetoothEnableChangeCallback(const ListValue* args) |
| +{ |
|
James Hawkins
2011/10/04 20:43:39
Opening brace goes on the same line as the method.
kevers
2011/10/05 14:23:01
Exceeded 80 character line limit with the opening
|
| + // TODO (kevers) - Call Bluetooth API to enable or disable. |
| +} |
| + |
| +void SystemOptionsHandler::FindBluetoothDevicesCallback(const ListValue* args) { |
| + // TODO (kevers) - Call Bluetooth API to fetch devices. |
| + // Generate a fake list until the bluetooth API is ready. |
| + // Afterwards keep fake list only for cases where emulating |
| + // ChromeOS from the desktop launch. |
| + GenerateFakeDeviceList(); |
| +} |
| + |
| +void SystemOptionsHandler::GenerateFakeDeviceList() { |
| + // TODO (kevers) - Send notifications asynchronously simulating that the |
| + // process of discovering bluetooth devices takes time. |
| + // Fire each notification using OneShotTimer with a |
| + // varying delay. |
| + BluetoothDeviceNotification("Fake Wireless Keyboard", "01-02-03-04-05", |
| + "keyboard", false); |
| + BluetoothDeviceNotification("Fake Wireless Mouse", "02-03-04-05-01", |
| + "mouse", false); |
| + BluetoothDeviceNotification("Fake Wireless Headset", "03-04-05-01-02", |
| + "headset", false); |
| + |
| + web_ui_->CallJavascriptFunction( |
| + "options.SystemOptions.NotifyBluetoothSearchComplete"); |
| +} |
| + |
| +void SystemOptionsHandler::BluetoothDeviceNotification( |
| + const std::string& name, |
| + const std::string& id, |
| + const std::string& type, |
| + bool connected) { |
| + DictionaryValue device; |
| + device.SetString("deviceName", name); |
| + device.SetString("deviceId", id); |
| + device.SetString("deviceType", type); |
| + device.SetString("deviceStatus", connected ? "bluetoothDeviceConnected" : |
| + "bluetoothDeviceNotPaired"); |
|
Vince Laviano
2011/10/04 22:03:14
There's a distinction between paired and connected
kevers
2011/10/05 14:23:01
Agreed that passing in a dictionary is more flexib
|
| + web_ui_->CallJavascriptFunction( |
| + "options.SystemOptions.AddBluetoothDevice", device); |
| +} |
| + |
| + |