Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/feature_list.h" | |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/values.h" | 17 #include "base/values.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/common/chrome_features.h" | |
| 21 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 23 #include "chrome/grit/browser_resources.h" | 21 #include "chrome/grit/browser_resources.h" |
| 24 #include "chrome/grit/chromium_strings.h" | 22 #include "chrome/grit/chromium_strings.h" |
| 25 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 26 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 27 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 28 #include "content/public/browser/page_navigator.h" | 26 #include "content/public/browser/page_navigator.h" |
| 29 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 30 #include "content/public/browser/web_contents_delegate.h" | 28 #include "content/public/browser/web_contents_delegate.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 {"keyboardOverlayFocusAddressBar", IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR}, | 172 {"keyboardOverlayFocusAddressBar", IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR}, |
| 175 {"keyboardOverlayFocusAddressBarInSearchMode", | 173 {"keyboardOverlayFocusAddressBarInSearchMode", |
| 176 IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR_IN_SEARCH_MODE}, | 174 IDS_KEYBOARD_OVERLAY_FOCUS_ADDRESS_BAR_IN_SEARCH_MODE}, |
| 177 {"keyboardOverlayFocusBookmarks", IDS_KEYBOARD_OVERLAY_FOCUS_BOOKMARKS}, | 175 {"keyboardOverlayFocusBookmarks", IDS_KEYBOARD_OVERLAY_FOCUS_BOOKMARKS}, |
| 178 {"keyboardOverlayFocusShelf", IDS_KEYBOARD_OVERLAY_FOCUS_SHELF}, | 176 {"keyboardOverlayFocusShelf", IDS_KEYBOARD_OVERLAY_FOCUS_SHELF}, |
| 179 {"keyboardOverlayFocusNextPane", IDS_KEYBOARD_OVERLAY_FOCUS_NEXT_PANE}, | 177 {"keyboardOverlayFocusNextPane", IDS_KEYBOARD_OVERLAY_FOCUS_NEXT_PANE}, |
| 180 {"keyboardOverlayFocusPreviousPane", | 178 {"keyboardOverlayFocusPreviousPane", |
| 181 IDS_KEYBOARD_OVERLAY_FOCUS_PREVIOUS_PANE}, | 179 IDS_KEYBOARD_OVERLAY_FOCUS_PREVIOUS_PANE}, |
| 182 {"keyboardOverlayFocusToolbar", IDS_KEYBOARD_OVERLAY_FOCUS_TOOLBAR}, | 180 {"keyboardOverlayFocusToolbar", IDS_KEYBOARD_OVERLAY_FOCUS_TOOLBAR}, |
| 183 {"keyboardOverlayGoBack", IDS_KEYBOARD_OVERLAY_GO_BACK}, | 181 {"keyboardOverlayGoBack", IDS_KEYBOARD_OVERLAY_GO_BACK}, |
| 184 {"keyboardOverlayGoForward", IDS_KEYBOARD_OVERLAY_GO_FORWARD}, | 182 {"keyboardOverlayGoForward", IDS_KEYBOARD_OVERLAY_GO_FORWARD}, |
|
afakhry
2017/05/11 01:19:35
Please remove the above two entries if you don't n
ojan
2017/05/11 18:25:25
Done
michaelpg
2017/05/11 19:10:14
Oops, my drafts didn't get published. Ojan: these
michaelpg
2017/05/11 19:10:14
(These strings are still used by the alt keys, so
| |
| 185 {"keyboardOverlayHelp", IDS_KEYBOARD_OVERLAY_HELP}, | 183 {"keyboardOverlayHelp", IDS_KEYBOARD_OVERLAY_HELP}, |
| 186 {"keyboardOverlayHistory", IDS_KEYBOARD_OVERLAY_HISTORY}, | 184 {"keyboardOverlayHistory", IDS_KEYBOARD_OVERLAY_HISTORY}, |
| 187 {"keyboardOverlayHome", IDS_KEYBOARD_OVERLAY_HOME}, | 185 {"keyboardOverlayHome", IDS_KEYBOARD_OVERLAY_HOME}, |
| 188 {"keyboardOverlayIncreaseKeyBrightness", | 186 {"keyboardOverlayIncreaseKeyBrightness", |
| 189 IDS_KEYBOARD_OVERLAY_INCREASE_KEY_BRIGHTNESS}, | 187 IDS_KEYBOARD_OVERLAY_INCREASE_KEY_BRIGHTNESS}, |
| 190 {"keyboardOverlayInputUnicodeCharacters", | 188 {"keyboardOverlayInputUnicodeCharacters", |
| 191 IDS_KEYBOARD_OVERLAY_INPUT_UNICODE_CHARACTERS}, | 189 IDS_KEYBOARD_OVERLAY_INPUT_UNICODE_CHARACTERS}, |
| 192 {"keyboardOverlayInsert", IDS_KEYBOARD_OVERLAY_INSERT}, | 190 {"keyboardOverlayInsert", IDS_KEYBOARD_OVERLAY_INSERT}, |
| 193 {"keyboardOverlayJavascriptConsole", | 191 {"keyboardOverlayJavascriptConsole", |
| 194 IDS_KEYBOARD_OVERLAY_JAVASCRIPT_CONSOLE}, | 192 IDS_KEYBOARD_OVERLAY_JAVASCRIPT_CONSOLE}, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 base::UTF8ToUTF16(kLearnMoreURL)); | 307 base::UTF8ToUTF16(kLearnMoreURL)); |
| 310 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", | 308 source->AddBoolean("keyboardOverlayHasChromeOSDiamondKey", |
| 311 base::CommandLine::ForCurrentProcess()->HasSwitch( | 309 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 312 chromeos::switches::kHasChromeOSDiamondKey)); | 310 chromeos::switches::kHasChromeOSDiamondKey)); |
| 313 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", | 311 source->AddBoolean("keyboardOverlayTopRowKeysAreFunctionKeys", |
| 314 TopRowKeysAreFunctionKeys(profile)); | 312 TopRowKeysAreFunctionKeys(profile)); |
| 315 ash::Shell* shell = ash::Shell::Get(); | 313 ash::Shell* shell = ash::Shell::Get(); |
| 316 display::DisplayManager* display_manager = shell->display_manager(); | 314 display::DisplayManager* display_manager = shell->display_manager(); |
| 317 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", | 315 source->AddBoolean("keyboardOverlayIsDisplayUIScalingEnabled", |
| 318 display_manager->IsDisplayUIScalingEnabled()); | 316 display_manager->IsDisplayUIScalingEnabled()); |
| 319 source->AddBoolean( | |
| 320 "backspaceGoesBackFeatureEnabled", | |
| 321 base::FeatureList::IsEnabled(features::kBackspaceGoesBackFeature)); | |
| 322 source->SetJsonPath("strings.js"); | 317 source->SetJsonPath("strings.js"); |
| 323 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); | 318 source->AddResourcePath("keyboard_overlay.js", IDR_KEYBOARD_OVERLAY_JS); |
| 324 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); | 319 source->SetDefaultResource(IDR_KEYBOARD_OVERLAY_HTML); |
| 325 return source; | 320 return source; |
| 326 } | 321 } |
| 327 | 322 |
| 328 } // namespace | 323 } // namespace |
| 329 | 324 |
| 330 // The handler for Javascript messages related to the "keyboardoverlay" view. | 325 // The handler for Javascript messages related to the "keyboardoverlay" view. |
| 331 class KeyboardOverlayHandler | 326 class KeyboardOverlayHandler |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 | 422 |
| 428 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) | 423 KeyboardOverlayUI::KeyboardOverlayUI(content::WebUI* web_ui) |
| 429 : WebDialogUI(web_ui) { | 424 : WebDialogUI(web_ui) { |
| 430 Profile* profile = Profile::FromWebUI(web_ui); | 425 Profile* profile = Profile::FromWebUI(web_ui); |
| 431 web_ui->AddMessageHandler(base::MakeUnique<KeyboardOverlayHandler>(profile)); | 426 web_ui->AddMessageHandler(base::MakeUnique<KeyboardOverlayHandler>(profile)); |
| 432 | 427 |
| 433 // Set up the chrome://keyboardoverlay/ source. | 428 // Set up the chrome://keyboardoverlay/ source. |
| 434 content::WebUIDataSource::Add(profile, | 429 content::WebUIDataSource::Add(profile, |
| 435 CreateKeyboardOverlayUIHTMLSource(profile)); | 430 CreateKeyboardOverlayUIHTMLSource(profile)); |
| 436 } | 431 } |
| OLD | NEW |