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

Unified Diff: chrome/browser/ui/browser_command_controller.cc

Issue 2636013002: Disable browser key reservation in fullscreen mode (Closed)
Patch Set: Resolve review comments Created 3 years, 10 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 | « no previous file | chrome/browser/ui/browser_command_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_command_controller.cc
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc
index 0d947e9a4f24cf96a056d565a89e227d60a8f26f..58b7cb6cf6e6561293ff5c54922c74028fcfde2b 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -88,18 +88,6 @@ using content::NavigationEntry;
using content::NavigationController;
using content::WebContents;
-namespace {
-
-enum WindowState {
- // Not in fullscreen mode.
- WINDOW_STATE_NOT_FULLSCREEN,
-
- // Fullscreen mode, occupying the whole screen.
- WINDOW_STATE_FULLSCREEN,
-};
-
-} // namespace
-
namespace chrome {
///////////////////////////////////////////////////////////////////////////////
@@ -199,8 +187,22 @@ bool BrowserCommandController::IsReservedCommandOrKey(
}
#endif
- if (window()->IsFullscreen() && command_id == IDC_FULLSCREEN)
- return true;
+ if (window()->IsFullscreen()) {
+ // In fullscreen, all keys except Esc and F11 should be delivered to the web
msw 2017/02/09 18:01:13 nit: maybe describe this in terms of commands, not
Hzj_jie 2017/02/10 01:14:23 Done.
+ // page. See https://goo.gl/4tJ32G.
+ if (command_id == IDC_FULLSCREEN) {
msw 2017/02/09 18:01:13 If the comment above is correct; why can't we just
Hzj_jie 2017/02/10 01:14:23 I have updated the comment. IDC_EXIT should also b
+ return true;
+ } else if (command_id == IDC_CLOSE_TAB ||
msw 2017/02/09 18:01:13 nit: no else after return
Hzj_jie 2017/02/10 01:14:23 Done.
+ command_id == IDC_CLOSE_WINDOW ||
msw 2017/02/09 18:01:13 nit: since most of this block is duplicated below,
Hzj_jie 2017/02/10 01:14:23 Done.
+ command_id == IDC_NEW_INCOGNITO_WINDOW ||
+ command_id == IDC_NEW_TAB ||
+ command_id == IDC_NEW_WINDOW ||
+ command_id == IDC_RESTORE_TAB ||
+ command_id == IDC_SELECT_NEXT_TAB ||
+ command_id == IDC_SELECT_PREVIOUS_TAB) {
+ return false;
+ }
+ }
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
// If this key was registered by the user as a content editing hotkey, then
@@ -1020,13 +1022,9 @@ void BrowserCommandController::UpdateCommandsForFileSelectionDialogs() {
}
void BrowserCommandController::UpdateCommandsForFullscreenMode() {
- WindowState window_state = WINDOW_STATE_NOT_FULLSCREEN;
- if (window() && window()->IsFullscreen()) {
- window_state = WINDOW_STATE_FULLSCREEN;
- }
- bool show_main_ui = IsShowingMainUI();
- bool main_not_fullscreen =
- show_main_ui && window_state == WINDOW_STATE_NOT_FULLSCREEN;
+ const bool is_fullscreen = (window() && window()->IsFullscreen());
msw 2017/02/09 18:01:13 nit: parens not needed
Hzj_jie 2017/02/10 01:14:23 Done.
+ const bool show_main_ui = IsShowingMainUI();
+ const bool main_not_fullscreen = show_main_ui && !is_fullscreen;
// Navigation commands
command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui);
@@ -1034,8 +1032,7 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() {
// Window management commands
command_updater_.UpdateCommandEnabled(
IDC_SHOW_AS_TAB,
- !browser_->is_type_tabbed() &&
- window_state == WINDOW_STATE_NOT_FULLSCREEN);
+ !browser_->is_type_tabbed() && !is_fullscreen);
// Focus various bits of UI
command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui);
@@ -1077,19 +1074,29 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() {
if (base::debug::IsProfilingSupported())
command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui);
- bool fullscreen_enabled = true;
#if !defined(OS_MACOSX)
- if (window_state == WINDOW_STATE_NOT_FULLSCREEN &&
- !profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) {
- // Disable toggling into fullscreen mode if disallowed by pref.
- fullscreen_enabled = false;
- }
+ // Disable toggling into fullscreen mode if disallowed by pref.
+ const bool fullscreen_enabled = is_fullscreen ||
+ profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed);
+#else
+ const bool fullscreen_enabled = true;
#endif
command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled);
command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR,
fullscreen_enabled);
+ command_updater_.UpdateCommandEnabled(IDC_CLOSE_TAB, !is_fullscreen);
msw 2017/02/09 18:01:13 Does this CL need security/UX review beyond the 'i
Hzj_jie 2017/02/10 01:14:23 Dominick has reviewed this already, though I canno
+ command_updater_.UpdateCommandEnabled(IDC_CLOSE_WINDOW, !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_NEW_INCOGNITO_WINDOW,
+ !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_NEW_TAB, !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_NEW_WINDOW, !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_RESTORE_TAB, !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, !is_fullscreen);
+ command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
+ !is_fullscreen);
+
UpdateCommandsForBookmarkBar();
}
« no previous file with comments | « no previous file | chrome/browser/ui/browser_command_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698