Return empty vector from GetShortcutVectorRepresentation when hotkey is unset
Correction to implementation in https://chromium-review.googlesource.com/c/chromium/src/+/6442193, to return {} instead of {""} if the hotkey is empty Bug: b:413771543 Change-Id: I3c0d2b243337823e276fb600c798334b3e7ead23 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6499812 Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org> Reviewed-by: Ian Wells <iwells@chromium.org> Commit-Queue: Anthony Cui <cuianthony@chromium.org> Cr-Commit-Position: refs/heads/main@{#1454104}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5466cb5737
commit
89bbe166ec
chrome
ui/base/accelerators
@ -12,10 +12,10 @@
|
||||
|
||||
namespace glic {
|
||||
std::string GetHotkeyString() {
|
||||
// If the hotkey is unset, return an empty string as its representation.
|
||||
std::vector<std::u16string> hotkey_tokens =
|
||||
glic::GlicLauncherConfiguration::GetGlobalHotkey()
|
||||
.GetShortcutVectorRepresentation();
|
||||
// If the hotkey is unset, return an empty string as its representation.
|
||||
if (hotkey_tokens.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
@ -917,6 +917,8 @@ IN_PROC_BROWSER_TEST_F(GlicApiTestWithOneTab, testGetOsHotkeyState) {
|
||||
g_browser_process->local_state()->SetString(prefs::kGlicLauncherHotkey,
|
||||
"Ctrl+Shift+1");
|
||||
ContinueJsTest();
|
||||
g_browser_process->local_state()->SetString(prefs::kGlicLauncherHotkey, "");
|
||||
ContinueJsTest();
|
||||
}
|
||||
|
||||
IN_PROC_BROWSER_TEST_F(GlicApiTestWithOneTab, testSetWindowDraggableAreas) {
|
||||
|
@ -496,14 +496,18 @@ class ApiTests extends ApiTestFixtureBase {
|
||||
async testGetOsHotkeyState() {
|
||||
assertTrue(!!this.host.getOsHotkeyState);
|
||||
const osHotkeyState = observeSequence(this.host.getOsHotkeyState());
|
||||
const initialHotkeyState = await osHotkeyState.next();
|
||||
let hotkeyState = await osHotkeyState.next();
|
||||
const isMac = /Mac/.test(navigator.platform);
|
||||
let expectedHotkey = isMac ? '<⌃>-<G>' : '<Ctrl>-<G>';
|
||||
assertEquals(expectedHotkey, initialHotkeyState.hotkey);
|
||||
assertEquals(expectedHotkey, hotkeyState.hotkey);
|
||||
await this.advanceToNextStep();
|
||||
const changedState = await osHotkeyState.next();
|
||||
hotkeyState = await osHotkeyState.next();
|
||||
expectedHotkey = isMac ? '<⌃>-<⇧>-<1>' : '<Ctrl>-<Shift>-<1>';
|
||||
assertEquals(expectedHotkey, changedState.hotkey);
|
||||
assertEquals(expectedHotkey, hotkeyState.hotkey);
|
||||
await this.advanceToNextStep();
|
||||
hotkeyState = await osHotkeyState.next();
|
||||
expectedHotkey = '';
|
||||
assertEquals(expectedHotkey, hotkeyState.hotkey);
|
||||
}
|
||||
|
||||
async testGetUserProfileInfo() {
|
||||
|
@ -90,12 +90,16 @@ bool Accelerator::IsMediaKey() const {
|
||||
std::vector<std::u16string> Accelerator::GetShortcutVectorRepresentation()
|
||||
const {
|
||||
std::vector<std::u16string> shortcut_vector;
|
||||
if (IsEmpty()) {
|
||||
return shortcut_vector;
|
||||
}
|
||||
|
||||
std::u16string key_code = GetKeyCodeStringForShortcut();
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
shortcut_vector = GetShortFormModifiers();
|
||||
shortcut_vector.push_back(GetKeyCodeStringForShortcut());
|
||||
shortcut_vector.push_back(key_code);
|
||||
#else
|
||||
std::u16string key_code = GetKeyCodeStringForShortcut();
|
||||
std::vector<std::u16string> modifiers = GetLongFormModifiers();
|
||||
// For some reason, menus in Windows ignore standard Unicode directionality
|
||||
// marks (such as LRE, PDF, etc.). On RTL locales, we use RTL menus and
|
||||
|
Reference in New Issue
Block a user