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

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

Issue 1650713003: Preference for Presentation Mode/Fullscreen Toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 BrowserWindowController* controller = 57 PrefService* prefs = browser->profile()->GetPrefs();
57 [browser->window()->GetNativeWindow() windowController]; 58 SetToggleState(prefs->GetBoolean(prefs::kHideFullscreenToolbar), item);
58 SetToggleState([controller shouldHideFullscreenToolbar], item);
59 return; 59 return;
60 } 60 }
61 61
62 // Update the checked/unchecked state of items in the encoding menu. 62 // Update the checked/unchecked state of items in the encoding menu.
63 // On Windows, this logic is part of |EncodingMenuModel| in 63 // On Windows, this logic is part of |EncodingMenuModel| in
64 // browser/ui/views/toolbar_view.h. 64 // browser/ui/views/toolbar_view.h.
65 EncodingMenuController encoding_controller; 65 EncodingMenuController encoding_controller;
66 if (!encoding_controller.DoesCommandBelongToEncodingMenu(tag)) 66 if (!encoding_controller.DoesCommandBelongToEncodingMenu(tag))
67 return; 67 return;
68 68
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { 166 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
167 if (chrome::mac::SupportsSystemFullscreen()) 167 if (chrome::mac::SupportsSystemFullscreen())
168 [menuItem setTitle:GetTitleForFullscreenMenuItem(browser)]; 168 [menuItem setTitle:GetTitleForFullscreenMenuItem(browser)];
169 else 169 else
170 [menuItem setHidden:YES]; 170 [menuItem setHidden:YES];
171 } 171 }
172 break; 172 break;
173 } 173 }
174 case IDC_PRESENTATION_MODE: { 174 case IDC_PRESENTATION_MODE: {
175 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { 175 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
176 [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)]; 176 if (chrome::mac::SupportsSystemFullscreen()) {
177 [menuItem setHidden:YES];
178 enable = NO;
179 } else {
180 [menuItem setTitle:GetTitleForPresentationModeMenuItem(browser)];
181 }
177 } 182 }
178 break; 183 break;
179 } 184 }
180 case IDC_SHOW_SIGNIN: { 185 case IDC_SHOW_SIGNIN: {
181 Profile* original_profile = browser->profile()->GetOriginalProfile(); 186 Profile* original_profile = browser->profile()->GetOriginalProfile();
182 [AppController updateSigninItem:item 187 [AppController updateSigninItem:item
183 shouldShow:enable 188 shouldShow:enable
184 currentProfile:original_profile]; 189 currentProfile:original_profile];
185 content::RecordAction( 190 content::RecordAction(
186 base::UserMetricsAction("Signin_Impression_FromMenu")); 191 base::UserMetricsAction("Signin_Impression_FromMenu"));
(...skipping 15 matching lines...) Expand all
202 // 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
203 // 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
204 // visibility controlled by AppMenuModel. 209 // visibility controlled by AppMenuModel.
205 bool shouldHide = 210 bool shouldHide =
206 chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile()); 211 chrome::ShouldRemoveBookmarkOpenPagesUI(browser->profile());
207 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); 212 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
208 [menuItem setHidden:shouldHide]; 213 [menuItem setHidden:shouldHide];
209 break; 214 break;
210 } 215 }
211 case IDC_TOGGLE_FULLSCREEN_TOOLBAR: { 216 case IDC_TOGGLE_FULLSCREEN_TOOLBAR: {
212 // TODO(spqchan): Implement a preferences for this command and replace 217 if (!chrome::mac::SupportsSystemFullscreen()) {
213 // the Presentation Mode menu item with item. 218 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
214 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
215 [menuItem setHidden:YES]; 219 [menuItem setHidden:YES];
216 enable = false; 220 enable = NO;
217 } 221 }
218 break;
219 } 222 }
220 default: 223 default:
221 // Special handling for the contents of the Text Encoding submenu. On 224 // Special handling for the contents of the Text Encoding submenu. On
222 // 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
223 // enable/disable the submenu's contents (per Apple's HIG). 226 // enable/disable the submenu's contents (per Apple's HIG).
224 EncodingMenuController encoding_controller; 227 EncodingMenuController encoding_controller;
225 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) 228 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag))
226 enable &= chrome::IsCommandEnabled(browser, IDC_ENCODING_MENU); 229 enable &= chrome::IsCommandEnabled(browser, IDC_ENCODING_MENU);
227 } 230 }
228 231
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // the background" in this case. 266 // the background" in this case.
264 modifierFlags &= ~NSCommandKeyMask; 267 modifierFlags &= ~NSCommandKeyMask;
265 } 268 }
266 chrome::ExecuteCommandWithDisposition( 269 chrome::ExecuteCommandWithDisposition(
267 FindBrowserForSender(sender, window), command, 270 FindBrowserForSender(sender, window), command,
268 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent], 271 ui::WindowOpenDispositionFromNSEventWithFlags([NSApp currentEvent],
269 modifierFlags)); 272 modifierFlags));
270 } 273 }
271 274
272 @end 275 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698