OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/chromeos/keyboard_overlay_ui.h" | 5 #include "chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 "main.html?answer=188743"; | 40 "main.html?answer=188743"; |
41 #else | 41 #else |
42 "http://support.google.com/chromeos/bin/answer.py?answer=183101"; | 42 "http://support.google.com/chromeos/bin/answer.py?answer=183101"; |
43 #endif | 43 #endif |
44 | 44 |
45 struct ModifierToLabel { | 45 struct ModifierToLabel { |
46 const ModifierKey modifier; | 46 const ModifierKey modifier; |
47 const char* label; | 47 const char* label; |
48 } kModifierToLabels[] = { | 48 } kModifierToLabels[] = { |
49 {chromeos::input_method::kSearchKey, "search"}, | 49 {chromeos::input_method::kSearchKey, "search"}, |
50 {chromeos::input_method::kLeftControlKey, "ctrl"}, | 50 {chromeos::input_method::kControlKey, "ctrl"}, |
51 {chromeos::input_method::kLeftAltKey, "alt"}, | 51 {chromeos::input_method::kAltKey, "alt"}, |
52 {chromeos::input_method::kVoidKey, "disabled"}, | 52 {chromeos::input_method::kVoidKey, "disabled"}, |
53 {chromeos::input_method::kCapsLockKey, "caps lock"}, | 53 {chromeos::input_method::kCapsLockKey, "caps lock"}, |
54 }; | 54 }; |
55 | 55 |
56 struct I18nContentToMessage { | 56 struct I18nContentToMessage { |
57 const char* i18n_content; | 57 const char* i18n_content; |
58 int message; | 58 int message; |
59 } kI18nContentToMessage[] = { | 59 } kI18nContentToMessage[] = { |
60 { "keyboardOverlayLearnMore", IDS_KEYBOARD_OVERLAY_LEARN_MORE }, | 60 { "keyboardOverlayLearnMore", IDS_KEYBOARD_OVERLAY_LEARN_MORE }, |
61 { "keyboardOverlayTitle", IDS_KEYBOARD_OVERLAY_TITLE }, | 61 { "keyboardOverlayTitle", IDS_KEYBOARD_OVERLAY_TITLE }, |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 web_ui()->CallJavascriptFunction("initKeyboardOverlayId", param); | 281 web_ui()->CallJavascriptFunction("initKeyboardOverlayId", param); |
282 } | 282 } |
283 | 283 |
284 void KeyboardOverlayHandler::GetLabelMap(const ListValue* args) { | 284 void KeyboardOverlayHandler::GetLabelMap(const ListValue* args) { |
285 DCHECK(profile_); | 285 DCHECK(profile_); |
286 PrefService* pref_service = profile_->GetPrefs(); | 286 PrefService* pref_service = profile_->GetPrefs(); |
287 typedef std::map<ModifierKey, ModifierKey> ModifierMap; | 287 typedef std::map<ModifierKey, ModifierKey> ModifierMap; |
288 ModifierMap modifier_map; | 288 ModifierMap modifier_map; |
289 modifier_map[chromeos::input_method::kSearchKey] = static_cast<ModifierKey>( | 289 modifier_map[chromeos::input_method::kSearchKey] = static_cast<ModifierKey>( |
290 pref_service->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo)); | 290 pref_service->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo)); |
291 modifier_map[chromeos::input_method::kLeftControlKey] = | 291 modifier_map[chromeos::input_method::kControlKey] = static_cast<ModifierKey>( |
292 static_cast<ModifierKey>( | 292 pref_service->GetInteger(prefs::kLanguageXkbRemapControlKeyTo)); |
293 pref_service->GetInteger(prefs::kLanguageXkbRemapControlKeyTo)); | 293 modifier_map[chromeos::input_method::kAltKey] = static_cast<ModifierKey>( |
294 modifier_map[chromeos::input_method::kLeftAltKey] = static_cast<ModifierKey>( | |
295 pref_service->GetInteger(prefs::kLanguageXkbRemapAltKeyTo)); | 294 pref_service->GetInteger(prefs::kLanguageXkbRemapAltKeyTo)); |
296 | 295 |
297 DictionaryValue dict; | 296 DictionaryValue dict; |
298 for (ModifierMap::const_iterator i = modifier_map.begin(); | 297 for (ModifierMap::const_iterator i = modifier_map.begin(); |
299 i != modifier_map.end(); ++i) { | 298 i != modifier_map.end(); ++i) { |
300 dict.SetString(ModifierKeyToLabel(i->first), ModifierKeyToLabel(i->second)); | 299 dict.SetString(ModifierKeyToLabel(i->first), ModifierKeyToLabel(i->second)); |
301 } | 300 } |
302 | 301 |
303 web_ui()->CallJavascriptFunction("initIdentifierMap", dict); | 302 web_ui()->CallJavascriptFunction("initIdentifierMap", dict); |
304 } | 303 } |
(...skipping 14 matching lines...) Expand all Loading... |
319 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 318 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
320 : WebDialogUI(web_ui) { | 319 : WebDialogUI(web_ui) { |
321 Profile* profile = Profile::FromWebUI(web_ui); | 320 Profile* profile = Profile::FromWebUI(web_ui); |
322 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); | 321 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); |
323 web_ui->AddMessageHandler(handler); | 322 web_ui->AddMessageHandler(handler); |
324 | 323 |
325 // Set up the chrome://keyboardoverlay/ source. | 324 // Set up the chrome://keyboardoverlay/ source. |
326 ChromeURLDataManager::AddDataSource(profile, | 325 ChromeURLDataManager::AddDataSource(profile, |
327 CreateKeyboardOverlayUIHTMLSource()); | 326 CreateKeyboardOverlayUIHTMLSource()); |
328 } | 327 } |
OLD | NEW |