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 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 ProfileInfoCache& cache = | 201 ProfileInfoCache& cache = |
| 201 g_browser_process->profile_manager()->GetProfileInfoCache(); | 202 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 202 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 203 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 203 if (profile_index == std::string::npos) | 204 if (profile_index == std::string::npos) |
| 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, |
| 212 NSSharingServiceDelegate> | |
| 211 | 213 |
| 212 - (void)initMenuState; | 214 - (void)initMenuState; |
| 213 - (void)initProfileMenu; | 215 - (void)initProfileMenu; |
| 216 - (void)initShareMenu; | |
| 214 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; | 217 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; |
| 215 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; | 218 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; |
| 216 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 219 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
| 217 - (void)getUrl:(NSAppleEventDescriptor*)event | 220 - (void)getUrl:(NSAppleEventDescriptor*)event |
| 218 withReply:(NSAppleEventDescriptor*)reply; | 221 withReply:(NSAppleEventDescriptor*)reply; |
| 219 - (void)activeSpaceDidChange:(NSNotification*)inNotification; | 222 - (void)activeSpaceDidChange:(NSNotification*)inNotification; |
| 220 - (void)checkForAnyKeyWindows; | 223 - (void)checkForAnyKeyWindows; |
| 221 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; | 224 - (BOOL)userWillWaitForInProgressDownloads:(int)downloadCount; |
| 222 - (BOOL)shouldQuitWithInProgressDownloads; | 225 - (BOOL)shouldQuitWithInProgressDownloads; |
| 223 - (void)executeApplication:(id)sender; | 226 - (void)executeApplication:(id)sender; |
| 224 - (void)profileWasRemoved:(const base::FilePath&)profilePath; | 227 - (void)profileWasRemoved:(const base::FilePath&)profilePath; |
| 225 | 228 |
| 229 | |
|
Avi (use Gerrit)
2015/05/05 18:47:50
remove this extra line.
| |
| 226 // Opens a tab for each GURL in |urls|. | 230 // Opens a tab for each GURL in |urls|. |
| 227 - (void)openUrls:(const std::vector<GURL>&)urls; | 231 - (void)openUrls:(const std::vector<GURL>&)urls; |
| 228 | 232 |
| 229 // This class cannot open urls until startup has finished. The urls that cannot | 233 // This class cannot open urls until startup has finished. The urls that cannot |
| 230 // be opened are cached in |startupUrls_|. This method must be called exactly | 234 // be opened are cached in |startupUrls_|. This method must be called exactly |
| 231 // once after startup has completed. It opens the urls in |startupUrls_|, and | 235 // once after startup has completed. It opens the urls in |startupUrls_|, and |
| 232 // clears |startupUrls_|. | 236 // clears |startupUrls_|. |
| 233 - (void)openStartupUrls; | 237 - (void)openStartupUrls; |
| 234 | 238 |
| 235 // Opens a tab for each GURL in |urls|. If there is exactly one tab open before | 239 // Opens a tab for each GURL in |urls|. If there is exactly one tab open before |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 addObserver:self | 385 addObserver:self |
| 382 selector:@selector(willPowerOff:) | 386 selector:@selector(willPowerOff:) |
| 383 name:NSWorkspaceWillPowerOffNotification | 387 name:NSWorkspaceWillPowerOffNotification |
| 384 object:nil]; | 388 object:nil]; |
| 385 | 389 |
| 386 // Set up the command updater for when there are no windows open | 390 // Set up the command updater for when there are no windows open |
| 387 [self initMenuState]; | 391 [self initMenuState]; |
| 388 | 392 |
| 389 // Initialize the Profile menu. | 393 // Initialize the Profile menu. |
| 390 [self initProfileMenu]; | 394 [self initProfileMenu]; |
| 395 | |
| 396 // Initialize the Share Menu | |
|
Avi (use Gerrit)
2015/05/05 18:47:50
period at the end; complete sentences, please.
| |
| 397 [self initShareMenu]; | |
| 391 } | 398 } |
| 392 | 399 |
| 393 - (void)unregisterEventHandlers { | 400 - (void)unregisterEventHandlers { |
| 394 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; | 401 NSAppleEventManager* em = [NSAppleEventManager sharedAppleEventManager]; |
| 395 [em removeEventHandlerForEventClass:kInternetEventClass | 402 [em removeEventHandlerForEventClass:kInternetEventClass |
| 396 andEventID:kAEGetURL]; | 403 andEventID:kAEGetURL]; |
| 397 [em removeEventHandlerForEventClass:cloud_print::kAECloudPrintClass | 404 [em removeEventHandlerForEventClass:cloud_print::kAECloudPrintClass |
| 398 andEventID:cloud_print::kAECloudPrintClass]; | 405 andEventID:cloud_print::kAECloudPrintClass]; |
| 399 [em removeEventHandlerForEventClass:'WWW!' | 406 [em removeEventHandlerForEventClass:'WWW!' |
| 400 andEventID:'OURL']; | 407 andEventID:'OURL']; |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 // returns nil regardless of whether any suitable candidates for the key | 602 // returns nil regardless of whether any suitable candidates for the key |
| 596 // window remain. It seems that the new key window for the app is not set | 603 // 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 | 604 // until after this notification is fired, so a check is performed after the |
| 598 // run loop is allowed to spin. | 605 // run loop is allowed to spin. |
| 599 [self performSelector:@selector(checkForAnyKeyWindows) | 606 [self performSelector:@selector(checkForAnyKeyWindows) |
| 600 withObject:nil | 607 withObject:nil |
| 601 afterDelay:0.0]; | 608 afterDelay:0.0]; |
| 602 } | 609 } |
| 603 | 610 |
| 604 - (void)windowDidBecomeMain:(NSNotification*)notify { | 611 - (void)windowDidBecomeMain:(NSNotification*)notify { |
| 605 Browser* browser = chrome::FindBrowserWithWindow([notify object]); | 612 Browser* browser = chrome::FindBrowserWithWindow([notify object]); |
|
shrike
2015/05/05 18:20:22
Seems like this change is two lines being indented
| |
| 606 if (browser) | 613 if (browser) |
| 607 [self windowChangedToProfile:browser->profile()->GetOriginalProfile()]; | 614 [self windowChangedToProfile:browser->profile()->GetOriginalProfile()]; |
| 608 } | 615 } |
| 609 | 616 |
| 610 - (void)windowDidResignMain:(NSNotification*)notify { | 617 - (void)windowDidResignMain:(NSNotification*)notify { |
| 611 if (chrome::GetTotalBrowserCount() == 0) { | 618 if (chrome::GetTotalBrowserCount() == 0) { |
| 612 [self windowChangedToProfile: | 619 [self windowChangedToProfile: |
| 613 g_browser_process->profile_manager()->GetLastUsedProfile()]; | 620 g_browser_process->profile_manager()->GetLastUsedProfile()]; |
| 614 } | 621 } |
| 615 } | 622 } |
| 616 | 623 |
| 617 - (void)activeSpaceDidChange:(NSNotification*)notify { | 624 - (void)activeSpaceDidChange:(NSNotification*)notify { |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 return; | 1311 return; |
| 1305 } | 1312 } |
| 1306 | 1313 |
| 1307 // The controller will unhide the menu if necessary. | 1314 // The controller will unhide the menu if necessary. |
| 1308 [profileMenu setHidden:YES]; | 1315 [profileMenu setHidden:YES]; |
| 1309 | 1316 |
| 1310 profileMenuController_.reset( | 1317 profileMenuController_.reset( |
| 1311 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]); | 1318 [[ProfileMenuController alloc] initWithMainMenuItem:profileMenu]); |
| 1312 } | 1319 } |
| 1313 | 1320 |
| 1321 - (void) initShareMenu { | |
|
Avi (use Gerrit)
2015/05/05 18:47:50
no space after )
| |
| 1322 NSMenu* mainMenu = [NSApp mainMenu]; | |
| 1323 | |
| 1324 shareMenuController_.reset( | |
| 1325 [[ShareMenuController alloc] initWithMainMenu:mainMenu]); | |
|
Avi (use Gerrit)
2015/05/05 18:47:50
Why are you passing in the main menu? Why wouldn't
| |
| 1326 } | |
| 1327 | |
| 1314 // The Confirm to Quit preference is atypical in that the preference lives in | 1328 // 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 | 1329 // the app menu right above the Quit menu item. This method will refresh the |
| 1316 // display of that item depending on the preference state. | 1330 // display of that item depending on the preference state. |
| 1317 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item { | 1331 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item { |
| 1318 // Format the string so that the correct key equivalent is displayed. | 1332 // Format the string so that the correct key equivalent is displayed. |
| 1319 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; | 1333 NSString* acceleratorString = [ConfirmQuitPanelController keyCommandString]; |
| 1320 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, | 1334 NSString* title = l10n_util::GetNSStringF(IDS_CONFIRM_TO_QUIT_OPTION, |
| 1321 base::SysNSStringToUTF16(acceleratorString)); | 1335 base::SysNSStringToUTF16(acceleratorString)); |
| 1322 [item setTitle:title]; | 1336 [item setTitle:title]; |
| 1323 | 1337 |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1712 | 1726 |
| 1713 //--------------------------------------------------------------------------- | 1727 //--------------------------------------------------------------------------- |
| 1714 | 1728 |
| 1715 namespace app_controller_mac { | 1729 namespace app_controller_mac { |
| 1716 | 1730 |
| 1717 bool IsOpeningNewWindow() { | 1731 bool IsOpeningNewWindow() { |
| 1718 return g_is_opening_new_window; | 1732 return g_is_opening_new_window; |
| 1719 } | 1733 } |
| 1720 | 1734 |
| 1721 } // namespace app_controller_mac | 1735 } // namespace app_controller_mac |
| OLD | NEW |