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

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

Issue 11359148: Merge 166410 - Constrained Window Cocoa: Disable fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/app/chrome_command_ids.h" 7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/defaults.h" 9 #include "chrome/browser/defaults.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" 11 #include "chrome/browser/prefs/incognito_mode_prefs.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/printing/print_preview_tab_controller.h" 13 #include "chrome/browser/printing/print_preview_tab_controller.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/sessions/tab_restore_service.h" 16 #include "chrome/browser/sessions/tab_restore_service.h"
17 #include "chrome/browser/sessions/tab_restore_service_factory.h" 17 #include "chrome/browser/sessions/tab_restore_service_factory.h"
18 #include "chrome/browser/shell_integration.h" 18 #include "chrome/browser/shell_integration.h"
19 #include "chrome/browser/sync/profile_sync_service.h" 19 #include "chrome/browser/sync/profile_sync_service.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 20 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 21 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
22 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
24 #include "chrome/browser/ui/browser_tabstrip.h" 24 #include "chrome/browser/ui/browser_tabstrip.h"
25 #include "chrome/browser/ui/browser_window.h" 25 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/chrome_pages.h" 26 #include "chrome/browser/ui/chrome_pages.h"
27 #include "chrome/browser/ui/tab_contents/tab_contents.h" 27 #include "chrome/browser/ui/tab_contents/tab_contents.h"
28 #include "chrome/browser/ui/tabs/tab_strip_model.h" 28 #include "chrome/browser/ui/tabs/tab_strip_model.h"
29 #include "chrome/browser/ui/tabs/tab_strip_model_utils.h"
29 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" 30 #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h"
30 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
31 #include "chrome/common/pref_names.h" 32 #include "chrome/common/pref_names.h"
32 #include "chrome/common/profiling.h" 33 #include "chrome/common/profiling.h"
33 #include "content/public/browser/native_web_keyboard_event.h" 34 #include "content/public/browser/native_web_keyboard_event.h"
34 #include "content/public/browser/navigation_controller.h" 35 #include "content/public/browser/navigation_controller.h"
35 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_details.h" 37 #include "content/public/browser/notification_details.h"
37 #include "content/public/browser/notification_source.h" 38 #include "content/public/browser/notification_source.h"
38 #include "content/public/browser/user_metrics.h" 39 #include "content/public/browser/user_metrics.h"
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 command_updater_.UpdateCommandEnabled( 850 command_updater_.UpdateCommandEnabled(
850 IDC_SHOW_SYNC_SETUP, profile()->GetOriginalProfile()->IsSyncAccessible()); 851 IDC_SHOW_SYNC_SETUP, profile()->GetOriginalProfile()->IsSyncAccessible());
851 852
852 // Initialize other commands based on the window type. 853 // Initialize other commands based on the window type.
853 bool normal_window = browser_->is_type_tabbed(); 854 bool normal_window = browser_->is_type_tabbed();
854 855
855 // Navigation commands 856 // Navigation commands
856 command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window); 857 command_updater_.UpdateCommandEnabled(IDC_HOME, normal_window);
857 858
858 // Window management commands 859 // Window management commands
859 // TODO(rohitrao): Disable fullscreen on non-Lion?
860 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN,
861 !(browser_->is_type_panel() && browser_->is_app()));
862 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window); 860 command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
863 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB, 861 command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
864 normal_window); 862 normal_window);
865 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window); 863 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window);
866 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window); 864 command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window);
867 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window); 865 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window);
868 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window); 866 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window);
869 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window); 867 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window);
870 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window); 868 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_3, normal_window);
871 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window); 869 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_4, normal_window);
872 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window); 870 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_5, normal_window);
873 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window); 871 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_6, normal_window);
874 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window); 872 command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_7, normal_window);
875 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window); 873 command_updater_.UpdateCommandEnabled(IDC_SELECT_LAST_TAB, normal_window);
876 #if defined(OS_WIN) 874 #if defined(OS_WIN)
877 const bool metro_mode = base::win::IsMetroProcess(); 875 const bool metro_mode = base::win::IsMetroProcess();
878 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_ENABLE, metro_mode); 876 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_ENABLE, metro_mode);
879 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_DISABLE, metro_mode); 877 command_updater_.UpdateCommandEnabled(IDC_METRO_SNAP_DISABLE, metro_mode);
880 int restart_mode = metro_mode ? 878 int restart_mode = metro_mode ?
881 IDC_WIN8_DESKTOP_RESTART : IDC_WIN8_METRO_RESTART; 879 IDC_WIN8_DESKTOP_RESTART : IDC_WIN8_METRO_RESTART;
882 command_updater_.UpdateCommandEnabled(restart_mode, normal_window); 880 command_updater_.UpdateCommandEnabled(restart_mode, normal_window);
883 #endif 881 #endif
884 #if defined(OS_MACOSX)
885 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window); 882 command_updater_.UpdateCommandEnabled(IDC_TABPOSE, normal_window);
886 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE,
887 !(browser_->is_type_panel() && browser_->is_app()));
888 #endif
889 883
890 // Find-in-page 884 // Find-in-page
891 command_updater_.UpdateCommandEnabled(IDC_FIND, !browser_->is_devtools()); 885 command_updater_.UpdateCommandEnabled(IDC_FIND, !browser_->is_devtools());
892 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT, 886 command_updater_.UpdateCommandEnabled(IDC_FIND_NEXT,
893 !browser_->is_devtools()); 887 !browser_->is_devtools());
894 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS, 888 command_updater_.UpdateCommandEnabled(IDC_FIND_PREVIOUS,
895 !browser_->is_devtools()); 889 !browser_->is_devtools());
896 890
897 // Show various bits of UI 891 // Show various bits of UI
898 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window); 892 command_updater_.UpdateCommandEnabled(IDC_CLEAR_BROWSING_DATA, normal_window);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1086
1093 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui); 1087 command_updater_.UpdateCommandEnabled(IDC_EDIT_SEARCH_ENGINES, show_main_ui);
1094 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui); 1088 command_updater_.UpdateCommandEnabled(IDC_VIEW_PASSWORDS, show_main_ui);
1095 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui); 1089 command_updater_.UpdateCommandEnabled(IDC_ABOUT, show_main_ui);
1096 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui); 1090 command_updater_.UpdateCommandEnabled(IDC_SHOW_APP_MENU, show_main_ui);
1097 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC) 1091 #if defined (ENABLE_PROFILING) && !defined(NO_TCMALLOC)
1098 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui); 1092 command_updater_.UpdateCommandEnabled(IDC_PROFILING_ENABLED, show_main_ui);
1099 #endif 1093 #endif
1100 1094
1101 // Disable explicit fullscreen toggling when in metro snap mode. 1095 // Disable explicit fullscreen toggling when in metro snap mode.
1102 command_updater_.UpdateCommandEnabled( 1096 bool fullscreen_enabled = !browser_->is_type_panel() &&
1103 IDC_FULLSCREEN, 1097 !browser_->is_app() &&
1104 fullscreen_mode != FULLSCREEN_METRO_SNAP); 1098 fullscreen_mode != FULLSCREEN_METRO_SNAP;
1099 #if defined(OS_MACOSX)
1100 // The Mac implementation doesn't support switching to fullscreen while
1101 // a tab modal dialog is displayed.
1102 int tabIndex = chrome::IndexOfFirstBlockedTab(browser_->tab_strip_model());
1103 bool has_blocked_tab = tabIndex != browser_->tab_strip_model()->count();
1104 fullscreen_enabled &= !has_blocked_tab;
1105 #endif
1106
1107 command_updater_.UpdateCommandEnabled(IDC_FULLSCREEN, fullscreen_enabled);
1108 command_updater_.UpdateCommandEnabled(IDC_PRESENTATION_MODE,
1109 fullscreen_enabled);
1105 1110
1106 UpdateCommandsForBookmarkBar(); 1111 UpdateCommandsForBookmarkBar();
1107 UpdateCommandsForMultipleProfiles(); 1112 UpdateCommandsForMultipleProfiles();
1108 } 1113 }
1109 1114
1110 void BrowserCommandController::UpdateCommandsForMultipleProfiles() { 1115 void BrowserCommandController::UpdateCommandsForMultipleProfiles() {
1111 bool show_main_ui = IsShowingMainUI(window() && window()->IsFullscreen()); 1116 bool show_main_ui = IsShowingMainUI(window() && window()->IsFullscreen());
1112 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU, 1117 command_updater_.UpdateCommandEnabled(IDC_SHOW_AVATAR_MENU,
1113 show_main_ui && 1118 show_main_ui &&
1114 !profile()->IsOffTheRecord() && 1119 !profile()->IsOffTheRecord() &&
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1176
1172 BrowserWindow* BrowserCommandController::window() { 1177 BrowserWindow* BrowserCommandController::window() {
1173 return browser_->window(); 1178 return browser_->window();
1174 } 1179 }
1175 1180
1176 Profile* BrowserCommandController::profile() { 1181 Profile* BrowserCommandController::profile() {
1177 return browser_->profile(); 1182 return browser_->profile();
1178 } 1183 }
1179 1184
1180 } // namespace chrome 1185 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/cocoa/browser_window_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698