| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 { "keyboardOverlayF5", IDS_KEYBOARD_OVERLAY_F5 }, | 71 { "keyboardOverlayF5", IDS_KEYBOARD_OVERLAY_F5 }, |
| 72 { "keyboardOverlayF6", IDS_KEYBOARD_OVERLAY_F6 }, | 72 { "keyboardOverlayF6", IDS_KEYBOARD_OVERLAY_F6 }, |
| 73 { "keyboardOverlayF7", IDS_KEYBOARD_OVERLAY_F7 }, | 73 { "keyboardOverlayF7", IDS_KEYBOARD_OVERLAY_F7 }, |
| 74 { "keyboardOverlayF8", IDS_KEYBOARD_OVERLAY_F8 }, | 74 { "keyboardOverlayF8", IDS_KEYBOARD_OVERLAY_F8 }, |
| 75 { "keyboardOverlayF9", IDS_KEYBOARD_OVERLAY_F9 }, | 75 { "keyboardOverlayF9", IDS_KEYBOARD_OVERLAY_F9 }, |
| 76 { "keyboardOverlayF10", IDS_KEYBOARD_OVERLAY_F10 }, | 76 { "keyboardOverlayF10", IDS_KEYBOARD_OVERLAY_F10 }, |
| 77 { "keyboardOverlayF11", IDS_KEYBOARD_OVERLAY_F11 }, | 77 { "keyboardOverlayF11", IDS_KEYBOARD_OVERLAY_F11 }, |
| 78 { "keyboardOverlayF12", IDS_KEYBOARD_OVERLAY_F12 }, | 78 { "keyboardOverlayF12", IDS_KEYBOARD_OVERLAY_F12 }, |
| 79 { "keyboardOverlayInsert", IDS_KEYBOARD_OVERLAY_INSERT }, | 79 { "keyboardOverlayInsert", IDS_KEYBOARD_OVERLAY_INSERT }, |
| 80 { "keyboardOverlayInstructions", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS }, | 80 { "keyboardOverlayInstructions", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS }, |
| 81 { "keyboardOverlayInstructionsWithSearch", | |
| 82 IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_WITH_SEARCH }, | |
| 83 { "keyboardOverlayInstructionsHide", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE }, | 81 { "keyboardOverlayInstructionsHide", IDS_KEYBOARD_OVERLAY_INSTRUCTIONS_HIDE }, |
| 84 { "keyboardOverlayActivateLastLauncherItem", | 82 { "keyboardOverlayActivateLastLauncherItem", |
| 85 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_LAUNCHER_ITEM }, | 83 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_LAUNCHER_ITEM }, |
| 86 { "keyboardOverlayActivateLastTab", IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_TAB }, | 84 { "keyboardOverlayActivateLastTab", IDS_KEYBOARD_OVERLAY_ACTIVATE_LAST_TAB }, |
| 87 { "keyboardOverlayActivateLauncherItem1", | 85 { "keyboardOverlayActivateLauncherItem1", |
| 88 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_1 }, | 86 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_1 }, |
| 89 { "keyboardOverlayActivateLauncherItem2", | 87 { "keyboardOverlayActivateLauncherItem2", |
| 90 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_2 }, | 88 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_2 }, |
| 91 { "keyboardOverlayActivateLauncherItem3", | 89 { "keyboardOverlayActivateLauncherItem3", |
| 92 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_3 }, | 90 IDS_KEYBOARD_OVERLAY_ACTIVATE_LAUNCHER_ITEM_3 }, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 | 230 |
| 233 std::string ModifierKeyToLabel(ModifierKey modifier) { | 231 std::string ModifierKeyToLabel(ModifierKey modifier) { |
| 234 for (size_t i = 0; i < arraysize(kModifierToLabels); ++i) { | 232 for (size_t i = 0; i < arraysize(kModifierToLabels); ++i) { |
| 235 if (modifier == kModifierToLabels[i].modifier) { | 233 if (modifier == kModifierToLabels[i].modifier) { |
| 236 return kModifierToLabels[i].label; | 234 return kModifierToLabels[i].label; |
| 237 } | 235 } |
| 238 } | 236 } |
| 239 return ""; | 237 return ""; |
| 240 } | 238 } |
| 241 | 239 |
| 242 ChromeWebUIDataSource* CreateKeyboardOverlayUIHTMLSource( | 240 ChromeWebUIDataSource* CreateKeyboardOverlayUIHTMLSource() { |
| 243 bool search_key_acts_as_function_key) { | |
| 244 ChromeWebUIDataSource* source = | 241 ChromeWebUIDataSource* source = |
| 245 new ChromeWebUIDataSource(chrome::kChromeUIKeyboardOverlayHost); | 242 new ChromeWebUIDataSource(chrome::kChromeUIKeyboardOverlayHost); |
| 246 | 243 |
| 247 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) { | 244 for (size_t i = 0; i < arraysize(kI18nContentToMessage); ++i) { |
| 248 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content, | 245 source->AddLocalizedString(kI18nContentToMessage[i].i18n_content, |
| 249 kI18nContentToMessage[i].message); | 246 kI18nContentToMessage[i].message); |
| 250 } | 247 } |
| 251 | 248 |
| 252 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL)); | 249 source->AddString("keyboardOverlayLearnMoreURL", UTF8ToUTF16(kLearnMoreURL)); |
| 253 source->AddString("keyboardSearchKeyActsAsFunctionKey", | |
| 254 search_key_acts_as_function_key ? "true" : "false"); | |
| 255 source->set_json_path("strings.js"); | 250 source->set_json_path("strings.js"); |
| 256 source->set_use_json_js_format_v2(); | 251 source->set_use_json_js_format_v2(); |
| 257 source->add_resource_path("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); | 252 source->add_resource_path("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); |
| 258 source->set_default_resource(IDR_KEYBOARD_OVERLAY_HTML); | 253 source->set_default_resource(IDR_KEYBOARD_OVERLAY_HTML); |
| 259 return source; | 254 return source; |
| 260 } | 255 } |
| 261 | 256 |
| 262 } // namespace | 257 } // namespace |
| 263 | 258 |
| 264 // The handler for Javascript messages related to the "keyboardoverlay" view. | 259 // The handler for Javascript messages related to the "keyboardoverlay" view. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // KeyboardOverlayUI | 355 // KeyboardOverlayUI |
| 361 // | 356 // |
| 362 //////////////////////////////////////////////////////////////////////////////// | 357 //////////////////////////////////////////////////////////////////////////////// |
| 363 | 358 |
| 364 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 359 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
| 365 : WebDialogUI(web_ui) { | 360 : WebDialogUI(web_ui) { |
| 366 Profile* profile = Profile::FromWebUI(web_ui); | 361 Profile* profile = Profile::FromWebUI(web_ui); |
| 367 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); | 362 KeyboardOverlayHandler* handler = new KeyboardOverlayHandler(profile); |
| 368 web_ui->AddMessageHandler(handler); | 363 web_ui->AddMessageHandler(handler); |
| 369 | 364 |
| 370 const bool search_key_acts_as_function_key = | |
| 371 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 372 switches::kEnableChromebookFunctionKey); | |
| 373 | |
| 374 // Set up the chrome://keyboardoverlay/ source. | 365 // Set up the chrome://keyboardoverlay/ source. |
| 375 ChromeURLDataManager::AddDataSource(profile, | 366 ChromeURLDataManager::AddDataSource(profile, |
| 376 CreateKeyboardOverlayUIHTMLSource(search_key_acts_as_function_key)); | 367 CreateKeyboardOverlayUIHTMLSource()); |
| 377 } | 368 } |
| OLD | NEW |