Chromium Code Reviews| 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 b59372d2c58d305beef3ecd49f680e4c1cefacf8..11ba4cf280549a960527e53ae9d066892334c6dd 100644 |
| --- a/chrome/browser/ui/browser_command_controller.cc |
| +++ b/chrome/browser/ui/browser_command_controller.cc |
| @@ -88,6 +88,18 @@ using content::NavigationEntry; |
| using content::NavigationController; |
| using content::WebContents; |
| +namespace { |
| + |
| +enum WindowState { |
|
msw
2017/02/16 00:48:53
I appreciated the removal of this enum; feel free
Hzj_jie
2017/02/16 01:56:53
Done.
|
| + // Not in fullscreen mode. |
| + WINDOW_STATE_NOT_FULLSCREEN, |
| + |
| + // Fullscreen mode, occupying the whole screen. |
| + WINDOW_STATE_FULLSCREEN, |
| +}; |
| + |
| +} // namespace |
| + |
| namespace chrome { |
| /////////////////////////////////////////////////////////////////////////////// |
| @@ -187,22 +199,11 @@ bool BrowserCommandController::IsReservedCommandOrKey( |
| } |
| #endif |
| - const bool is_tab_or_window_command = |
| - command_id == IDC_CLOSE_TAB || |
| - command_id == IDC_CLOSE_WINDOW || |
| - 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; |
| if (window()->IsFullscreen()) { |
| // In fullscreen, all commands except for IDC_FULLSCREEN and IDC_EXIT should |
| - // be delivered to the web page. See https://goo.gl/4tJ32G. |
| - if (command_id == IDC_FULLSCREEN) |
| - return true; |
| - if (is_tab_or_window_command) |
| - return false; |
| + // be delivered to the web page. See, intent to implement, |
| + // https://goo.gl/4tJ32G. |
| + return command_id == IDC_EXIT || command_id == IDC_FULLSCREEN; |
| } |
| #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| @@ -214,7 +215,15 @@ bool BrowserCommandController::IsReservedCommandOrKey( |
| return false; |
| #endif |
| - return is_tab_or_window_command || command_id == IDC_EXIT; |
| + return command_id == IDC_CLOSE_TAB || |
| + command_id == IDC_CLOSE_WINDOW || |
| + 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 || |
| + command_id == IDC_EXIT; |
| } |
| void BrowserCommandController::SetBlockCommandExecution(bool block) { |
| @@ -1015,9 +1024,13 @@ void BrowserCommandController::UpdateCommandsForFileSelectionDialogs() { |
| } |
| void BrowserCommandController::UpdateCommandsForFullscreenMode() { |
| - const bool is_fullscreen = window() && window()->IsFullscreen(); |
| - const bool show_main_ui = IsShowingMainUI(); |
| - const bool main_not_fullscreen = show_main_ui && !is_fullscreen; |
| + 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; |
| // Navigation commands |
| command_updater_.UpdateCommandEnabled(IDC_OPEN_CURRENT_URL, show_main_ui); |
| @@ -1025,7 +1038,8 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() { |
| // Window management commands |
| command_updater_.UpdateCommandEnabled( |
| IDC_SHOW_AS_TAB, |
| - !browser_->is_type_tabbed() && !is_fullscreen); |
| + !browser_->is_type_tabbed() && |
| + window_state == WINDOW_STATE_NOT_FULLSCREEN); |
| // Focus various bits of UI |
| command_updater_.UpdateCommandEnabled(IDC_FOCUS_TOOLBAR, show_main_ui); |
| @@ -1067,29 +1081,19 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() { |
| if (base::debug::IsProfilingSupported()) |
| command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); |
| + bool fullscreen_enabled = true; |
| #if !defined(OS_MACOSX) |
| - // 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; |
| + if (window_state == WINDOW_STATE_NOT_FULLSCREEN && |
| + !profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed)) { |
| + // Disable toggling into fullscreen mode if disallowed by pref. |
| + fullscreen_enabled = false; |
| + } |
| #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); |
| - 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(); |
| } |