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

Unified Diff: chrome/browser/ui/exclusive_access/exclusive_access_manager.cc

Issue 1814983003: Add an experimental keyboard lock, where Esc must be held to exit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comment nit Created 4 years, 9 months 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 | « chrome/browser/ui/exclusive_access/exclusive_access_manager.h ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
index 666d11e6970660990014e60c2a88d65f567d018b..3492dc448f0195afd22ddf435be1e4ec709c5552 100644
--- a/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
+++ b/chrome/browser/ui/exclusive_access/exclusive_access_manager.cc
@@ -19,6 +19,15 @@
using content::WebContents;
+namespace {
+
+// Time in milliseconds to hold the Esc key in order to exit full screen.
+// TODO(dominickn) refactor the way timings/input handling works so this
+// constant doesn't have to be in this file.
+const int kHoldEscapeTimeMs = 1500;
+
+}
+
ExclusiveAccessManager::ExclusiveAccessManager(
ExclusiveAccessContext* exclusive_access_context)
: exclusive_access_context_(exclusive_access_context),
@@ -58,6 +67,8 @@ ExclusiveAccessManager::GetExclusiveAccessExitBubbleType() const {
if (fullscreen_controller_.IsUserAcceptedFullscreen()) {
if (fullscreen_controller_.IsPrivilegedFullscreenForTab())
return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
+ if (IsExperimentalKeyboardLockUIEnabled())
+ return EXCLUSIVE_ACCESS_BUBBLE_TYPE_KEYBOARD_LOCK_EXIT_INSTRUCTION;
if (mouse_lock_controller_.IsMouseLocked())
return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
if (mouse_lock_controller_.IsMouseLockRequested())
@@ -91,6 +102,11 @@ GURL ExclusiveAccessManager::GetExclusiveAccessBubbleURL() const {
}
// static
+bool ExclusiveAccessManager::IsExperimentalKeyboardLockUIEnabled() {
+ return base::FeatureList::IsEnabled(features::kExperimentalKeyboardLockUI);
+}
+
+// static
bool ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled() {
return base::FeatureList::IsEnabled(features::kSimplifiedFullscreenUI);
}
@@ -117,6 +133,27 @@ bool ExclusiveAccessManager::HandleUserKeyPress(
return false;
}
+ if (IsExperimentalKeyboardLockUIEnabled()) {
+ if (event.type == content::NativeWebKeyboardEvent::KeyUp &&
+ hold_timer_.IsRunning()) {
+ // Seeing a key up event on Esc with the hold timer running cancels the
+ // timer and doesn't exit. This means the user pressed Esc, but not long
+ // enough to trigger an exit
+ hold_timer_.Stop();
+ } else if (event.type == content::NativeWebKeyboardEvent::RawKeyDown &&
+ !hold_timer_.IsRunning()) {
+ // Seeing a key down event on Esc when the hold timer is stopped starts
+ // the timer. When the timer reaches 0, the callback will trigger an exit
+ // from fullscreen/mouselock.
+ hold_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMilliseconds(kHoldEscapeTimeMs),
+ base::Bind(&ExclusiveAccessManager::HandleUserHeldEscape,
+ base::Unretained(this)));
+ }
+ // We never handle the keyboard event.
+ return false;
+ }
+
bool handled = false;
handled = fullscreen_controller_.HandleUserPressedEscape();
handled |= mouse_lock_controller_.HandleUserPressedEscape();
@@ -159,6 +196,7 @@ void ExclusiveAccessManager::RecordBubbleReshownUMA(
break;
case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS:
case EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION:
+ case EXCLUSIVE_ACCESS_BUBBLE_TYPE_KEYBOARD_LOCK_EXIT_INSTRUCTION:
case EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION:
case EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION:
// Only fullscreen in effect.
@@ -181,3 +219,8 @@ void ExclusiveAccessManager::RecordBubbleReshownUMA(
if (mouselock)
mouse_lock_controller_.RecordBubbleReshownUMA();
}
+
+void ExclusiveAccessManager::HandleUserHeldEscape() {
+ fullscreen_controller_.HandleUserPressedEscape();
+ mouse_lock_controller_.HandleUserPressedEscape();
+}
« no previous file with comments | « chrome/browser/ui/exclusive_access/exclusive_access_manager.h ('k') | chrome/common/chrome_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698