Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Unified Diff: chrome/browser/ui/webui/options/chromeos/system_options_handler.cc

Issue 8137003: Add display of available bluetooth devices, and mechanism for retrieving the list. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add opacity transition animation for the Bluetooth scanning indicator. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..39c8183d357cee23d1baa80d5663620684671f55 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,46 @@ void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) {
chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL);
}
+
+void SystemOptionsHandler::BluetoothEnableChangeCallback(
+ const ListValue* args) {
+ // 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::BluetoothDeviceNotification(
+ const DictionaryValue& device) {
+ web_ui_->CallJavascriptFunction(
+ "options.SystemOptions.AddBluetoothDevice", device);
+}
+
+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.
+ 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);
+ }
+ web_ui_->CallJavascriptFunction(
+ "options.SystemOptions.NotifyBluetoothSearchComplete");
+}

Powered by Google App Engine
This is Rietveld 408576698