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

Side by Side Diff: chrome/browser/ui/browser_command_controller.cc

Issue 2701973002: Fix an inconsistent behavior in BrowserCommandController (Closed)
Patch Set: Fix the code defect 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_command_controller.h" 5 #include "chrome/browser/ui/browser_command_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1039 command_updater_.UpdateCommandEnabled( 1039 command_updater_.UpdateCommandEnabled(
1040 IDC_FOCUS_INFOBARS, main_not_fullscreen); 1040 IDC_FOCUS_INFOBARS, main_not_fullscreen);
1041 1041
1042 // Show various bits of UI 1042 // Show various bits of UI
1043 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); 1043 command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui);
1044 #if defined(GOOGLE_CHROME_BUILD) 1044 #if defined(GOOGLE_CHROME_BUILD)
1045 command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui); 1045 command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui);
1046 #endif 1046 #endif
1047 UpdateShowSyncState(show_main_ui); 1047 UpdateShowSyncState(show_main_ui);
1048 1048
1049 // Settings page/subpages are forced to open in normal mode. We disable these
1050 // commands for guest sessions and when incognito is forced.
1051 const bool options_enabled = show_main_ui &&
1052 IncognitoModePrefs::GetAvailability(
1053 profile()->GetPrefs()) != IncognitoModePrefs::FORCED;
1054 const bool guest_session = profile()->IsGuestSession();
1055 command_updater_.UpdateCommandEnabled(IDC_OPTIONS, options_enabled);
1056 command_updater_.UpdateCommandEnabled(IDC_IMPORT_SETTINGS,
1057 options_enabled && !guest_session);
1058
1059 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); 1049 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
1060 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); 1050 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
1061 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); 1051 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
1062 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); 1052 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui);
1063 1053
1064 if (base::debug::IsProfilingSupported()) 1054 if (base::debug::IsProfilingSupported())
1065 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); 1055 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui);
1066 1056
1067 #if !defined(OS_MACOSX) 1057 #if !defined(OS_MACOSX)
1068 // Disable toggling into fullscreen mode if disallowed by pref. 1058 // Disable toggling into fullscreen mode if disallowed by pref.
1069 const bool fullscreen_enabled = is_fullscreen || 1059 const bool fullscreen_enabled = is_fullscreen ||
1070 profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed); 1060 profile()->GetPrefs()->GetBoolean(prefs::kFullscreenAllowed);
1071 #else 1061 #else
1072 const bool fullscreen_enabled = true; 1062 const bool fullscreen_enabled = true;
1073 #endif 1063 #endif
1074 1064
1075 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled); 1065 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled);
1076 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR, 1066 command_updater_.UpdateCommandEnabled(IDC_TOGGLE_FULLSCREEN_TOOLBAR,
1077 fullscreen_enabled); 1067 fullscreen_enabled);
1078 1068
1079 UpdateCommandsForBookmarkBar(); 1069 UpdateCommandsForBookmarkBar();
1070 UpdateCommandsForIncognitoAvailability();
msw 2017/02/23 19:07:28 I was slightly worried that this updates the enabl
Hzj_jie 2017/02/23 22:00:09 I think a simple rule to avoid the conflict is to
msw 2017/02/23 22:19:43 I generally agree, but doubt the effectiveness of
1080 } 1071 }
1081 1072
1082 void BrowserCommandController::UpdatePrintingState() { 1073 void BrowserCommandController::UpdatePrintingState() {
1083 bool print_enabled = CanPrint(browser_); 1074 bool print_enabled = CanPrint(browser_);
1084 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled); 1075 command_updater_.UpdateCommandEnabled(IDC_PRINT, print_enabled);
1085 #if BUILDFLAG(ENABLE_BASIC_PRINTING) 1076 #if BUILDFLAG(ENABLE_BASIC_PRINTING)
1086 command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT, 1077 command_updater_.UpdateCommandEnabled(IDC_BASIC_PRINT,
1087 CanBasicPrint(browser_)); 1078 CanBasicPrint(browser_));
1088 #endif // ENABLE_BASIC_PRINTING 1079 #endif // ENABLE_BASIC_PRINTING
1089 } 1080 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1150
1160 BrowserWindow* BrowserCommandController::window() { 1151 BrowserWindow* BrowserCommandController::window() {
1161 return browser_->window(); 1152 return browser_->window();
1162 } 1153 }
1163 1154
1164 Profile* BrowserCommandController::profile() { 1155 Profile* BrowserCommandController::profile() {
1165 return browser_->profile(); 1156 return browser_->profile();
1166 } 1157 }
1167 1158
1168 } // namespace chrome 1159 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698