Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #import "chrome/browser/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 return cache.ProfileIsSigninRequiredAtIndex(profile_index); | 205 return cache.ProfileIsSigninRequiredAtIndex(profile_index); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace | 208 } // namespace |
| 209 | 209 |
| 210 @interface AppController () <HandoffActiveURLObserverBridgeDelegate> | 210 @interface AppController () <HandoffActiveURLObserverBridgeDelegate> |
| 211 | 211 |
| 212 - (void)initMenuState; | 212 - (void)initMenuState; |
| 213 - (void)initProfileMenu; | 213 - (void)initProfileMenu; |
| 214 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; | 214 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; |
| 215 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; | |
| 216 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 215 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
| 217 - (void)getUrl:(NSAppleEventDescriptor*)event | 216 - (void)getUrl:(NSAppleEventDescriptor*)event |
| 218 withReply:(NSAppleEventDescriptor*)reply; | 217 withReply:(NSAppleEventDescriptor*)reply; |
| 219 - (void)activeSpaceDidChange:(NSNotification*)inNotification; | 218 - (void)activeSpaceDidChange:(NSNotification*)inNotification; |
| 220 - (void)checkForAnyKeyWindows; | 219 - (void)checkForAnyKeyWindows; |
| 221 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 220 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
| 222 - (BOOL)shouldQuitWithInProgressDownloads; | 221 - (BOOL)shouldQuitWithInProgressDownloads; |
| 223 - (void)executeApplication:(id)sender; | 222 - (void)executeApplication:(id)sender; |
| 224 - (void)profileWasRemoved:(const base::FilePath&)profilePath; | 223 - (void)profileWasRemoved:(const base::FilePath&)profilePath; |
| 225 | 224 |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 } else if (action == @selector(showPreferences:)) { | 992 } else if (action == @selector(showPreferences:)) { |
| 994 enable = YES; | 993 enable = YES; |
| 995 } else if (action == @selector(orderFrontStandardAboutPanel:)) { | 994 } else if (action == @selector(orderFrontStandardAboutPanel:)) { |
| 996 enable = YES; | 995 enable = YES; |
| 997 } else if (action == @selector(commandFromDock:)) { | 996 } else if (action == @selector(commandFromDock:)) { |
| 998 enable = YES; | 997 enable = YES; |
| 999 } else if (action == @selector(toggleConfirmToQuit:)) { | 998 } else if (action == @selector(toggleConfirmToQuit:)) { |
| 1000 [self updateConfirmToQuitPrefMenuItem:static_cast<NSMenuItem*>(item)]; | 999 [self updateConfirmToQuitPrefMenuItem:static_cast<NSMenuItem*>(item)]; |
| 1001 enable = YES; | 1000 enable = YES; |
| 1002 } else if (action == @selector(toggleDisplayMessageCenter:)) { | 1001 } else if (action == @selector(toggleDisplayMessageCenter:)) { |
| 1003 NSMenuItem* menuItem = static_cast<NSMenuItem*>(item); | 1002 enable = NO; |
|
Robert Sesek
2015/09/15 22:07:08
Leave a TODO and point to the bug # ?
dewittj
2015/09/15 22:52:22
Done.
| |
| 1004 [self updateDisplayMessageCenterPrefMenuItem:menuItem]; | |
| 1005 enable = YES; | |
| 1006 } else if (action == @selector(executeApplication:)) { | 1003 } else if (action == @selector(executeApplication:)) { |
| 1007 enable = YES; | 1004 enable = YES; |
| 1008 } | 1005 } |
| 1009 return enable; | 1006 return enable; |
| 1010 } | 1007 } |
| 1011 | 1008 |
| 1012 // Called when the user picks a menu item when there are no key windows, or when | 1009 // Called when the user picks a menu item when there are no key windows, or when |
| 1013 // there is no foreground browser window. Calls through to the browser object to | 1010 // there is no foreground browser window. Calls through to the browser object to |
| 1014 // execute the command. This assumes that the command is supported and doesn't | 1011 // execute the command. This assumes that the command is supported and doesn't |
| 1015 // check, otherwise it should have been disabled in the UI in | 1012 // check, otherwise it should have been disabled in the UI in |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1319 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; | 1316 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; |
| 1320 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, | 1317 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, |
| 1321 base::SysNSStringToUTF16(acceleratorString)); | 1318 base::SysNSStringToUTF16(acceleratorString)); |
| 1322 [item setTitle:title]; | 1319 [item setTitle:title]; |
| 1323 | 1320 |
| 1324 const PrefService* prefService = g_browser_process->local_state(); | 1321 const PrefService* prefService = g_browser_process->local_state(); |
| 1325 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); | 1322 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); |
| 1326 [item setState:enabled ? NSOnState : NSOffState]; | 1323 [item setState:enabled ? NSOnState : NSOffState]; |
| 1327 } | 1324 } |
| 1328 | 1325 |
| 1329 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item { | 1326 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item { |
|
Robert Sesek
2015/09/15 22:07:08
You can remove this. Only the -toggle… method is r
dewittj
2015/09/15 22:52:22
Done.
| |
| 1330 const PrefService* prefService = g_browser_process->local_state(); | |
| 1331 bool enabled = prefService->GetBoolean(prefs::kMessageCenterShowIcon); | |
| 1332 // The item should be checked if "show icon" is false, since the text reads | |
| 1333 // "Hide notification center icon." | |
| 1334 [item setState:enabled ? NSOffState : NSOnState]; | |
| 1335 } | 1327 } |
| 1336 | 1328 |
| 1337 - (void)registerServicesMenuTypesTo:(NSApplication*)app { | 1329 - (void)registerServicesMenuTypesTo:(NSApplication*)app { |
| 1338 // Note that RenderWidgetHostViewCocoa implements NSServicesRequests which | 1330 // Note that RenderWidgetHostViewCocoa implements NSServicesRequests which |
| 1339 // handles requests from services. | 1331 // handles requests from services. |
| 1340 NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; | 1332 NSArray* types = [NSArray arrayWithObjects:NSStringPboardType, nil]; |
| 1341 [app registerServicesMenuSendTypes:types returnTypes:types]; | 1333 [app registerServicesMenuSendTypes:types returnTypes:types]; |
| 1342 } | 1334 } |
| 1343 | 1335 |
| 1344 - (Profile*)lastProfile { | 1336 - (Profile*)lastProfile { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1460 } | 1452 } |
| 1461 } | 1453 } |
| 1462 | 1454 |
| 1463 - (IBAction)toggleConfirmToQuit:(id)sender { | 1455 - (IBAction)toggleConfirmToQuit:(id)sender { |
| 1464 PrefService* prefService = g_browser_process->local_state(); | 1456 PrefService* prefService = g_browser_process->local_state(); |
| 1465 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); | 1457 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); |
| 1466 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); | 1458 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); |
| 1467 } | 1459 } |
| 1468 | 1460 |
| 1469 - (IBAction)toggleDisplayMessageCenter:(id)sender { | 1461 - (IBAction)toggleDisplayMessageCenter:(id)sender { |
| 1470 PrefService* prefService = g_browser_process->local_state(); | |
| 1471 bool enabled = prefService->GetBoolean(prefs::kMessageCenterShowIcon); | |
| 1472 prefService->SetBoolean(prefs::kMessageCenterShowIcon, !enabled); | |
| 1473 } | 1462 } |
| 1474 | 1463 |
| 1475 // Explicitly bring to the foreground when creating new windows from the dock. | 1464 // Explicitly bring to the foreground when creating new windows from the dock. |
| 1476 - (void)commandFromDock:(id)sender { | 1465 - (void)commandFromDock:(id)sender { |
| 1477 [NSApp activateIgnoringOtherApps:YES]; | 1466 [NSApp activateIgnoringOtherApps:YES]; |
| 1478 [self commandDispatch:sender]; | 1467 [self commandDispatch:sender]; |
| 1479 } | 1468 } |
| 1480 | 1469 |
| 1481 - (NSMenu*)applicationDockMenu:(NSApplication*)sender { | 1470 - (NSMenu*)applicationDockMenu:(NSApplication*)sender { |
| 1482 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; | 1471 NSMenu* dockMenu = [[[NSMenu alloc] initWithTitle: @""] autorelease]; |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1720 | 1709 |
| 1721 //--------------------------------------------------------------------------- | 1710 //--------------------------------------------------------------------------- |
| 1722 | 1711 |
| 1723 namespace app_controller_mac { | 1712 namespace app_controller_mac { |
| 1724 | 1713 |
| 1725 bool IsOpeningNewWindow() { | 1714 bool IsOpeningNewWindow() { |
| 1726 return g_is_opening_new_window; | 1715 return g_is_opening_new_window; |
| 1727 } | 1716 } |
| 1728 | 1717 |
| 1729 } // namespace app_controller_mac | 1718 } // namespace app_controller_mac |
| OLD | NEW |