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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_command_handler.mm

Issue 1681463003: Preference for Presentation Mode/Fullscreen Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2623
Patch Set: Created 4 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h" 5 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/mac/foundation_util.h" 8 #import "base/mac/foundation_util.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #import "chrome/browser/app_controller_mac.h" 10 #import "chrome/browser/app_controller_mac.h"
11 #include "chrome/browser/fullscreen.h" 11 #include "chrome/browser/fullscreen.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 13 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/ui/browser_commands.h" 14 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/browser_window.h" 16 #include "chrome/browser/ui/browser_window.h"
17 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 17 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
18 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" 18 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
19 #include "chrome/common/pref_names.h"
19 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
20 #include "content/public/browser/user_metrics.h" 21 #include "content/public/browser/user_metrics.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #import "ui/base/cocoa/cocoa_base_utils.h" 23 #import "ui/base/cocoa/cocoa_base_utils.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/l10n/l10n_util_mac.h" 25 #include "ui/base/l10n/l10n_util_mac.h"
25 26
26 namespace { 27 namespace {
27 28
28 void SetToggleState(bool toggled, id item) { 29 void SetToggleState(bool toggled, id item) {
(...skipping 17 matching lines...) Expand all
46 DCHECK(browser); 47 DCHECK(browser);
47 48
48 // On Windows this logic happens in bookmark_bar_view.cc. This simply updates 49 // On Windows this logic happens in bookmark_bar_view.cc. This simply updates
49 // the menu item; it does not display the bookmark bar itself. 50 // the menu item; it does not display the bookmark bar itself.
50 if (tag == IDC_SHOW_BOOKMARK_BAR) { 51 if (tag == IDC_SHOW_BOOKMARK_BAR) {
51 SetToggleState(browser->window()->IsBookmarkBarVisible(), item); 52 SetToggleState(browser->window()->IsBookmarkBarVisible(), item);
52 return; 53 return;
53 } 54 }
54 55
55 if (tag == IDC_TOGGLE_FULLSCREEN_TOOLBAR) { 56 if (tag == IDC_TOGGLE_FULLSCREEN_TOOLBAR) {
56 SetToggleState(browser->window()->ShouldHideFullscreenToolbar(), item); 57 PrefService* prefs = browser->profile()->GetPrefs();
58 SetToggleState(prefs->GetBoolean(prefs::kHideFullscreenToolbar), item);
57 return; 59 return;
58 } 60 }
59 61
60 // Update the checked/unchecked state of items in the encoding menu. 62 // Update the checked/unchecked state of items in the encoding menu.
61 // On Windows, this logic is part of |EncodingMenuModel| in 63 // On Windows, this logic is part of |EncodingMenuModel| in
62 // browser/ui/views/toolbar_view.h. 64 // browser/ui/views/toolbar_view.h.
63 EncodingMenuController encoding_controller; 65 EncodingMenuController encoding_controller;
64 if (!encoding_controller.DoesCommandBelongToEncodingMenu(tag)) 66 if (!encoding_controller.DoesCommandBelongToEncodingMenu(tag))
65 return; 67 return;
66 68
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { 166 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
165 if (chrome::mac::SupportsSystemFullscreen()) 167 if (chrome::mac::SupportsSystemFullscreen())
166 [menuItem setTitle:GetTitleForFullscreenMenuItem(browser)]; 168 [menuItem setTitle:GetTitleForFullscreenMenuItem(browser)];
167 else 169 else
168 [menuItem setHidden:YES]; 170 [menuItem setHidden:YES];
169 } 171 }
170 break; 172 break;
171 } 173 }
172 case IDC_PRESENTATION_MODE: { 174 case IDC_PRESENTATION_MODE: {
173 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { 175 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
174 [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)]; 176 if (chrome::mac::SupportsSystemFullscreen()) {
177 [menuItem setHidden:YES];
178 enable = NO;
179 } else {
180 [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)];
181 }
175 } 182 }
176 break; 183 break;
177 } 184 }
178 case IDC_SHOW_SIGNIN: { 185 case IDC_SHOW_SIGNIN: {
179 Profile* original_profile = browser->profile()->GetOriginalProfile(); 186 Profile* original_profile = browser->profile()->GetOriginalProfile();
180 [AppController updateSigninItem:item 187 [AppController updateSigninItem:item
181 shouldShow:enable 188 shouldShow:enable
182 currentProfile:original_profile]; 189 currentProfile:original_profile];
183 content::RecordAction( 190 content::RecordAction(
184 base::UserMetricsAction("Signin_Impression_FromMenu")); 191 base::UserMetricsAction("Signin_Impression_FromMenu"));
(...skipping 15 matching lines...) Expand all
200 // item. This only affects the bookmark page menu item under the main 207 // item. This only affects the bookmark page menu item under the main
201 // menu. The bookmark page menu item under the app menu has its 208 // menu. The bookmark page menu item under the app menu has its
202 // visibility controlled by AppMenuModel. 209 // visibility controlled by AppMenuModel.
203 bool shouldHide = 210 bool shouldHide =
204 chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile()); 211 chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile());
205 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); 212 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
206 [menuItem setHidden:shouldHide]; 213 [menuItem setHidden:shouldHide];
207 break; 214 break;
208 } 215 }
209 case IDC_TOGGLE_FULLSCREEN_TOOLBAR: { 216 case IDC_TOGGLE_FULLSCREEN_TOOLBAR: {
210 // TODO(spqchan): Implement a preferences for this command and replace 217 if (!chrome::mac::SupportsSystemFullscreen()) {
211 // the Presentation Mode menu item with item. 218 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
212 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
213 [menuItem setHidden:YES]; 219 [menuItem setHidden:YES];
214 enable = false; 220 enable = NO;
215 } 221 }
216 break;
217 } 222 }
218 default: 223 default:
219 // Special handling for the contents of the Text Encoding submenu. On 224 // Special handling for the contents of the Text Encoding submenu. On
220 // Mac OS, instead of enabling/disabling the top-level menu item, we 225 // Mac OS, instead of enabling/disabling the top-level menu item, we
221 // enable/disable the submenu's contents (per Apple's HIG). 226 // enable/disable the submenu's contents (per Apple's HIG).
222 EncodingMenuController encoding_controller; 227 EncodingMenuController encoding_controller;
223 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) 228 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag))
224 enable &= chrome::IsCommandEnabled(browser, IDC_ENCODING_MENU); 229 enable &= chrome::IsCommandEnabled(browser, IDC_ENCODING_MENU);
225 } 230 }
226 231
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // the background" in this case. 266 // the background" in this case.
262 modifierFlags &= ~NSCommandKeyMask; 267 modifierFlags &= ~NSCommandKeyMask;
263 } 268 }
264 chrome::ExecuteCommandWithDisposition( 269 chrome::ExecuteCommandWithDisposition(
265 FindBrowserForSender(sender, window), command, 270 FindBrowserForSender(sender, window), command,
266 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent], 271 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent],
267 modifierFlags)); 272 modifierFlags));
268 } 273 }
269 274
270 @end 275 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_cocoa.mm ('k') | chrome/browser/ui/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698