Commit bd02a98f authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

[KeyboardLock] Removing Esc key string from context menu when lock is active

Per UX feedback, we should not show [esc] in the context menu when we know that
press and hold is required to exit fullscreen.  This change updates the context
menu to query the current keyboard lock state to handle that scenario.

BUG=680809

Change-Id: Iea80d64b0c3f905521f9bf07473b6b26791fa042
Reviewed-on: https://chromium-review.googlesource.com/1055659Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Reviewed-by: default avatarIstiaque Ahmed <lazyboy@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558800}
parent 41fe7a10
......@@ -62,6 +62,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/exclusive_access/keyboard_lock_controller.h"
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/web_applications/web_app.h"
......@@ -909,6 +910,16 @@ bool RenderViewContextMenu::IsHTML5Fullscreen() const {
return controller->IsTabFullscreen();
}
bool RenderViewContextMenu::IsPressAndHoldEscRequiredToExitFullscreen() const {
Browser* browser = chrome::FindBrowserWithWebContents(source_web_contents_);
if (!browser)
return false;
KeyboardLockController* controller =
browser->exclusive_access_manager()->keyboard_lock_controller();
return controller->RequiresPressAndHoldEscToExit();
}
#if BUILDFLAG(ENABLE_PLUGINS)
void RenderViewContextMenu::HandleAuthorizeAllPlugins() {
ChromePluginServiceFilter::GetInstance()->AuthorizeAllPlugins(
......
......@@ -99,6 +99,10 @@ class RenderViewContextMenu : public RenderViewContextMenuBase {
// page (as opposed to the user). Used to determine which shortcut to display.
bool IsHTML5Fullscreen() const;
// Returns true if keyboard lock is active and requires the user to press and
// hold escape to exit exclusive access mode.
bool IsPressAndHoldEscRequiredToExitFullscreen() const;
private:
friend class RenderViewContextMenuTest;
friend class TestRenderViewContextMenu;
......
......@@ -137,6 +137,11 @@ bool RenderViewContextMenuViews::GetAcceleratorForCommandId(
case IDC_CONTENT_CONTEXT_EXIT_FULLSCREEN:
// Esc only works in HTML5 (site-triggered) fullscreen.
if (IsHTML5Fullscreen()) {
// Per UX design feedback, do not show an accelerator when press and
// hold is required to exit fullscreen.
if (IsPressAndHoldEscRequiredToExitFullscreen())
return false;
*accel = ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE);
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment