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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 localized_strings->SetString("sensitivityMore", | 66 localized_strings->SetString("sensitivityMore", |
67 l10n_util::GetStringUTF16( | 67 l10n_util::GetStringUTF16( |
68 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION)); | 68 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION)); |
69 | 69 |
70 localized_strings->SetString("bluetooth", | 70 localized_strings->SetString("bluetooth", |
71 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); | 71 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_BLUETOOTH)); |
72 localized_strings->SetString("enableBluetooth", | 72 localized_strings->SetString("enableBluetooth", |
73 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENABLE)); | 73 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_ENABLE)); |
74 localized_strings->SetString("findBluetoothDevices", | 74 localized_strings->SetString("findBluetoothDevices", |
75 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_FIND_BLUETOOTH_DEVICES)); | 75 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_FIND_BLUETOOTH_DEVICES)); |
76 localized_strings->SetString("bluetoothScanning", | |
77 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_SCANNING)); | |
78 localized_strings->SetString("bluetoothDeviceConnected", | |
79 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_CONNECTED)); | |
80 localized_strings->SetString("bluetoothDeviceNotPaired", | |
81 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_BLUETOOTH_NOT_PAIRED)); | |
76 | 82 |
77 localized_strings->SetString("language", | 83 localized_strings->SetString("language", |
78 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); | 84 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); |
79 localized_strings->SetString("languageCustomize", | 85 localized_strings->SetString("languageCustomize", |
80 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); | 86 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); |
81 localized_strings->SetString("modifierKeysCustomize", | 87 localized_strings->SetString("modifierKeysCustomize", |
82 l10n_util::GetStringUTF16( | 88 l10n_util::GetStringUTF16( |
83 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); | 89 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); |
84 | 90 |
85 localized_strings->SetString("accessibilityTitle", | 91 localized_strings->SetString("accessibilityTitle", |
(...skipping 23 matching lines...) Expand all Loading... | |
109 ->HasSwitch(switches::kEnableBluetooth)) { | 115 ->HasSwitch(switches::kEnableBluetooth)) { |
110 web_ui_->CallJavascriptFunction( | 116 web_ui_->CallJavascriptFunction( |
111 "options.SystemOptions.ShowBluetoothSettings"); | 117 "options.SystemOptions.ShowBluetoothSettings"); |
112 } | 118 } |
113 } | 119 } |
114 | 120 |
115 void SystemOptionsHandler::RegisterMessages() { | 121 void SystemOptionsHandler::RegisterMessages() { |
116 DCHECK(web_ui_); | 122 DCHECK(web_ui_); |
117 web_ui_->RegisterMessageCallback("accessibilityChange", | 123 web_ui_->RegisterMessageCallback("accessibilityChange", |
118 NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); | 124 NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); |
125 web_ui_->RegisterMessageCallback("bluetoothEnableChange", | |
126 NewCallback(this, &SystemOptionsHandler::BluetoothEnableChangeCallback)); | |
127 web_ui_->RegisterMessageCallback("findBluetoothDevices", | |
128 NewCallback(this, &SystemOptionsHandler::FindBluetoothDevicesCallback)); | |
119 } | 129 } |
120 | 130 |
121 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { | 131 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
122 std::string checked_str; | 132 std::string checked_str; |
123 args->GetString(0, &checked_str); | 133 args->GetString(0, &checked_str); |
124 bool accessibility_enabled = (checked_str == "true"); | 134 bool accessibility_enabled = (checked_str == "true"); |
125 | 135 |
126 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); | 136 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); |
127 } | 137 } |
138 | |
139 void SystemOptionsHandler::BluetoothEnableChangeCallback(const ListValue* args) | |
140 { | |
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
| |
141 // TODO (kevers) - Call Bluetooth API to enable or disable. | |
142 } | |
143 | |
144 void SystemOptionsHandler::FindBluetoothDevicesCallback(const ListValue* args) { | |
145 // TODO (kevers) - Call Bluetooth API to fetch devices. | |
146 // Generate a fake list until the bluetooth API is ready. | |
147 // Afterwards keep fake list only for cases where emulating | |
148 // ChromeOS from the desktop launch. | |
149 GenerateFakeDeviceList(); | |
150 } | |
151 | |
152 void SystemOptionsHandler::GenerateFakeDeviceList() { | |
153 // TODO (kevers) - Send notifications asynchronously simulating that the | |
154 // process of discovering bluetooth devices takes time. | |
155 // Fire each notification using OneShotTimer with a | |
156 // varying delay. | |
157 BluetoothDeviceNotification("Fake Wireless Keyboard", "01-02-03-04-05", | |
158 "keyboard", false); | |
159 BluetoothDeviceNotification("Fake Wireless Mouse", "02-03-04-05-01", | |
160 "mouse", false); | |
161 BluetoothDeviceNotification("Fake Wireless Headset", "03-04-05-01-02", | |
162 "headset", false); | |
163 | |
164 web_ui_->CallJavascriptFunction( | |
165 "options.SystemOptions.NotifyBluetoothSearchComplete"); | |
166 } | |
167 | |
168 void SystemOptionsHandler::BluetoothDeviceNotification( | |
169 const std::string& name, | |
170 const std::string& id, | |
171 const std::string& type, | |
172 bool connected) { | |
173 DictionaryValue device; | |
174 device.SetString("deviceName", name); | |
175 device.SetString("deviceId", id); | |
176 device.SetString("deviceType", type); | |
177 device.SetString("deviceStatus", connected ? "bluetoothDeviceConnected" : | |
178 "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
| |
179 web_ui_->CallJavascriptFunction( | |
180 "options.SystemOptions.AddBluetoothDevice", device); | |
181 } | |
182 | |
183 | |
OLD | NEW |