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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" | 59 #import "chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.h" |
60 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" | 60 #include "chrome/browser/ui/cocoa/apps/quit_with_apps_controller_mac.h" |
61 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 61 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
62 #import "chrome/browser/ui/cocoa/confirm_quit.h" | 62 #import "chrome/browser/ui/cocoa/confirm_quit.h" |
63 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 63 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
64 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 64 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
65 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h" | 65 #include "chrome/browser/ui/cocoa/handoff_active_url_observer_bridge.h" |
66 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" | 66 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
67 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 67 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
68 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" | 68 #import "chrome/browser/ui/cocoa/profiles/profile_menu_controller.h" |
69 #import "chrome/browser/ui/cocoa/renderer_context_menu/share_menu_controller.h" | |
69 #include "chrome/browser/ui/extensions/application_launch.h" | 70 #include "chrome/browser/ui/extensions/application_launch.h" |
70 #include "chrome/browser/ui/host_desktop.h" | 71 #include "chrome/browser/ui/host_desktop.h" |
71 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 72 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
72 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | 73 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
73 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 74 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
74 #include "chrome/browser/ui/user_manager.h" | 75 #include "chrome/browser/ui/user_manager.h" |
75 #include "chrome/browser/web_applications/web_app_mac.h" | 76 #include "chrome/browser/web_applications/web_app_mac.h" |
76 #include "chrome/common/chrome_paths_internal.h" | 77 #include "chrome/common/chrome_paths_internal.h" |
77 #include "chrome/common/chrome_switches.h" | 78 #include "chrome/common/chrome_switches.h" |
78 #include "chrome/common/cloud_print/cloud_print_class_mac.h" | 79 #include "chrome/common/cloud_print/cloud_print_class_mac.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 return false; | 205 return false; |
205 return cache.ProfileIsSigninRequiredAtIndex(profile_index); | 206 return cache.ProfileIsSigninRequiredAtIndex(profile_index); |
206 } | 207 } |
207 | 208 |
208 } // namespace | 209 } // namespace |
209 | 210 |
210 @interface AppController () <HandoffActiveURLObserverBridgeDelegate> | 211 @interface AppController () <HandoffActiveURLObserverBridgeDelegate> |
211 | 212 |
212 - (void)initMenuState; | 213 - (void)initMenuState; |
213 - (void)initProfileMenu; | 214 - (void)initProfileMenu; |
215 - (void)initShareMenu; | |
214 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; | 216 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; |
215 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; | 217 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; |
216 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 218 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
217 - (void)getUrl:(NSAppleEventDescriptor*)event | 219 - (void)getUrl:(NSAppleEventDescriptor*)event |
218 withReply:(NSAppleEventDescriptor*)reply; | 220 withReply:(NSAppleEventDescriptor*)reply; |
219 - (void)activeSpaceDidChange:(NSNotification*)inNotification; | 221 - (void)activeSpaceDidChange:(NSNotification*)inNotification; |
220 - (void)checkForAnyKeyWindows; | 222 - (void)checkForAnyKeyWindows; |
221 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 223 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
222 - (BOOL)shouldQuitWithInProgressDownloads; | 224 - (BOOL)shouldQuitWithInProgressDownloads; |
223 - (void)executeApplication:(id)sender; | 225 - (void)executeApplication:(id)sender; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 addObserver:self | 383 addObserver:self |
382 selector:@selector(willPowerOff:) | 384 selector:@selector(willPowerOff:) |
383 name:NSWorkspaceWillPowerOffNotification | 385 name:NSWorkspaceWillPowerOffNotification |
384 object:nil]; | 386 object:nil]; |
385 | 387 |
386 // Set up the command updater for when there are no windows open | 388 // Set up the command updater for when there are no windows open |
387 [self initMenuState]; | 389 [self initMenuState]; |
388 | 390 |
389 // Initialize the Profile menu. | 391 // Initialize the Profile menu. |
390 [self initProfileMenu]; | 392 [self initProfileMenu]; |
393 | |
394 // Initialize the Share Menu. Limit execution of this method for OSX | |
395 // versions >= 10.9. | |
396 #if defined(MAC_OS_X_VERSION_10_9) && \ | |
397 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 | |
398 [self initShareMenu]; | |
399 #endif | |
Avi (use Gerrit)
2015/05/15 16:13:08
No.
You're doing a compile-time check, and you ne
| |
400 | |
391 } | 401 } |
392 | 402 |
393 - (void)unregisterEventHandlers { | 403 - (void)unregisterEventHandlers { |
394 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; | 404 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; |
395 [em removeEventHandlerForEventClass:kInternetEventClass | 405 [em removeEventHandlerForEventClass:kInternetEventClass |
396 andEventID:kAEGetURL]; | 406 andEventID:kAEGetURL]; |
397 [em removeEventHandlerForEventClass:cloud_print::kAECloudPrintClass | 407 [em removeEventHandlerForEventClass:cloud_print::kAECloudPrintClass |
398 andEventID:cloud_print::kAECloudPrintClass]; | 408 andEventID:cloud_print::kAECloudPrintClass]; |
399 [em removeEventHandlerForEventClass:'WWW!' | 409 [em removeEventHandlerForEventClass:'WWW!' |
400 andEventID:'OURL']; | 410 andEventID:'OURL']; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 // window remain. It seems that the new key window for the app is not set | 606 // window remain. It seems that the new key window for the app is not set |
597 // until after this notification is fired, so a check is performed after the | 607 // until after this notification is fired, so a check is performed after the |
598 // run loop is allowed to spin. | 608 // run loop is allowed to spin. |
599 [self performSelector:@selector(checkForAnyKeyWindows) | 609 [self performSelector:@selector(checkForAnyKeyWindows) |
600 withObject:nil | 610 withObject:nil |
601 afterDelay:0.0]; | 611 afterDelay:0.0]; |
602 } | 612 } |
603 | 613 |
604 - (void)windowDidBecomeMain:(NSNotification*)notify { | 614 - (void)windowDidBecomeMain:(NSNotification*)notify { |
605 Browser* browser = chrome::FindBrowserWithWindow([notify object]); | 615 Browser* browser = chrome::FindBrowserWithWindow([notify object]); |
606 if (browser) | 616 if (browser) |
607 [self windowChangedToProfile:browser->profile()->GetOriginalProfile()]; | 617 [self windowChangedToProfile:browser->profile()->GetOriginalProfile()]; |
Avi (use Gerrit)
2015/05/15 16:13:08
Please don't make random formatting changes.
| |
608 } | 618 } |
609 | 619 |
610 - (void)windowDidResignMain:(NSNotification*)notify { | 620 - (void)windowDidResignMain:(NSNotification*)notify { |
611 if (chrome::GetTotalBrowserCount() == 0) { | 621 if (chrome::GetTotalBrowserCount() == 0) { |
612 [self windowChangedToProfile: | 622 [self windowChangedToProfile: |
613 g_browser_process->profile_manager()->GetLastUsedProfile()]; | 623 g_browser_process->profile_manager()->GetLastUsedProfile()]; |
614 } | 624 } |
615 } | 625 } |
616 | 626 |
617 - (void)activeSpaceDidChange:(NSNotification*)notify { | 627 - (void)activeSpaceDidChange:(NSNotification*)notify { |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 return; | 1314 return; |
1305 } | 1315 } |
1306 | 1316 |
1307 // The controller will unhide the menu if necessary. | 1317 // The controller will unhide the menu if necessary. |
1308 [profileMenu setHidden:YES]; | 1318 [profileMenu setHidden:YES]; |
1309 | 1319 |
1310 profileMenuController_.reset( | 1320 profileMenuController_.reset( |
1311 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]); | 1321 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]); |
1312 } | 1322 } |
1313 | 1323 |
1324 - (void)initShareMenu { | |
1325 NSMenu* mainMenu = [NSApp mainMenu]; | |
1326 | |
1327 shareMenuController_.reset( | |
1328 [[ShareMenuController alloc] initWithMainMenu:mainMenu]); | |
1329 } | |
1330 | |
1314 // The Confirm to Quit preference is atypical in that the preference lives in | 1331 // The Confirm to Quit preference is atypical in that the preference lives in |
1315 // the app menu right above the Quit menu item. This method will refresh the | 1332 // the app menu right above the Quit menu item. This method will refresh the |
1316 // display of that item depending on the preference state. | 1333 // display of that item depending on the preference state. |
1317 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item { | 1334 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item { |
1318 // Format the string so that the correct key equivalent is displayed. | 1335 // Format the string so that the correct key equivalent is displayed. |
1319 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; | 1336 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; |
1320 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, | 1337 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, |
1321 base::SysNSStringToUTF16(acceleratorString)); | 1338 base::SysNSStringToUTF16(acceleratorString)); |
1322 [item setTitle:title]; | 1339 [item setTitle:title]; |
1323 | 1340 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 | 1729 |
1713 //--------------------------------------------------------------------------- | 1730 //--------------------------------------------------------------------------- |
1714 | 1731 |
1715 namespace app_controller_mac { | 1732 namespace app_controller_mac { |
1716 | 1733 |
1717 bool IsOpeningNewWindow() { | 1734 bool IsOpeningNewWindow() { |
1718 return g_is_opening_new_window; | 1735 return g_is_opening_new_window; |
1719 } | 1736 } |
1720 | 1737 |
1721 } // namespace app_controller_mac | 1738 } // namespace app_controller_mac |
OLD | NEW |