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

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

Issue 2689383002: Commands should have consistent behaviors across different modes
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
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..f72b2b1e28a0e0651a8925b4e2cce2a0fa0e5232 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -848,17 +848,20 @@ void BrowserCommandController::InitCommandState() {
// static
void BrowserCommandController::UpdateSharedCommandsForIncognitoAvailability(
CommandUpdater* command_updater,
- Profile* profile) {
+ Profile* profile,
+ bool is_fullscreen) {
const bool guest_session = profile->IsGuestSession();
// TODO(mlerman): Make GetAvailability account for profile->IsGuestSession().
IncognitoModePrefs::Availability incognito_availability =
IncognitoModePrefs::GetAvailability(profile->GetPrefs());
command_updater->UpdateCommandEnabled(
IDC_NEW_WINDOW,
- incognito_availability != IncognitoModePrefs::FORCED);
+ !is_fullscreen && incognito_availability != IncognitoModePrefs::FORCED);
msw 2017/02/15 18:40:51 I should have asked earlier, but do we actually ne
Hzj_jie 2017/02/15 21:20:16 Yes, patch set 2 of change https://codereview.chro
msw 2017/02/15 22:38:18 My naive understanding is that it would be safe to
command_updater->UpdateCommandEnabled(
IDC_NEW_INCOGNITO_WINDOW,
- incognito_availability != IncognitoModePrefs::DISABLED && !guest_session);
+ !is_fullscreen &&
+ incognito_availability != IncognitoModePrefs::DISABLED &&
+ !guest_session);
const bool forced_incognito =
incognito_availability == IncognitoModePrefs::FORCED ||
@@ -883,7 +886,9 @@ void BrowserCommandController::UpdateSharedCommandsForIncognitoAvailability(
}
void BrowserCommandController::UpdateCommandsForIncognitoAvailability() {
- UpdateSharedCommandsForIncognitoAvailability(&command_updater_, profile());
+ const bool is_fullscreen = window() && window()->IsFullscreen();
+ UpdateSharedCommandsForIncognitoAvailability(
+ &command_updater_, profile(), is_fullscreen);
if (!IsShowingMainUI()) {
command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS, false);
@@ -1049,16 +1054,6 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() {
#endif
UpdateShowSyncState(show_main_ui);
- // Settings page/subpages are forced to open in normal mode. We disable these
- // commands for guest sessions and when incognito is forced.
- const bool options_enabled = show_main_ui &&
- IncognitoModePrefs::GetAvailability(
- profile()->GetPrefs()) != IncognitoModePrefs::FORCED;
- const bool guest_session = profile()->IsGuestSession();
- command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled);
msw 2017/02/15 18:40:51 Now that I'm looking closer, I'm not sure this is
Hzj_jie 2017/02/15 21:20:16 Yes, as I have replied in the previous comment, we
msw 2017/02/15 22:38:18 If it matches the test expectations, then it's pro
- command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS,
msw 2017/02/15 18:40:51 Similarly, this disables IDC_IMPORT_SETTINGS for g
Hzj_jie 2017/02/15 21:20:17 Ditto.
- options_enabled && !guest_session);
-
command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
@@ -1081,16 +1076,14 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode() {
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();
+ UpdateCommandsForIncognitoAvailability();
+ UpdateTabRestoreCommandState();
}
void BrowserCommandController::UpdatePrintingState() {
@@ -1129,12 +1122,14 @@ void BrowserCommandController::UpdateReloadStopState(bool is_loading,
}
void BrowserCommandController::UpdateTabRestoreCommandState() {
+ const bool is_fullscreen = window() && window()->IsFullscreen();
sessions::TabRestoreService* tab_restore_service =
TabRestoreServiceFactory::GetForProfile(profile());
// The command is enabled if the service hasn't loaded yet to trigger loading.
// The command is updated once the load completes.
command_updater_.UpdateCommandEnabled(
IDC_RESTORE_TAB,
+ !is_fullscreen &&
tab_restore_service &&
(!tab_restore_service->IsLoaded() ||
GetRestoreTabType(browser_) != TabStripModelDelegate::RESTORE_NONE));
« no previous file with comments | « chrome/browser/ui/browser_command_controller.h ('k') | chrome/browser/ui/browser_command_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698