Commit d4c50080 authored by wutao's avatar wutao Committed by Commit Bot

cros: Add missing shortcuts to Keyboard Shortcut Viewer

This cl adds the followings to Keyboard Shortcut Viewer (KSV):
1. Adds 21 more shortcuts.
2. Test to check changes of Chrome OS available shortcuts.

Bug: 823946
Test: KeyboardShortcutViewerMetadataTest.ModifyAcceleratorShouldUpdateMetadata
Change-Id: I6ae8ef9cb573828eb77210dfea8d57a32b2d8400
Reviewed-on: https://chromium-review.googlesource.com/981440
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#546981}
parent 85896467
...@@ -321,7 +321,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -321,7 +321,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
ui::VKEY_G, ui::VKEY_SHIFT, ui::VKEY_UNKNOWN, ui::VKEY_RETURN}}, ui::VKEY_G, ui::VKEY_SHIFT, ui::VKEY_UNKNOWN, ui::VKEY_RETURN}},
{// |categories| {// |categories|
{ShortcutCategory::kAccessibility}, {ShortcutCategory::kPageAndBrowser, ShortcutCategory::kAccessibility},
IDS_KSV_DESCRIPTION_IDC_FOCUS_BOOKMARKS, IDS_KSV_DESCRIPTION_IDC_FOCUS_BOOKMARKS,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY, IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids| // |accelerator_ids|
...@@ -410,11 +410,14 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -410,11 +410,14 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
{{ui::VKEY_P, ui::EF_CONTROL_DOWN}}}, {{ui::VKEY_P, ui::EF_CONTROL_DOWN}}},
{// |categories| {// |categories|
{ShortcutCategory::kPageAndBrowser}, {ShortcutCategory::kPopular, ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_IDC_RELOAD, IDS_KSV_DESCRIPTION_IDC_RELOAD,
IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY, IDS_KSV_SHORTCUT_IDC_RELOAD,
// |accelerator_ids| // |accelerator_ids|
{{ui::VKEY_R, ui::EF_CONTROL_DOWN}}}, {},
// |shortcut_key_codes|
{ui::VKEY_BROWSER_REFRESH, ui::VKEY_CONTROL, ui::VKEY_UNKNOWN,
ui::VKEY_R}},
{// |categories| {// |categories|
{ShortcutCategory::kPageAndBrowser}, {ShortcutCategory::kPageAndBrowser},
...@@ -510,7 +513,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -510,7 +513,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
{{ui::VKEY_OEM_PLUS, ui::EF_CONTROL_DOWN}}}, {{ui::VKEY_OEM_PLUS, ui::EF_CONTROL_DOWN}}},
{// |categories| {// |categories|
{ShortcutCategory::kTextEditing}, {ShortcutCategory::kSystemAndDisplay, ShortcutCategory::kTextEditing},
IDS_KSV_DESCRIPTION_NEXT_IME, IDS_KSV_DESCRIPTION_NEXT_IME,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY, IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids| // |accelerator_ids|
...@@ -524,7 +527,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -524,7 +527,7 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
{{ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN}}}, {{ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN}}},
{// |categories| {// |categories|
{ShortcutCategory::kTextEditing}, {ShortcutCategory::kSystemAndDisplay, ShortcutCategory::kTextEditing},
IDS_KSV_DESCRIPTION_PREVIOUS_IME, IDS_KSV_DESCRIPTION_PREVIOUS_IME,
IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY, IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY,
// |accelerator_ids| // |accelerator_ids|
...@@ -655,15 +658,6 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -655,15 +658,6 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
// |shortcut_key_codes| // |shortcut_key_codes|
{ui::VKEY_CONTROL, ui::VKEY_UNKNOWN}}, {ui::VKEY_CONTROL, ui::VKEY_UNKNOWN}},
{// |categories|
{ShortcutCategory::kPopular, ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_IDC_RELOAD,
IDS_KSV_SHORTCUT_ONE_KEY,
// |accelerator_ids|
{},
// |shortcut_key_codes|
{ui::VKEY_BROWSER_REFRESH}},
{// |categories| {// |categories|
{ShortcutCategory::kPopular}, {ShortcutCategory::kPopular},
IDS_KSV_DESCRIPTION_KEYBOARD_SHORTCUT_HELPER, IDS_KSV_DESCRIPTION_KEYBOARD_SHORTCUT_HELPER,
...@@ -1128,6 +1122,156 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() { ...@@ -1128,6 +1122,156 @@ const std::vector<KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY, IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids| // |accelerator_ids|
{{ui::VKEY_M, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN}}}, {{ui::VKEY_M, ui::EF_COMMAND_DOWN | ui::EF_ALT_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_TOGGLE_APP_LIST,
IDS_KSV_SHORTCUT_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_LWIN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_TAKE_WINDOW_SCREENSHOT,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_SUSPEND,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_COMMAND_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_OPEN_GET_HELP,
IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_OEM_2, ui::EF_CONTROL_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_OPEN_FEEDBACK_PAGE,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_I, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_ROTATE_WINDOW,
IDS_KSV_SHORTCUT_THREE_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_BROWSER_REFRESH,
ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_SHOW_STYLUS_TOOLS,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_P, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_TOGGLE_MAXIMIZED,
IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_WINDOW_POSITION_CENTER,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_OEM_PLUS, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_OPEN_CROSH,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_T, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN}}},
{// |categories|
{ShortcutCategory::kAccessibility},
IDS_KSV_DESCRIPTION_TOGGLE_DICTATION,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_S, ui::EF_SHIFT_DOWN | ui::EF_COMMAND_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_EXIT,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_Q, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kTabAndWindow},
IDS_KSV_DESCRIPTION_UNPIN,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN | ui::EF_COMMAND_DOWN}}},
{// |categories|
{ShortcutCategory::kSystemAndDisplay},
IDS_KSV_DESCRIPTION_SHOW_IME_MENU_BUBBLE,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_K, ui::EF_SHIFT_DOWN | ui::EF_COMMAND_DOWN}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_SHOW_IDC_FOCUS_MENU_BAR,
IDS_KSV_SHORTCUT_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_F10}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_SHOW_IDC_HOME,
IDS_KSV_SHORTCUT_ONE_MODIFIER_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_HOME, ui::EF_ALT_DOWN}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_SHOW_IDC_CLEAR_BROWSING_DATA,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_BACK, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_SHOW_IDC_SHOW_BOOKMARK_MANAGER,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_O, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_IDC_DEV_TOOLS_INSPECT,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_C, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kAccessibility},
IDS_KSV_DESCRIPTION_IDC_FOCUS_INACTIVE_POPUP_FOR_ACCESSIBILITY,
IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY,
// |accelerator_ids|
{{ui::VKEY_A, ui::EF_ALT_DOWN | ui::EF_SHIFT_DOWN}}},
{// |categories|
{ShortcutCategory::kPageAndBrowser},
IDS_KSV_DESCRIPTION_IDC_SHOW_APP_MENU,
IDS_KSV_SHORTCUT_IDC_SHOW_APP_MENU,
// |accelerator_ids|
{},
// |shortcut_key_codes|
{ui::VKEY_LMENU, ui::VKEY_UNKNOWN, ui::VKEY_E, ui::VKEY_F}},
}); });
static bool is_initialized = false; static bool is_initialized = false;
......
...@@ -91,13 +91,16 @@ ...@@ -91,13 +91,16 @@
<message name="IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY" desc="Human readable version of the keyboard shortcut. This is for all two modifiers shortcuts."> <message name="IDS_KSV_SHORTCUT_TWO_MODIFIERS_ONE_KEY" desc="Human readable version of the keyboard shortcut. This is for all two modifiers shortcuts.">
<ph name="modifier1">$1<ex>Ctrl</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="modifier2">$3<ex>Alt</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="key">$5<ex>v</ex></ph> <ph name="modifier1">$1<ex>Ctrl</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="modifier2">$3<ex>Alt</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="key">$5<ex>v</ex></ph>
</message> </message>
<message name="IDS_KSV_SHORTCUT_THREE_MODIFIERS_ONE_KEY" desc="Human readable version of the keyboard shortcut. This is for all two modifiers shortcuts.">
<ph name="modifier1">$1<ex>Ctrl</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="modifier2">$3<ex>Alt</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="modifier3">$5<ex>Shift</ex></ph><ph name="separator3">$6<ex>+</ex></ph><ph name="key">$7<ex>v</ex></ph>
</message>
<!-- Shortcuts descriptions --> <!-- Shortcuts descriptions -->
<message name="IDS_KSV_DESCRIPTION_LOCK_SCREEN" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_LOCK_SCREEN" desc="Description of the command in keyboard shortcut viewer.">
Lock screen Lock screen
</message> </message>
<message name="IDS_KSV_DESCRIPTION_CHANGE_SCREEN_RESOLUTION" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_CHANGE_SCREEN_RESOLUTION" desc="Description of the command in keyboard shortcut viewer.">
Change screen resolution Make items on your screen larger or smaller
</message> </message>
<message name="IDS_KSV_SHORTCUT_CHANGE_SCREEN_RESOLUTION" desc="Human readable version of the keyboard shortcut."> <message name="IDS_KSV_SHORTCUT_CHANGE_SCREEN_RESOLUTION" desc="Human readable version of the keyboard shortcut.">
<ph name="ctrl">$1<ex>Ctrl</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="shift">$3<ex>Shift</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="plus">$5<ex>v</ex></ph> or <ph name="minus">$6<ex>v</ex></ph> <ph name="ctrl">$1<ex>Ctrl</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="shift">$3<ex>Shift</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="plus">$5<ex>v</ex></ph> or <ph name="minus">$6<ex>v</ex></ph>
...@@ -115,7 +118,7 @@ ...@@ -115,7 +118,7 @@
<ph name="shift">$1<ex>Shift</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="alt">$3<ex>Alt</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="l">$5<ex>v</ex></ph>, then <ph name="tab">$6<ex>v</ex></ph> or <ph name="right">$7<ex>v</ex></ph> <ph name="shift">$1<ex>Shift</ex></ph><ph name="separator1">$2<ex>+</ex></ph><ph name="alt">$3<ex>Alt</ex></ph><ph name="separator2">$4<ex>+</ex></ph><ph name="l">$5<ex>v</ex></ph>, then <ph name="tab">$6<ex>v</ex></ph> or <ph name="right">$7<ex>v</ex></ph>
</message> </message>
<message name="IDS_KSV_DESCRIPTION_PREVIOUS_IME" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_PREVIOUS_IME" desc="Description of the command in keyboard shortcut viewer.">
Switch to the previous keyboard language you were using. Switch to the previous language input method
</message> </message>
<message name="IDS_KSV_DESCRIPTION_CYCLE_FORWARD_MRU" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_CYCLE_FORWARD_MRU" desc="Description of the command in keyboard shortcut viewer.">
Switch quickly between windows Switch quickly between windows
...@@ -163,7 +166,7 @@ ...@@ -163,7 +166,7 @@
Turn Caps Lock on and off Turn Caps Lock on and off
</message> </message>
<message name="IDS_KSV_DESCRIPTION_NEXT_IME" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_NEXT_IME" desc="Description of the command in keyboard shortcut viewer.">
Switch between the keyboard languages you've set. Learn how to choose your keyboard language. Switch to the next language input method
</message> </message>
<message name="IDS_KSV_DESCRIPTION_NEW_WINDOW" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_NEW_WINDOW" desc="Description of the command in keyboard shortcut viewer.">
Open new window Open new window
...@@ -237,6 +240,9 @@ ...@@ -237,6 +240,9 @@
<message name="IDS_KSV_DESCRIPTION_IDC_RELOAD" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_IDC_RELOAD" desc="Description of the command in keyboard shortcut viewer.">
Reload your current page Reload your current page
</message> </message>
<message name="IDS_KSV_SHORTCUT_IDC_RELOAD" desc="Description of the command in keyboard shortcut viewer.">
<ph name="refresh">$1<ex>Refresh</ex></ph> or <ph name="ctrl">$2<ex>Ctrl</ex></ph><ph name="separator">$3<ex>+</ex></ph><ph name="r">$4<ex>r</ex></ph>
</message>
<message name="IDS_KSV_DESCRIPTION_IDC_RELOAD_BYPASSING_CACHE" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_IDC_RELOAD_BYPASSING_CACHE" desc="Description of the command in keyboard shortcut viewer.">
Reload your current page without using cached content Reload your current page without using cached content
</message> </message>
...@@ -277,10 +283,10 @@ ...@@ -277,10 +283,10 @@
Show or hide the Developer Tools panel Show or hide the Developer Tools panel
</message> </message>
<message name="IDS_KSV_DESCRIPTION_IDC_DEV_TOOLS_CONSOLE" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_IDC_DEV_TOOLS_CONSOLE" desc="Description of the command in keyboard shortcut viewer.">
Show or hide the DOM Inspector Show or hide the Developer Tools console
</message> </message>
<message name="IDS_KSV_DESCRIPTION_IDC_FOCUS_BOOKMARKS" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_IDC_FOCUS_BOOKMARKS" desc="Description of the command in keyboard shortcut viewer.">
Highlight the bookmarks bar (if shown) Focus on or Highlight the bookmarks bar (if shown)
</message> </message>
<message name="IDS_KSV_DESCRIPTION_IDC_FOCUS_SEARCH" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_IDC_FOCUS_SEARCH" desc="Description of the command in keyboard shortcut viewer.">
Place focus in search address bar Place focus in search address bar
...@@ -531,5 +537,70 @@ ...@@ -531,5 +537,70 @@
<message name="IDS_KSV_DESCRIPTION_MOVE_ACTIVE_WINDOW_BETWEEN_DISPLAYS" desc="Description of the command in keyboard shortcut viewer."> <message name="IDS_KSV_DESCRIPTION_MOVE_ACTIVE_WINDOW_BETWEEN_DISPLAYS" desc="Description of the command in keyboard shortcut viewer.">
Move active window between displays Move active window between displays
</message> </message>
<message name="IDS_KSV_DESCRIPTION_TOGGLE_APP_LIST" desc="Description of the command in keyboard shortcut viewer.">
Open/close the launcher
</message>
<message name="IDS_KSV_DESCRIPTION_TAKE_WINDOW_SCREENSHOT" desc="Description of the command in keyboard shortcut viewer.">
Take window screenshot
</message>
<message name="IDS_KSV_DESCRIPTION_SUSPEND" desc="Description of the command in keyboard shortcut viewer.">
Put device in sleep mode (suspend)
</message>
<message name="IDS_KSV_DESCRIPTION_OPEN_GET_HELP" desc="Description of the command in keyboard shortcut viewer.">
Open Help Center
</message>
<message name="IDS_KSV_DESCRIPTION_OPEN_FEEDBACK_PAGE" desc="Description of the command in keyboard shortcut viewer.">
Submit feedback
</message>
<message name="IDS_KSV_DESCRIPTION_ROTATE_WINDOW" desc="Description of the command in keyboard shortcut viewer.">
Rotate window
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_STYLUS_TOOLS" desc="Description of the command in keyboard shortcut viewer.">
Show stylus tools
</message>
<message name="IDS_KSV_DESCRIPTION_TOGGLE_MAXIMIZED" desc="Description of the command in keyboard shortcut viewer.">
Maximize window
</message>
<message name="IDS_KSV_DESCRIPTION_WINDOW_POSITION_CENTER" desc="Description of the command in keyboard shortcut viewer.">
Move window to center
</message>
<message name="IDS_KSV_DESCRIPTION_OPEN_CROSH" desc="Description of the command in keyboard shortcut viewer.">
Open Crosh window
</message>
<message name="IDS_KSV_DESCRIPTION_TOGGLE_DICTATION" desc="Description of the command in keyboard shortcut viewer.">
Starts or stops dictation (type what you speak)
</message>
<message name="IDS_KSV_DESCRIPTION_EXIT" desc="Description of the command in keyboard shortcut viewer.">
Sign out
</message>
<message name="IDS_KSV_DESCRIPTION_UNPIN" desc="Description of the command in keyboard shortcut viewer.">
Unpin an app
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_IME_MENU_BUBBLE" desc="Description of the command in keyboard shortcut viewer.">
Show the menu displaying a list of available IMEs
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_IDC_FOCUS_MENU_BAR" desc="Description of the command in keyboard shortcut viewer.">
Place focus on menu bar
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_IDC_HOME" desc="Description of the command in keyboard shortcut viewer.">
Open home page
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_IDC_CLEAR_BROWSING_DATA" desc="Description of the command in keyboard shortcut viewer.">
Clear browsing data
</message>
<message name="IDS_KSV_DESCRIPTION_SHOW_IDC_SHOW_BOOKMARK_MANAGER" desc="Description of the command in keyboard shortcut viewer.">
Show bookmark manager
</message>
<message name="IDS_KSV_DESCRIPTION_IDC_DEV_TOOLS_INSPECT" desc="Description of the command in keyboard shortcut viewer.">
Show or hide the Developer Tools inspector
</message>
<message name="IDS_KSV_DESCRIPTION_IDC_FOCUS_INACTIVE_POPUP_FOR_ACCESSIBILITY" desc="Description of the command in keyboard shortcut viewer.">
Focus inactive popup for accessibility
</message>
<message name="IDS_KSV_DESCRIPTION_IDC_SHOW_APP_MENU" desc="Description of the command in keyboard shortcut viewer.">
Show app menu
</message>
<message name="IDS_KSV_SHORTCUT_IDC_SHOW_APP_MENU" desc="Description of the command in keyboard shortcut viewer.">
<ph name="alt">$1<ex>Alt</ex></ph><ph name="separator">$2<ex>+</ex></ph><ph name="e">$3<ex>e</ex></ph> or <ph name="f">$4<ex>f</ex></ph>
</message>
</grit-part> </grit-part>
...@@ -4,12 +4,14 @@ ...@@ -4,12 +4,14 @@
#include <set> #include <set>
#include <string> #include <string>
#include <tuple>
#include <vector> #include <vector>
#include "ash/accelerators/accelerator_table.h" #include "ash/accelerators/accelerator_table.h"
#include "ash/components/shortcut_viewer/keyboard_shortcut_item.h" #include "ash/components/shortcut_viewer/keyboard_shortcut_item.h"
#include "ash/components/shortcut_viewer/keyboard_shortcut_viewer_metadata.h" #include "ash/components/shortcut_viewer/keyboard_shortcut_viewer_metadata.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/md5.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/ui/views/accelerator_table.h" #include "chrome/browser/ui/views/accelerator_table.h"
...@@ -17,14 +19,86 @@ ...@@ -17,14 +19,86 @@
namespace { namespace {
// The total number of Ash accelerators.
constexpr int kAshAcceleratorsTotalNum = 98;
// The hash of Ash accelerators.
constexpr char kAshAcceleratorsHash[] = "71c96531d7639ba0ecf255a59546c243";
// The total number of Chrome accelerators (available on Chrome OS).
constexpr int kChromeAcceleratorsTotalNum = 91;
// The hash of Chrome accelerators (available on Chrome OS).
constexpr char kChromeAcceleratorsHash[] = "cde825b73b85f0ff34a1ff78086e61c8";
const char* BooleanToString(bool value) {
return value ? "true" : "false";
}
std::string ModifiersToString(int modifiers) {
return base::StringPrintf("shift=%s control=%s alt=%s search=%s",
BooleanToString(modifiers & ui::EF_SHIFT_DOWN),
BooleanToString(modifiers & ui::EF_CONTROL_DOWN),
BooleanToString(modifiers & ui::EF_ALT_DOWN),
BooleanToString(modifiers & ui::EF_COMMAND_DOWN));
}
std::string AshAcceleratorDataToString(
const ash::AcceleratorData& accelerator) {
return base::StringPrintf("trigger_on_press=%s keycode=%d action=%d ",
BooleanToString(accelerator.trigger_on_press),
accelerator.keycode, accelerator.action) +
ModifiersToString(accelerator.modifiers);
}
std::string ChromeAcceleratorMappingToString(
const AcceleratorMapping& accelerator) {
return base::StringPrintf("keycode=%d command_id=%d ", accelerator.keycode,
accelerator.command_id) +
ModifiersToString(accelerator.modifiers);
}
struct AshAcceleratorDataCmp {
bool operator()(const ash::AcceleratorData& lhs,
const ash::AcceleratorData& rhs) {
return std::tie(lhs.trigger_on_press, lhs.keycode, lhs.modifiers) <
std::tie(rhs.trigger_on_press, rhs.keycode, rhs.modifiers);
}
};
struct ChromeAcceleratorMappingCmp {
bool operator()(const AcceleratorMapping& lhs,
const AcceleratorMapping& rhs) {
return std::tie(lhs.keycode, lhs.modifiers) <
std::tie(rhs.keycode, rhs.modifiers);
}
};
std::string HashAshAcceleratorData(
const std::vector<ash::AcceleratorData> accelerators) {
base::MD5Context context;
base::MD5Init(&context);
for (const auto& accelerator : accelerators)
base::MD5Update(&context, AshAcceleratorDataToString(accelerator));
base::MD5Digest digest;
base::MD5Final(&digest, &context);
return MD5DigestToBase16(digest);
}
std::string HashChromeAcceleratorMapping(
const std::vector<AcceleratorMapping> accelerators) {
base::MD5Context context;
base::MD5Init(&context);
for (const auto& accelerator : accelerators)
base::MD5Update(&context, ChromeAcceleratorMappingToString(accelerator));
base::MD5Digest digest;
base::MD5Final(&digest, &context);
return MD5DigestToBase16(digest);
}
std::string AcceleratorIdToString( std::string AcceleratorIdToString(
const keyboard_shortcut_viewer::AcceleratorId& accelerator_id) { const keyboard_shortcut_viewer::AcceleratorId& accelerator_id) {
return base::StringPrintf( return base::StringPrintf("keycode=%d ", accelerator_id.keycode) +
"keycode=%d shift=%s control=%s alt=%s search=%s", accelerator_id.keycode, ModifiersToString(accelerator_id.modifiers);
(accelerator_id.modifiers & ui::EF_SHIFT_DOWN) ? "true" : "false",
(accelerator_id.modifiers & ui::EF_CONTROL_DOWN) ? "true" : "false",
(accelerator_id.modifiers & ui::EF_ALT_DOWN) ? "true" : "false",
(accelerator_id.modifiers & ui::EF_COMMAND_DOWN) ? "true" : "false");
} }
std::string AcceleratorIdsToString( std::string AcceleratorIdsToString(
...@@ -118,3 +192,53 @@ TEST_F(KeyboardShortcutViewerMetadataTest, ...@@ -118,3 +192,53 @@ TEST_F(KeyboardShortcutViewerMetadataTest,
} }
} }
} }
// Test that modifying Ash/Chrome accelerator should update
// KeyboardShortcutViewerMetadata. (https://crbug.com/826037).
// 1. If you are adding/deleting/modifying shortcuts, please also
// add/delete/modify the corresponding strings and items to the list of
// KeyboardShortcutItem.
// 2. Please update the number and hash value of Ash/Chrome accelerators (these
// available on Chrome OS) on the top of this file. The new number and hash
// value will be provided in the test output.
// 3. If there is no corrensponding item in the Keyboard Shortcut Viewer, please
// consider adding the shortcut to it or only update 2.
TEST_F(KeyboardShortcutViewerMetadataTest,
ModifyAcceleratorShouldUpdateMetadata) {
std::vector<ash::AcceleratorData> ash_accelerators;
std::vector<AcceleratorMapping> chrome_accelerators;
for (size_t i = 0; i < ash::kAcceleratorDataLength; ++i)
ash_accelerators.emplace_back(ash::kAcceleratorData[i]);
for (const auto& accel_mapping : GetAcceleratorList())
chrome_accelerators.emplace_back(accel_mapping);
const char kCommonMessage[] =
"If you are modifying Chrome OS available shortcuts, please update "
"Keyboard Shortcut Viewer shortcuts and the following value(s) on the "
"top of this file:\n";
const int ash_accelerators_number = ash_accelerators.size();
EXPECT_TRUE(ash_accelerators_number == kAshAcceleratorsTotalNum)
<< kCommonMessage
<< "kAshAcceleratorsTotalNum=" << ash_accelerators_number << "\n";
std::stable_sort(ash_accelerators.begin(), ash_accelerators.end(),
AshAcceleratorDataCmp());
const std::string ash_accelerators_hash =
HashAshAcceleratorData(ash_accelerators);
EXPECT_TRUE(ash_accelerators_hash == kAshAcceleratorsHash)
<< kCommonMessage << "kAshAcceleratorsHash=\"" << ash_accelerators_hash
<< "\"\n";
const int chrome_accelerators_number = chrome_accelerators.size();
EXPECT_TRUE(chrome_accelerators_number == kChromeAcceleratorsTotalNum)
<< kCommonMessage
<< "kChromeAcceleratorsTotalNum=" << chrome_accelerators_number << "\n";
std::stable_sort(chrome_accelerators.begin(), chrome_accelerators.end(),
ChromeAcceleratorMappingCmp());
const std::string chrome_accelerators_hash =
HashChromeAcceleratorMapping(chrome_accelerators);
EXPECT_TRUE(chrome_accelerators_hash == kChromeAcceleratorsHash)
<< kCommonMessage << "kChromeAcceleratorsHash=\""
<< chrome_accelerators_hash << "\"\n";
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment