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

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: Remove addition of animated spinner in favour of reusing an existing throbber class. 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
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/system_options_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 362fa82b08ba652ce73d3402c530f0d04eb8b0cc..a692f0054349d71e4f366d50ccb09a991d83dcc4 100644
--- a/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc
+++ b/chrome/browser/ui/webui/options/chromeos/system_options_handler.cc
@@ -74,6 +74,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));
@@ -109,7 +115,7 @@ void SystemOptionsHandler::Initialize() {
if (CommandLine::ForCurrentProcess()
->HasSwitch(switches::kEnableBluetooth)) {
web_ui_->CallJavascriptFunction(
- "options.SystemOptions.ShowBluetoothSettings");
+ "options.SystemOptions.showBluetoothSettings");
}
}
@@ -118,6 +124,10 @@ void SystemOptionsHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback("accessibilityChange",
base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback,
base::Unretained(this)));
+ web_ui_->RegisterMessageCallback("bluetoothEnableChange",
+ NewCallback(this, &SystemOptionsHandler::BluetoothEnableChangeCallback));
+ web_ui_->RegisterMessageCallback("findBluetoothDevices",
+ NewCallback(this, &SystemOptionsHandler::FindBluetoothDevicesCallback));
}
void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) {
@@ -127,3 +137,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");
+}
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/system_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698