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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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(
140 const ListValue* args) {
141 // TODO (kevers) - Call Bluetooth API to enable or disable.
142 }
143
144 void SystemOptionsHandler::FindBluetoothDevicesCallback(
145 const ListValue* args) {
146 // TODO (kevers) - Call Bluetooth API to fetch devices.
147 // Generate a fake list until the bluetooth API is ready.
148 // Afterwards keep fake list only for cases where emulating
149 // ChromeOS from the desktop launch.
150 GenerateFakeDeviceList();
151 }
152
153 void SystemOptionsHandler::BluetoothDeviceNotification(
154 const DictionaryValue& device) {
155 web_ui_->CallJavascriptFunction(
156 "options.SystemOptions.AddBluetoothDevice", device);
157 }
158
159 void SystemOptionsHandler::GenerateFakeDeviceList() {
160 // TODO (kevers) - Send notifications asynchronously simulating that the
161 // process of discovering bluetooth devices takes time.
162 // Fire each notification using OneShotTimer with a
163 // varying delay.
164 std::string data[9] = {
165 "Fake Wireless Keyboard", "01-02-03-04-05", "keyboard",
166 "Fake Wireless Mouse", "02-03-04-05-01", "mouse",
167 "Fake Wireless Headset", "03-04-05-01-02", "headset"};
168
169 for (int i = 0; i < 3; i++) {
170 DictionaryValue device;
171 device.SetString("deviceName", data[3*i]);
172 device.SetString("deviceId", data[3*i+1]);
173 device.SetString("deviceType", data[3*i+2]);
174 device.SetString("deviceStatus", "bluetoothDeviceNotPaired");
175 web_ui_->CallJavascriptFunction(
176 "options.SystemOptions.AddBluetoothDevice", device);
177 }
178 web_ui_->CallJavascriptFunction(
179 "options.SystemOptions.NotifyBluetoothSearchComplete");
180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698