| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/chromeos/system_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/system_options_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 localized_strings->SetString("sensitivityMore", | 67 localized_strings->SetString("sensitivityMore", |
| 68 l10n_util::GetStringUTF16( | 68 l10n_util::GetStringUTF16( |
| 69 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION)); | 69 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION)); |
| 70 | 70 |
| 71 localized_strings->SetString("bluetooth", | 71 localized_strings->SetString("bluetooth", |
| 72 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); | 72 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); |
| 73 localized_strings->SetString("enableBluetooth", | 73 localized_strings->SetString("enableBluetooth", |
| 74 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENABLE)); | 74 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENABLE)); |
| 75 localized_strings->SetString("findBluetoothDevices", | 75 localized_strings->SetString("findBluetoothDevices", |
| 76 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_FIND_BLUETOOTH_DEVICES)); | 76 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_FIND_BLUETOOTH_DEVICES)); |
| 77 localized_strings->SetString("bluetoothScanning", |
| 78 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_SCANNING)); |
| 79 localized_strings->SetString("bluetoothDeviceConnected", |
| 80 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTED)); |
| 81 localized_strings->SetString("bluetoothDeviceNotPaired", |
| 82 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_NOT_PAIRED)); |
| 77 | 83 |
| 78 localized_strings->SetString("language", | 84 localized_strings->SetString("language", |
| 79 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); | 85 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); |
| 80 localized_strings->SetString("languageCustomize", | 86 localized_strings->SetString("languageCustomize", |
| 81 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 87 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
| 82 localized_strings->SetString("modifierKeysCustomize", | 88 localized_strings->SetString("modifierKeysCustomize", |
| 83 l10n_util::GetStringUTF16( | 89 l10n_util::GetStringUTF16( |
| 84 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); | 90 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); |
| 85 | 91 |
| 86 localized_strings->SetString("accessibilityTitle", | 92 localized_strings->SetString("accessibilityTitle", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 102 base::FundamentalValue checked(acc_enabled); | 108 base::FundamentalValue checked(acc_enabled); |
| 103 web_ui_->CallJavascriptFunction( | 109 web_ui_->CallJavascriptFunction( |
| 104 "options.SystemOptions.SetAccessibilityCheckboxState", checked); | 110 "options.SystemOptions.SetAccessibilityCheckboxState", checked); |
| 105 | 111 |
| 106 // Bluetooth support is a work in progress. Supress the feature unless | 112 // Bluetooth support is a work in progress. Supress the feature unless |
| 107 // explicitly enabled via a command line flag. | 113 // explicitly enabled via a command line flag. |
| 108 // TODO (kevers) - Test for presence of bluetooth hardware. | 114 // TODO (kevers) - Test for presence of bluetooth hardware. |
| 109 if (CommandLine::ForCurrentProcess() | 115 if (CommandLine::ForCurrentProcess() |
| 110 ->HasSwitch(switches::kEnableBluetooth)) { | 116 ->HasSwitch(switches::kEnableBluetooth)) { |
| 111 web_ui_->CallJavascriptFunction( | 117 web_ui_->CallJavascriptFunction( |
| 112 "options.SystemOptions.ShowBluetoothSettings"); | 118 "options.SystemOptions.showBluetoothSettings"); |
| 113 } | 119 } |
| 114 } | 120 } |
| 115 | 121 |
| 116 void SystemOptionsHandler::RegisterMessages() { | 122 void SystemOptionsHandler::RegisterMessages() { |
| 117 DCHECK(web_ui_); | 123 DCHECK(web_ui_); |
| 118 web_ui_->RegisterMessageCallback("accessibilityChange", | 124 web_ui_->RegisterMessageCallback("accessibilityChange", |
| 119 base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback, | 125 base::Bind(&SystemOptionsHandler::AccessibilityChangeCallback, |
| 120 base::Unretained(this))); | 126 base::Unretained(this))); |
| 127 web_ui_->RegisterMessageCallback("bluetoothEnableChange", |
| 128 NewCallback(this, &SystemOptionsHandler::BluetoothEnableChangeCallback)); |
| 129 web_ui_->RegisterMessageCallback("findBluetoothDevices", |
| 130 NewCallback(this, &SystemOptionsHandler::FindBluetoothDevicesCallback)); |
| 121 } | 131 } |
| 122 | 132 |
| 123 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { | 133 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
| 124 std::string checked_str; | 134 std::string checked_str; |
| 125 args->GetString(0, &checked_str); | 135 args->GetString(0, &checked_str); |
| 126 bool accessibility_enabled = (checked_str == "true"); | 136 bool accessibility_enabled = (checked_str == "true"); |
| 127 | 137 |
| 128 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); | 138 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); |
| 129 } | 139 } |
| 140 |
| 141 void SystemOptionsHandler::BluetoothEnableChangeCallback( |
| 142 const ListValue* args) { |
| 143 // TODO (kevers) - Call Bluetooth API to enable or disable. |
| 144 } |
| 145 |
| 146 void SystemOptionsHandler::FindBluetoothDevicesCallback( |
| 147 const ListValue* args) { |
| 148 // TODO (kevers) - Call Bluetooth API to fetch devices. |
| 149 // Generate a fake list until the bluetooth API is ready. |
| 150 // Afterwards keep fake list only for cases where emulating |
| 151 // ChromeOS from the desktop launch. |
| 152 GenerateFakeDeviceList(); |
| 153 } |
| 154 |
| 155 void SystemOptionsHandler::BluetoothDeviceNotification( |
| 156 const DictionaryValue& device) { |
| 157 web_ui_->CallJavascriptFunction( |
| 158 "options.SystemOptions.addBluetoothDevice", device); |
| 159 } |
| 160 |
| 161 void SystemOptionsHandler::GenerateFakeDeviceList() { |
| 162 // TODO (kevers) - Send notifications asynchronously simulating that the |
| 163 // process of discovering bluetooth devices takes time. |
| 164 // Fire each notification using OneShotTimer with a |
| 165 // varying delay. |
| 166 std::string data[9] = { |
| 167 "Fake Wireless Keyboard", "01-02-03-04-05", "keyboard", |
| 168 "Fake Wireless Mouse", "02-03-04-05-01", "mouse", |
| 169 "Fake Wireless Headset", "03-04-05-01-02", "headset"}; |
| 170 |
| 171 for (int i = 0; i < 3; i++) { |
| 172 DictionaryValue device; |
| 173 device.SetString("deviceName", data[3*i]); |
| 174 device.SetString("deviceId", data[3*i+1]); |
| 175 device.SetString("deviceType", data[3*i+2]); |
| 176 device.SetString("deviceStatus", "bluetoothDeviceNotPaired"); |
| 177 web_ui_->CallJavascriptFunction( |
| 178 "options.SystemOptions.addBluetoothDevice", device); |
| 179 } |
| 180 web_ui_->CallJavascriptFunction( |
| 181 "options.SystemOptions.notifyBluetoothSearchComplete"); |
| 182 } |
| OLD | NEW |