fix: handle shortcuts by default if no WebPreferences object exists (#14766)

DevTools webcontents do not have webpreferences

Fixes #14685
This commit is contained in:
Samuel Attard 2018-09-28 01:41:09 +10:00 committed by GitHub
parent 0d2a0c7583
commit 6be69048e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 581 additions and 43 deletions

View file

@ -24,12 +24,15 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
if (event.windows_key_code == ui::VKEY_ESCAPE && is_html_fullscreen())
ExitFullscreenModeForTab(source);
// Check if the webContents has preferences and to ignore shortcuts
auto* web_preferences = WebContentsPreferences::From(source);
if (web_preferences &&
web_preferences->IsEnabled("ignoreMenuShortcuts", false))
return;
// Let the NativeWindow handle other parts.
if (auto* web_preferences = WebContentsPreferences::From(source)) {
if (owner_window() &&
!web_preferences->IsEnabled("ignoreMenuShortcuts", false)) {
owner_window()->HandleKeyboardEvent(source, event);
}
if (owner_window()) {
owner_window()->HandleKeyboardEvent(source, event);
}
}