capture-mode-demo-tools: Extract accelerators APIs
Extract the accelerators APIs in ash/accelerators so that they can be reused in ash/*. Change-Id: Ib9e6e4aa5e6e7b474f2cd82d645938f42bdb6b49 Bug: b:252343558 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3964789 Commit-Queue: Michele Fan <michelefan@chromium.org> Reviewed-by: Ahmed Fakhry <afakhry@chromium.org> Reviewed-by: Tony Yeoman <tby@chromium.org> Cr-Commit-Position: refs/heads/main@{#1060849}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
dbaa2f33e5
commit
a35651a9ff
ash
BUILD.gn
accelerators
ash_strings.grdash_strings_grd
IDS_KSV_KEY_ESCAPE.png.sha1IDS_KSV_KEY_FULLSCREEN.png.sha1IDS_KSV_KEY_OVERVIEW.png.sha1IDS_KSV_KEY_SNAPSHOT.png.sha1IDS_KSV_KEY_SPACE.png.sha1IDS_KSV_MODIFIER_ALT.png.sha1IDS_KSV_MODIFIER_CONTROL.png.sha1IDS_KSV_MODIFIER_LAUNCHER.png.sha1IDS_KSV_MODIFIER_SEARCH.png.sha1IDS_KSV_MODIFIER_SHIFT.png.sha1
shortcut_viewer
chrome/browser/ui/app_list/search
@ -49,6 +49,8 @@ component("ash") {
|
||||
"accelerators/exit_warning_handler.h",
|
||||
"accelerators/key_hold_detector.cc",
|
||||
"accelerators/key_hold_detector.h",
|
||||
"accelerators/keyboard_code_util.cc",
|
||||
"accelerators/keyboard_code_util.h",
|
||||
"accelerators/magnifier_key_scroller.cc",
|
||||
"accelerators/magnifier_key_scroller.h",
|
||||
"accelerators/pre_target_accelerator_handler.cc",
|
||||
|
122
ash/accelerators/keyboard_code_util.cc
Normal file
122
ash/accelerators/keyboard_code_util.cc
Normal file
@ -0,0 +1,122 @@
|
||||
// Copyright 2022 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "ash/accelerators/keyboard_code_util.h"
|
||||
|
||||
#include "ash/public/cpp/accelerators_util.h"
|
||||
#include "ash/resources/vector_icons/vector_icons.h"
|
||||
#include "ash/strings/grit/ash_strings.h"
|
||||
#include "base/logging.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/chromeos/events/keyboard_layout_util.h"
|
||||
#include "ui/events/devices/device_data_manager.h"
|
||||
|
||||
namespace ash {
|
||||
|
||||
namespace {
|
||||
|
||||
// Provides I18n string for key codes which have no mapping to a meaningful
|
||||
// description or they require a special one we explicitly specify. For example,
|
||||
// ui::VKEY_COMMAND could return a string "Meta", but we want to display it as
|
||||
// "Search" or "Launcher".
|
||||
absl::optional<std::u16string> GetSpecialStringForKeyboardCode(
|
||||
ui::KeyboardCode key_code) {
|
||||
int msg_id = 0;
|
||||
switch (key_code) {
|
||||
case ui::VKEY_CONTROL:
|
||||
msg_id = IDS_KSV_MODIFIER_CONTROL;
|
||||
break;
|
||||
case ui::VKEY_LMENU:
|
||||
msg_id = IDS_KSV_MODIFIER_ALT;
|
||||
break;
|
||||
case ui::VKEY_SHIFT:
|
||||
msg_id = IDS_KSV_MODIFIER_SHIFT;
|
||||
break;
|
||||
case ui::VKEY_COMMAND:
|
||||
// DeviceUsesKeyboardLayout2() relies on DeviceDataManager.
|
||||
DCHECK(ui::DeviceDataManager::HasInstance());
|
||||
DCHECK(ui::DeviceDataManager::GetInstance()->AreDeviceListsComplete());
|
||||
msg_id = ui::DeviceUsesKeyboardLayout2() ? IDS_KSV_MODIFIER_LAUNCHER
|
||||
: IDS_KSV_MODIFIER_SEARCH;
|
||||
break;
|
||||
case ui::VKEY_ESCAPE:
|
||||
msg_id = IDS_KSV_KEY_ESCAPE;
|
||||
break;
|
||||
case ui::VKEY_SPACE:
|
||||
msg_id = IDS_KSV_KEY_SPACE;
|
||||
break;
|
||||
case ui::VKEY_MEDIA_LAUNCH_APP1:
|
||||
msg_id = IDS_KSV_KEY_OVERVIEW;
|
||||
break;
|
||||
case ui::VKEY_ZOOM:
|
||||
msg_id = IDS_KSV_KEY_FULLSCREEN;
|
||||
break;
|
||||
case ui::VKEY_SNAPSHOT:
|
||||
msg_id = IDS_KSV_KEY_SNAPSHOT;
|
||||
break;
|
||||
case ui::VKEY_UNKNOWN:
|
||||
// TODO(wutao): make this reliable.
|
||||
// If this is VKEY_UNKNOWN, it indicates to insert a "+" separator. Use
|
||||
// one plus and one space to replace the string resourece's placeholder so
|
||||
// that the separator will not conflict with the replacement string for
|
||||
// "VKEY_OEM_PLUS", which is "+" and "VKEY_SPACE", which is "Space".
|
||||
return u"+ ";
|
||||
default:
|
||||
return absl::nullopt;
|
||||
}
|
||||
return l10n_util::GetStringUTF16(msg_id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::u16string GetStringForKeyboardCode(ui::KeyboardCode key_code,
|
||||
bool remap_positional_key) {
|
||||
const absl::optional<std::u16string> key_label =
|
||||
GetSpecialStringForKeyboardCode(key_code);
|
||||
if (key_label)
|
||||
return key_label.value();
|
||||
|
||||
return ash::KeycodeToKeyString(key_code, remap_positional_key);
|
||||
}
|
||||
|
||||
const gfx::VectorIcon* GetVectorIconForKeyboardCode(ui::KeyboardCode key_code) {
|
||||
switch (key_code) {
|
||||
case ui::VKEY_BROWSER_BACK:
|
||||
return &ash::kKsvBrowserBackIcon;
|
||||
case ui::VKEY_BROWSER_FORWARD:
|
||||
return &ash::kKsvBrowserForwardIcon;
|
||||
case ui::VKEY_BROWSER_REFRESH:
|
||||
return &ash::kKsvReloadIcon;
|
||||
case ui::VKEY_ZOOM:
|
||||
return &ash::kKsvFullscreenIcon;
|
||||
case ui::VKEY_MEDIA_LAUNCH_APP1:
|
||||
return &ash::kKsvOverviewIcon;
|
||||
case ui::VKEY_BRIGHTNESS_DOWN:
|
||||
return &ash::kKsvBrightnessDownIcon;
|
||||
case ui::VKEY_BRIGHTNESS_UP:
|
||||
return &ash::kKsvBrightnessUpIcon;
|
||||
case ui::VKEY_VOLUME_MUTE:
|
||||
return &ash::kKsvMuteIcon;
|
||||
case ui::VKEY_VOLUME_DOWN:
|
||||
return &ash::kKsvVolumeDownIcon;
|
||||
case ui::VKEY_VOLUME_UP:
|
||||
return &ash::kKsvVolumeUpIcon;
|
||||
case ui::VKEY_UP:
|
||||
return &ash::kKsvArrowUpIcon;
|
||||
case ui::VKEY_DOWN:
|
||||
return &ash::kKsvArrowDownIcon;
|
||||
case ui::VKEY_LEFT:
|
||||
return &ash::kKsvArrowLeftIcon;
|
||||
case ui::VKEY_RIGHT:
|
||||
return &ash::kKsvArrowRightIcon;
|
||||
case ui::VKEY_PRIVACY_SCREEN_TOGGLE:
|
||||
return &ash::kKsvPrivacyScreenToggleIcon;
|
||||
case ui::VKEY_SNAPSHOT:
|
||||
return &ash::kKsvSnapshotIcon;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ash
|
42
ash/accelerators/keyboard_code_util.h
Normal file
42
ash/accelerators/keyboard_code_util.h
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright 2022 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ASH_ACCELERATORS_KEYBOARD_CODE_UTIL_H_
|
||||
#define ASH_ACCELERATORS_KEYBOARD_CODE_UTIL_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ash/ash_export.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
|
||||
namespace gfx {
|
||||
struct VectorIcon;
|
||||
} // namespace gfx
|
||||
|
||||
namespace ash {
|
||||
|
||||
// Returns the string of a DomKey for a given VKEY. VKEY needs to be mapped to
|
||||
// a physical key `dom_code` and then the `dom_code` needs to be mapped to a
|
||||
// meaning or character of `dom_key` based on the corresponding keyboard layout.
|
||||
//
|
||||
// For shortcuts based on keys that use positional mapping, eg. plus, minus,
|
||||
// left/right bracket, comma, period, or slash the VKEY is mapped to the
|
||||
// glyph on the key with the same physical position as the US layout. This
|
||||
// remapping can be disabled by passing false to `remap_positional_key`. This
|
||||
// is currently used for the 2 browser shortcuts that use these keys but are
|
||||
// not remapped (page zoom in/out).
|
||||
//
|
||||
// Returns empty string if the `dom_key` has no mapped meaning or character.
|
||||
ASH_EXPORT std::u16string GetStringForKeyboardCode(
|
||||
ui::KeyboardCode key_code,
|
||||
bool remap_positional_key = true);
|
||||
|
||||
// Returns the VectorIcon if `key_code` needs to be represented as an icon.
|
||||
// Returns nullptr if `key_code` should not be represented as an icon.
|
||||
ASH_EXPORT const gfx::VectorIcon* GetVectorIconForKeyboardCode(
|
||||
ui::KeyboardCode key_code);
|
||||
|
||||
} // namespace ash
|
||||
|
||||
#endif
|
@ -1691,6 +1691,39 @@ Style notes:
|
||||
<message name="IDS_ASH_STYLUS_TOOLS_CREATE_NOTE_ACTION" desc="Title of the capture screen action in the stylus tools (a pop-up panel next to the status tray). Clicking this opens up an application that the user can quickly jot a note down in.">
|
||||
Create note
|
||||
</message>
|
||||
<!-- Modifiers -->
|
||||
<message name="IDS_KSV_MODIFIER_CONTROL" desc="Name of [Ctrl] key. Shouldn't be translated in many languages.">
|
||||
Ctrl
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_ALT" desc="Name of [Alt] key. Shouldn't be translated in many languages.">
|
||||
Alt
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_SHIFT" desc="Name of [Shift] key. Shouldn't be translated in many languages.">
|
||||
Shift
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_SEARCH" desc="Name of [Search] key.">
|
||||
Search
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_LAUNCHER" desc="Name of [Launcher] key.">
|
||||
Launcher
|
||||
</message>
|
||||
|
||||
<!-- Keys with special label -->
|
||||
<message name="IDS_KSV_KEY_ESCAPE" desc="Name of [Esc] key. Shouldn't be translated in many languages.">
|
||||
Esc
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_SPACE" desc="Name of [Space] key.">
|
||||
Space
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_OVERVIEW" desc="Name of the key on a Chromebook keyboard that triggers the overview mode.">
|
||||
Overview mode key
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_FULLSCREEN" desc="Name of the key on a Chromebook keyboard that triggers the fullscreen.">
|
||||
Fullscreen key
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_SNAPSHOT" desc="Name of the key on a Chromebook keyboard that triggers the capture mode.">
|
||||
Capture mode key
|
||||
</message>
|
||||
<message name="IDS_ASH_STYLUS_TOOLS_ENTER_CAPTURE_MODE_ACTION" desc="Title of the enter capture mode action in the stylus tools (a pop-up panel next to the status tray). This enters capture mode, which allows users to take screenshots and record video. Capture mode has an UI for users to modify what gets screenshotted or recorded.">
|
||||
Screen capture
|
||||
</message>
|
||||
|
1
ash/ash_strings_grd/IDS_KSV_KEY_ESCAPE.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_KEY_ESCAPE.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
3f4beeb2197d5c1c846f9a3fefd4642cfbf20925
|
1
ash/ash_strings_grd/IDS_KSV_KEY_FULLSCREEN.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_KEY_FULLSCREEN.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
e5747622de5e8daba39b2173c0d7c43f37d1595a
|
1
ash/ash_strings_grd/IDS_KSV_KEY_OVERVIEW.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_KEY_OVERVIEW.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
01551cab9b705d2f041ee458f3ed19ddf92ab8ec
|
1
ash/ash_strings_grd/IDS_KSV_KEY_SNAPSHOT.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_KEY_SNAPSHOT.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
66888bd0b9444f1ebe0d54bb90e73fbbc1bfad73
|
1
ash/ash_strings_grd/IDS_KSV_KEY_SPACE.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_KEY_SPACE.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
a91189ac8404157b5e0548da6335e019be6b9fb2
|
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_ALT.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_ALT.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
703ceedabf76af6d0019cd8fb97b5c0efa4cb503
|
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_CONTROL.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_CONTROL.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
28b8c7a6a93f3d286dc53e7a9f27f8107ae0c8aa
|
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_LAUNCHER.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_LAUNCHER.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
a36c538457e29a0da29d4791fd6cd479385b1ab0
|
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_SEARCH.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_SEARCH.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
2861244faf02ccb1bdb9cdac80961b795d54e86f
|
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_SHIFT.png.sha1
Normal file
1
ash/ash_strings_grd/IDS_KSV_MODIFIER_SHIFT.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
06a89ab869bf95e824a78be7c19fb1c98927a939
|
@ -53,58 +53,6 @@ ui::KeyboardCode GetKeyCodeForModifier(ui::EventFlags modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
// Provides I18n string for key codes which have no mapping to a meaningful
|
||||
// description or they require a special one we explicitly specify. For example,
|
||||
// ui::VKEY_COMMAND could return a string "Meta", but we want to display it as
|
||||
// "Search" or "Launcher".
|
||||
absl::optional<std::u16string> GetSpecialStringForKeyboardCode(
|
||||
ui::KeyboardCode key_code) {
|
||||
int msg_id = 0;
|
||||
switch (key_code) {
|
||||
case ui::VKEY_CONTROL:
|
||||
msg_id = IDS_KSV_MODIFIER_CONTROL;
|
||||
break;
|
||||
case ui::VKEY_LMENU:
|
||||
msg_id = IDS_KSV_MODIFIER_ALT;
|
||||
break;
|
||||
case ui::VKEY_SHIFT:
|
||||
msg_id = IDS_KSV_MODIFIER_SHIFT;
|
||||
break;
|
||||
case ui::VKEY_COMMAND:
|
||||
// DeviceUsesKeyboardLayout2() relies on DeviceDataManager.
|
||||
DCHECK(ui::DeviceDataManager::HasInstance());
|
||||
DCHECK(ui::DeviceDataManager::GetInstance()->AreDeviceListsComplete());
|
||||
msg_id = ui::DeviceUsesKeyboardLayout2() ? IDS_KSV_MODIFIER_LAUNCHER
|
||||
: IDS_KSV_MODIFIER_SEARCH;
|
||||
break;
|
||||
case ui::VKEY_ESCAPE:
|
||||
msg_id = IDS_KSV_KEY_ESCAPE;
|
||||
break;
|
||||
case ui::VKEY_SPACE:
|
||||
msg_id = IDS_KSV_KEY_SPACE;
|
||||
break;
|
||||
case ui::VKEY_MEDIA_LAUNCH_APP1:
|
||||
msg_id = IDS_KSV_KEY_OVERVIEW;
|
||||
break;
|
||||
case ui::VKEY_ZOOM:
|
||||
msg_id = IDS_KSV_KEY_FULLSCREEN;
|
||||
break;
|
||||
case ui::VKEY_SNAPSHOT:
|
||||
msg_id = IDS_KSV_KEY_SNAPSHOT;
|
||||
break;
|
||||
case ui::VKEY_UNKNOWN:
|
||||
// TODO(wutao): make this reliable.
|
||||
// If this is VKEY_UNKNOWN, it indicates to insert a "+" separator. Use
|
||||
// one plus and one space to replace the string resourece's placeholder so
|
||||
// that the separator will not conflict with the replacement string for
|
||||
// "VKEY_OEM_PLUS", which is "+" and "VKEY_SPACE", which is "Space".
|
||||
return u"+ ";
|
||||
default:
|
||||
return absl::nullopt;
|
||||
}
|
||||
return l10n_util::GetStringUTF16(msg_id);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
std::u16string GetStringForCategory(ShortcutCategory category) {
|
||||
@ -135,16 +83,6 @@ std::u16string GetStringForCategory(ShortcutCategory category) {
|
||||
return l10n_util::GetStringUTF16(msg_id);
|
||||
}
|
||||
|
||||
std::u16string GetStringForKeyboardCode(ui::KeyboardCode key_code,
|
||||
bool remap_positional_key) {
|
||||
const absl::optional<std::u16string> key_label =
|
||||
GetSpecialStringForKeyboardCode(key_code);
|
||||
if (key_label)
|
||||
return key_label.value();
|
||||
|
||||
return ash::KeycodeToKeyString(key_code, remap_positional_key);
|
||||
}
|
||||
|
||||
std::u16string GetAccessibleNameForKeyboardCode(ui::KeyboardCode key_code) {
|
||||
int msg_id = 0;
|
||||
switch (key_code) {
|
||||
@ -169,45 +107,6 @@ std::u16string GetAccessibleNameForKeyboardCode(ui::KeyboardCode key_code) {
|
||||
return msg_id ? l10n_util::GetStringUTF16(msg_id) : std::u16string();
|
||||
}
|
||||
|
||||
const gfx::VectorIcon* GetVectorIconForKeyboardCode(ui::KeyboardCode key_code) {
|
||||
switch (key_code) {
|
||||
case ui::VKEY_BROWSER_BACK:
|
||||
return &ash::kKsvBrowserBackIcon;
|
||||
case ui::VKEY_BROWSER_FORWARD:
|
||||
return &ash::kKsvBrowserForwardIcon;
|
||||
case ui::VKEY_BROWSER_REFRESH:
|
||||
return &ash::kKsvReloadIcon;
|
||||
case ui::VKEY_ZOOM:
|
||||
return &ash::kKsvFullscreenIcon;
|
||||
case ui::VKEY_MEDIA_LAUNCH_APP1:
|
||||
return &ash::kKsvOverviewIcon;
|
||||
case ui::VKEY_BRIGHTNESS_DOWN:
|
||||
return &ash::kKsvBrightnessDownIcon;
|
||||
case ui::VKEY_BRIGHTNESS_UP:
|
||||
return &ash::kKsvBrightnessUpIcon;
|
||||
case ui::VKEY_VOLUME_MUTE:
|
||||
return &ash::kKsvMuteIcon;
|
||||
case ui::VKEY_VOLUME_DOWN:
|
||||
return &ash::kKsvVolumeDownIcon;
|
||||
case ui::VKEY_VOLUME_UP:
|
||||
return &ash::kKsvVolumeUpIcon;
|
||||
case ui::VKEY_UP:
|
||||
return &ash::kKsvArrowUpIcon;
|
||||
case ui::VKEY_DOWN:
|
||||
return &ash::kKsvArrowDownIcon;
|
||||
case ui::VKEY_LEFT:
|
||||
return &ash::kKsvArrowLeftIcon;
|
||||
case ui::VKEY_RIGHT:
|
||||
return &ash::kKsvArrowRightIcon;
|
||||
case ui::VKEY_PRIVACY_SCREEN_TOGGLE:
|
||||
return &ash::kKsvPrivacyScreenToggleIcon;
|
||||
case ui::VKEY_SNAPSHOT:
|
||||
return &ash::kKsvSnapshotIcon;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<ash::KeyboardShortcutItem>& GetKeyboardShortcutItemList() {
|
||||
static base::NoDestructor<std::vector<ash::KeyboardShortcutItem>> item_list({
|
||||
{// |categories|
|
||||
|
@ -11,10 +11,6 @@
|
||||
#include "ash/shortcut_viewer/ksv_export.h"
|
||||
#include "ui/events/keycodes/keyboard_codes.h"
|
||||
|
||||
namespace gfx {
|
||||
struct VectorIcon;
|
||||
} // namespace gfx
|
||||
|
||||
namespace ash {
|
||||
|
||||
struct KeyboardShortcutItem;
|
||||
@ -30,21 +26,6 @@ GetKeyboardShortcutItemList();
|
||||
|
||||
std::u16string GetStringForCategory(ash::ShortcutCategory category);
|
||||
|
||||
// Returns the string of a DomKey for a given VKEY. VKEY needs to be mapped to
|
||||
// a physical key |dom_code| and then the |dom_code| needs to be mapped to a
|
||||
// meaning or character of |dom_key| based on the corresponding keyboard layout.
|
||||
//
|
||||
// For shortcuts based on keys that use positional mapping, eg. plus, minus,
|
||||
// left/right bracket, comma, period, or slash the VKEY is mapped to the
|
||||
// glyph on the key with the same physical position as the US layout. This
|
||||
// remapping can be disabled by passing false to |remap_positional_key|. This
|
||||
// is currently used for the 2 browser shortcuts that use these keys but are
|
||||
// not remapped (page zoom in/out).
|
||||
//
|
||||
// Returns empty string if the |dom_key| has no mapped meaning or character.
|
||||
std::u16string GetStringForKeyboardCode(ui::KeyboardCode key_code,
|
||||
bool remap_positional_key = true);
|
||||
|
||||
// Certain punctuation is not verbalized by ChromeVox, i.e. ".". So, whenever
|
||||
// one of these is used in a keyboard shortcut, need to set the accessible name
|
||||
// to explicitly specified text, such as "period".
|
||||
@ -52,10 +33,6 @@ std::u16string GetStringForKeyboardCode(ui::KeyboardCode key_code,
|
||||
// |key_code|.
|
||||
std::u16string GetAccessibleNameForKeyboardCode(ui::KeyboardCode key_code);
|
||||
|
||||
// Returns the VectorIcon if |key_code| need to be represented as an icon.
|
||||
// Returns nullptr if |key_code| should not be represented as an icon.
|
||||
const gfx::VectorIcon* GetVectorIconForKeyboardCode(ui::KeyboardCode key_code);
|
||||
|
||||
} // namespace keyboard_shortcut_viewer
|
||||
|
||||
#endif // ASH_SHORTCUT_VIEWER_KEYBOARD_SHORTCUT_VIEWER_METADATA_H_
|
||||
|
@ -239,39 +239,6 @@
|
||||
Accessibility
|
||||
</message>
|
||||
|
||||
<!-- Modifiers -->
|
||||
<message name="IDS_KSV_MODIFIER_CONTROL" desc="Name of [Ctrl] key. Shouldn't be translated in many languages.">
|
||||
Ctrl
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_ALT" desc="Name of [Alt] key. Shouldn't be translated in many languages.">
|
||||
Alt
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_SHIFT" desc="Name of [Shift] key. Shouldn't be translated in many languages.">
|
||||
Shift
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_SEARCH" desc="Name of [Search] key.">
|
||||
Search
|
||||
</message>
|
||||
<message name="IDS_KSV_MODIFIER_LAUNCHER" desc="Name of [Launcher] key.">
|
||||
Launcher
|
||||
</message>
|
||||
|
||||
<!-- Keys with special label -->
|
||||
<message name="IDS_KSV_KEY_ESCAPE" desc="Name of [Esc] key. Shouldn't be translated in many languages.">
|
||||
Esc
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_SPACE" desc="Name of [Space] key.">
|
||||
Space
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_OVERVIEW" desc="Name of the key on a Chromebook keyboard that triggers the overview mode.">
|
||||
Overview mode key
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_FULLSCREEN" desc="Name of the key on a Chromebook keyboard that triggers the fullscreen.">
|
||||
Fullscreen key
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_SNAPSHOT" desc="Name of the key on a Chromebook keyboard that triggers the capture mode.">
|
||||
Capture mode key
|
||||
</message>
|
||||
<message name="IDS_KSV_KEY_NO_MAPPING" desc="Alternative string to display if no meaning found for the key.">
|
||||
Not supported with current keyboard layout
|
||||
</message>
|
||||
|
@ -1 +0,0 @@
|
||||
0fa8ce76888a1e83db08c9f8e111b8a65de8ecef
|
@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/accelerators/keyboard_code_util.h"
|
||||
#include "ash/constants/ash_features.h"
|
||||
#include "ash/public/cpp/keyboard_shortcut_item.h"
|
||||
#include "ash/public/cpp/style/color_provider.h"
|
||||
@ -87,7 +88,8 @@ std::unique_ptr<views::View> CreateSeparatorView() {
|
||||
std::unique_ptr<views::View> CreateBubbleView(const std::u16string& bubble_text,
|
||||
ui::KeyboardCode key_code) {
|
||||
auto bubble_view = std::make_unique<BubbleView>();
|
||||
const gfx::VectorIcon* vector_icon = GetVectorIconForKeyboardCode(key_code);
|
||||
const gfx::VectorIcon* vector_icon =
|
||||
ash::GetVectorIconForKeyboardCode(key_code);
|
||||
if (vector_icon)
|
||||
bubble_view->SetIcon(*vector_icon);
|
||||
else
|
||||
@ -123,7 +125,7 @@ KeyboardShortcutItemView::KeyboardShortcutItemView(
|
||||
auto iter = GetKeycodeToString16Cache()->find(key_code);
|
||||
if (iter == GetKeycodeToString16Cache()->end()) {
|
||||
iter = GetKeycodeToString16Cache()
|
||||
->emplace(key_code, GetStringForKeyboardCode(key_code))
|
||||
->emplace(key_code, ash::GetStringForKeyboardCode(key_code))
|
||||
.first;
|
||||
}
|
||||
|
||||
@ -140,8 +142,8 @@ KeyboardShortcutItemView::KeyboardShortcutItemView(
|
||||
item.description_message_id == IDS_KSV_DESCRIPTION_IDC_ZOOM_PLUS ||
|
||||
item.description_message_id == IDS_KSV_DESCRIPTION_IDC_ZOOM_MINUS;
|
||||
if (dont_remap_position) {
|
||||
dom_key_string =
|
||||
GetStringForKeyboardCode(key_code, /*remap_positional_key=*/false);
|
||||
dom_key_string = ash::GetStringForKeyboardCode(
|
||||
key_code, /*remap_positional_key=*/false);
|
||||
}
|
||||
|
||||
// If the |key_code| has no mapped |dom_key_string|, we use alternative
|
||||
|
@ -1,4 +1,5 @@
|
||||
include_rules = [
|
||||
"+ash/accelerators",
|
||||
"+ash/assistant/model",
|
||||
"+ash/assistant/util",
|
||||
"+ash/shortcut_viewer",
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "ash/accelerators/keyboard_code_util.h"
|
||||
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
|
||||
#include "ash/shortcut_viewer/keyboard_shortcut_viewer_metadata.h"
|
||||
#include "ash/shortcut_viewer/strings/grit/shortcut_viewer_strings.h"
|
||||
@ -180,8 +181,7 @@ KeyboardShortcutResult::KeyboardShortcutResult(Profile* profile,
|
||||
|
||||
for (ui::KeyboardCode key_code : data.shortcut_key_codes) {
|
||||
// Get the string for the |DomKey|.
|
||||
std::u16string dom_key_string =
|
||||
keyboard_shortcut_viewer::GetStringForKeyboardCode(key_code);
|
||||
std::u16string dom_key_string = ash::GetStringForKeyboardCode(key_code);
|
||||
|
||||
// See ash/shortcut_viewer/views/keyboard_shortcut_item_view.cc for details
|
||||
// on why this is necessary.
|
||||
@ -189,7 +189,7 @@ KeyboardShortcutResult::KeyboardShortcutResult(Profile* profile,
|
||||
data.description_message_id == IDS_KSV_DESCRIPTION_IDC_ZOOM_PLUS ||
|
||||
data.description_message_id == IDS_KSV_DESCRIPTION_IDC_ZOOM_MINUS;
|
||||
if (dont_remap_position) {
|
||||
dom_key_string = keyboard_shortcut_viewer::GetStringForKeyboardCode(
|
||||
dom_key_string = ash::GetStringForKeyboardCode(
|
||||
key_code, /*remap_positional_key=*/false);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user