Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1616)

Unified Diff: apps/shell_window.cc

Issue 62763003: Leave fullscreen mode in an app window when ESC key is pressed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable tests on mac Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/shell_window.h ('k') | chrome/browser/apps/app_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/shell_window.cc
diff --git a/apps/shell_window.cc b/apps/shell_window.cc
index c50e5321bb7eee39648aa4fbd133f714449b7766..75cd7cd2e55999f7db5e4be8be33b063c396587f 100644
--- a/apps/shell_window.cc
+++ b/apps/shell_window.cc
@@ -289,9 +289,39 @@ void ShellWindow::AddNewContents(WebContents* source,
initial_pos, user_gesture, was_blocked);
}
+bool ShellWindow::PreHandleKeyboardEvent(
+ content::WebContents* source,
+ const content::NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) {
+ // Here, we can handle a key event before the content gets it. When we are
+ // fullscreen, we want to allow the user to leave when ESC is pressed.
+ // However, if the application has the "overrideEscFullscreen" permission, we
+ // should let it override that behavior.
+ // ::HandleKeyboardEvent() will only be called if the KeyEvent's default
+ // action is not prevented.
+ // Thus, we should handle the KeyEvent here only if the permission is not set.
+ if (event.windowsKeyCode == ui::VKEY_ESCAPE &&
+ (fullscreen_types_ != FULLSCREEN_TYPE_NONE) &&
+ !extension_->HasAPIPermission(APIPermission::kOverrideEscFullscreen)) {
+ Restore();
+ return true;
+ }
+
+ return false;
+}
+
void ShellWindow::HandleKeyboardEvent(
WebContents* source,
const content::NativeWebKeyboardEvent& event) {
+ // If the window is currently fullscreen, ESC should leave fullscreen.
+ // If this code is being called for ESC, that means that the KeyEvent's
+ // default behavior was not prevented by the content.
+ if (event.windowsKeyCode == ui::VKEY_ESCAPE &&
+ (fullscreen_types_ != FULLSCREEN_TYPE_NONE)) {
+ Restore();
+ return;
+ }
+
native_app_window_->HandleKeyboardEvent(event);
}
« no previous file with comments | « apps/shell_window.h ('k') | chrome/browser/apps/app_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698