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

Side by Side Diff: chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc

Issue 11415124: Add keyboard overlay help for the Search key as a Function key extended keyboard shortcuts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding Created 8 years 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
« no previous file with comments | « chrome/browser/resources/chromeos/keyboard_overlay.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h"
9 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 12 #include "base/values.h"
12 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 13 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
13 #include "chrome/browser/chromeos/input_method/xkeyboard.h" 14 #include "chrome/browser/chromeos/input_method/xkeyboard.h"
14 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 17 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
17 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" 18 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
19 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/jstemplate_builder.h" 20 #include "chrome/common/jstemplate_builder.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
21 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/page_navigator.h" 24 #include "content/public/browser/page_navigator.h"
23 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_delegate.h" 26 #include "content/public/browser/web_contents_delegate.h"
25 #include "content/public/browser/web_ui.h" 27 #include "content/public/browser/web_ui.h"
26 #include "content/public/browser/web_ui_message_handler.h" 28 #include "content/public/browser/web_ui_message_handler.h"
27 #include "grit/browser_resources.h" 29 #include "grit/browser_resources.h"
(...skipping 26 matching lines...) Expand all
54 {chromeos::input_method::kVoidKey, "disabled"}, 56 {chromeos::input_method::kVoidKey, "disabled"},
55 {chromeos::input_method::kCapsLockKey, "caps lock"}, 57 {chromeos::input_method::kCapsLockKey, "caps lock"},
56 }; 58 };
57 59
58 struct I18nContentToMessage { 60 struct I18nContentToMessage {
59 const char* i18n_content; 61 const char* i18n_content;
60 int message; 62 int message;
61 } kI18nContentToMessage[] = { 63 } kI18nContentToMessage[] = {
62 { "keyboardOverlayLearnMore", IDS_KEYBOARD_OVERLAY_LEARN_MORE }, 64 { "keyboardOverlayLearnMore", IDS_KEYBOARD_OVERLAY_LEARN_MORE },
63 { "keyboardOverlayTitle", IDS_KEYBOARD_OVERLAY_TITLE }, 65 { "keyboardOverlayTitle", IDS_KEYBOARD_OVERLAY_TITLE },
66 { "keyboardOverlayF1", IDS_KEYBOARD_OVERLAY_F1 },
67 { "keyboardOverlayF2", IDS_KEYBOARD_OVERLAY_F2 },
68 { "keyboardOverlayF3", IDS_KEYBOARD_OVERLAY_F3 },
69 { "keyboardOverlayF4", IDS_KEYBOARD_OVERLAY_F4 },
70 { "keyboardOverlayF5", IDS_KEYBOARD_OVERLAY_F5 },
71 { "keyboardOverlayF6", IDS_KEYBOARD_OVERLAY_F6 },
72 { "keyboardOverlayF7", IDS_KEYBOARD_OVERLAY_F7 },
73 { "keyboardOverlayF8", IDS_KEYBOARD_OVERLAY_F8 },
74 { "keyboardOverlayF9", IDS_KEYBOARD_OVERLAY_F9 },
75 { "keyboardOverlayF10", IDS_KEYBOARD_OVERLAY_F10 },
76 { "keyboardOverlayF11", IDS_KEYBOARD_OVERLAY_F11 },
77 { "keyboardOverlayF12", IDS_KEYBOARD_OVERLAY_F12 },
64 { "keyboardOverlayInstructions", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS }, 78 { "keyboardOverlayInstructions", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS },
79 { "keyboardOverlayInstructionsWithSearch",
80 IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_WITH_SEARCH },
65 { "keyboardOverlayInstructionsHide", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE }, 81 { "keyboardOverlayInstructionsHide", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE },
66 { "keyboardOverlayActivateLastLauncherItem", 82 { "keyboardOverlayActivateLastLauncherItem",
67 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_LAUNCHER_ITEM }, 83 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_LAUNCHER_ITEM },
68 { "keyboardOverlayActivateLastTab", IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_TAB }, 84 { "keyboardOverlayActivateLastTab", IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_TAB },
69 { "keyboardOverlayActivateLauncherItem1", 85 { "keyboardOverlayActivateLauncherItem1",
70 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_1 }, 86 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_1 },
71 { "keyboardOverlayActivateLauncherItem2", 87 { "keyboardOverlayActivateLauncherItem2",
72 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_2 }, 88 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_2 },
73 { "keyboardOverlayActivateLauncherItem3", 89 { "keyboardOverlayActivateLauncherItem3",
74 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_3 }, 90 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_3 },
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 231
216 std::string ModifierKeyToLabel(ModifierKey modifier) { 232 std::string ModifierKeyToLabel(ModifierKey modifier) {
217 for (size_t i = 0; i < arraysize(kModifierToLabels); ++i) { 233 for (size_t i = 0; i < arraysize(kModifierToLabels); ++i) {
218 if (modifier == kModifierToLabels[i].modifier) { 234 if (modifier == kModifierToLabels[i].modifier) {
219 return kModifierToLabels[i].label; 235 return kModifierToLabels[i].label;
220 } 236 }
221 } 237 }
222 return ""; 238 return "";
223 } 239 }
224 240
225 ChromeWebUIDataSource* CreateKeyboardOverlayUIHTMLSource() { 241 ChromeWebUIDataSource* CreateKeyboardOverlayUIHTMLSource(
242 bool search_key_acts_as_function_key) {
226 ChromeWebUIDataSource* source = 243 ChromeWebUIDataSource* source =
227 new ChromeWebUIDataSource(chrome::kChromeUIKeyboardOverlayHost); 244 new ChromeWebUIDataSource(chrome::kChromeUIKeyboardOverlayHost);
228 245
229 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) { 246 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) {
230 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content, 247 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content,
231 kI18nContentToMessage[i].message); 248 kI18nContentToMessage[i].message);
232 } 249 }
233 250
234 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL)); 251 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL));
252 source->AddString("keyboardSearchKeyActsAsFunctionKey",
253 search_key_acts_as_function_key ? "true" : "false");
235 source->set_json_path("strings.js"); 254 source->set_json_path("strings.js");
236 source->set_use_json_js_format_v2(); 255 source->set_use_json_js_format_v2();
237 source->add_resource_path("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); 256 source->add_resource_path("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS);
238 source->set_default_resource(IDR_KEYBOARD_OVERLAY_HTML); 257 source->set_default_resource(IDR_KEYBOARD_OVERLAY_HTML);
239 return source; 258 return source;
240 } 259 }
241 260
242 } // namespace 261 } // namespace
243 262
244 // The handler for Javascript messages related to the "keyboardoverlay" view. 263 // The handler for Javascript messages related to the "keyboardoverlay" view.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // KeyboardOverlayUI 359 // KeyboardOverlayUI
341 // 360 //
342 //////////////////////////////////////////////////////////////////////////////// 361 ////////////////////////////////////////////////////////////////////////////////
343 362
344 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) 363 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui)
345 : WebDialogUI(web_ui) { 364 : WebDialogUI(web_ui) {
346 Profile* profile = Profile::FromWebUI(web_ui); 365 Profile* profile = Profile::FromWebUI(web_ui);
347 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); 366 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile);
348 web_ui->AddMessageHandler(handler); 367 web_ui->AddMessageHandler(handler);
349 368
369 PrefService* pref_service = profile->GetPrefs();
370 bool chromebook_function_key = CommandLine::ForCurrentProcess()->HasSwitch(
371 switches::kEnableChromebookFunctionKey);
372 bool chromeos_keyboard = CommandLine::ForCurrentProcess()->HasSwitch(
373 switches::kHasChromeOSKeyboard);
374
375 bool search_key_acts_as_function_key = chromeos_keyboard &&
376 chromebook_function_key &&
377 pref_service->GetBoolean(prefs::kLanguageSearchKeyActsAsFunctionKey);
378
350 // Set up the chrome://keyboardoverlay/ source. 379 // Set up the chrome://keyboardoverlay/ source.
351 ChromeURLDataManager::AddDataSource(profile, 380 ChromeURLDataManager::AddDataSource(profile,
352 CreateKeyboardOverlayUIHTMLSource()); 381 CreateKeyboardOverlayUIHTMLSource(search_key_acts_as_function_key));
353 } 382 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/keyboard_overlay.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698