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/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "chrome/browser/sessions/session_service_factory.h" | 35 #include "chrome/browser/sessions/session_service_factory.h" |
36 #include "chrome/browser/sessions/tab_restore_service.h" | 36 #include "chrome/browser/sessions/tab_restore_service.h" |
37 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 37 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
38 #include "chrome/browser/sync/profile_sync_service.h" | 38 #include "chrome/browser/sync/profile_sync_service.h" |
39 #include "chrome/browser/sync/sync_ui_util.h" | 39 #include "chrome/browser/sync/sync_ui_util.h" |
40 #include "chrome/browser/ui/browser.h" | 40 #include "chrome/browser/ui/browser.h" |
41 #include "chrome/browser/ui/browser_command_controller.h" | 41 #include "chrome/browser/ui/browser_command_controller.h" |
42 #include "chrome/browser/ui/browser_commands.h" | 42 #include "chrome/browser/ui/browser_commands.h" |
43 #include "chrome/browser/ui/browser_finder.h" | 43 #include "chrome/browser/ui/browser_finder.h" |
44 #include "chrome/browser/ui/browser_iterator.h" | 44 #include "chrome/browser/ui/browser_iterator.h" |
45 #include "chrome/browser/ui/browser_list.h" | |
46 #include "chrome/browser/ui/browser_mac.h" | 45 #include "chrome/browser/ui/browser_mac.h" |
47 #include "chrome/browser/ui/browser_window.h" | 46 #include "chrome/browser/ui/browser_window.h" |
48 #include "chrome/browser/ui/chrome_pages.h" | 47 #include "chrome/browser/ui/chrome_pages.h" |
49 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 48 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
50 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 49 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
51 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 50 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
52 #import "chrome/browser/ui/cocoa/confirm_quit.h" | 51 #import "chrome/browser/ui/cocoa/confirm_quit.h" |
53 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" | 52 #import "chrome/browser/ui/cocoa/confirm_quit_panel_controller.h" |
54 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 53 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
55 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" | 54 #import "chrome/browser/ui/cocoa/history_menu_bridge.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave | 295 // TODO(viettrungluu): Remove Apple Event handlers here? (It's safe to leave |
297 // them in, but I'm not sure about UX; we'd also want to disable other things | 296 // them in, but I'm not sure about UX; we'd also want to disable other things |
298 // though.) http://crbug.com/40861 | 297 // though.) http://crbug.com/40861 |
299 | 298 |
300 // Check if the user really wants to quit by employing the confirm-to-quit | 299 // Check if the user really wants to quit by employing the confirm-to-quit |
301 // mechanism. | 300 // mechanism. |
302 if (!browser_shutdown::IsTryingToQuit() && | 301 if (!browser_shutdown::IsTryingToQuit() && |
303 [self applicationShouldTerminate:app] != NSTerminateNow) | 302 [self applicationShouldTerminate:app] != NSTerminateNow) |
304 return NO; | 303 return NO; |
305 | 304 |
306 size_t num_browsers = BrowserList::size(); | 305 size_t num_browsers = chrome::GetTotalBrowserCount(); |
307 | 306 |
308 // Initiate a shutdown (via browser::CloseAllBrowsers()) if we aren't | 307 // Initiate a shutdown (via browser::CloseAllBrowsers()) if we aren't |
309 // already shutting down. | 308 // already shutting down. |
310 if (!browser_shutdown::IsTryingToQuit()) { | 309 if (!browser_shutdown::IsTryingToQuit()) { |
311 content::NotificationService::current()->Notify( | 310 content::NotificationService::current()->Notify( |
312 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 311 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
313 content::NotificationService::AllSources(), | 312 content::NotificationService::AllSources(), |
314 content::NotificationService::NoDetails()); | 313 content::NotificationService::NoDetails()); |
315 browser::CloseAllBrowsers(); | 314 browser::CloseAllBrowsers(); |
316 } | 315 } |
(...skipping 28 matching lines...) Expand all Loading... |
345 if (![ConfirmQuitPanelController eventTriggersFeature:[app currentEvent]]) | 344 if (![ConfirmQuitPanelController eventTriggersFeature:[app currentEvent]]) |
346 return NSTerminateNow; | 345 return NSTerminateNow; |
347 | 346 |
348 return [[ConfirmQuitPanelController sharedController] | 347 return [[ConfirmQuitPanelController sharedController] |
349 runModalLoopForApplication:app]; | 348 runModalLoopForApplication:app]; |
350 } | 349 } |
351 | 350 |
352 // Called when the app is shutting down. Clean-up as appropriate. | 351 // Called when the app is shutting down. Clean-up as appropriate. |
353 - (void)applicationWillTerminate:(NSNotification*)aNotification { | 352 - (void)applicationWillTerminate:(NSNotification*)aNotification { |
354 // There better be no browser windows left at this point. | 353 // There better be no browser windows left at this point. |
355 CHECK_EQ(0u, BrowserList::size()); | 354 CHECK_EQ(0u, chrome::GetTotalBrowserCount()); |
356 | 355 |
357 // Tell BrowserList not to keep the browser process alive. Once all the | 356 // Tell BrowserList not to keep the browser process alive. Once all the |
358 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). | 357 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). |
359 chrome::EndKeepAlive(); | 358 chrome::EndKeepAlive(); |
360 | 359 |
361 // Reset all pref watching, as this object outlives the prefs system. | 360 // Reset all pref watching, as this object outlives the prefs system. |
362 profilePrefRegistrar_.reset(); | 361 profilePrefRegistrar_.reset(); |
363 localPrefRegistrar_.RemoveAll(); | 362 localPrefRegistrar_.RemoveAll(); |
364 | 363 |
365 [self unregisterEventHandlers]; | 364 [self unregisterEventHandlers]; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 afterDelay:0.0]; | 478 afterDelay:0.0]; |
480 } | 479 } |
481 | 480 |
482 // If the window changed to a new BrowserWindowController, update the profile. | 481 // If the window changed to a new BrowserWindowController, update the profile. |
483 id windowController = [[notify object] windowController]; | 482 id windowController = [[notify object] windowController]; |
484 if ([notify name] == NSWindowDidBecomeMainNotification && | 483 if ([notify name] == NSWindowDidBecomeMainNotification && |
485 [windowController isKindOfClass:[BrowserWindowController class]]) { | 484 [windowController isKindOfClass:[BrowserWindowController class]]) { |
486 // If the profile is incognito, use the original profile. | 485 // If the profile is incognito, use the original profile. |
487 Profile* newProfile = [windowController profile]->GetOriginalProfile(); | 486 Profile* newProfile = [windowController profile]->GetOriginalProfile(); |
488 [self windowChangedToProfile:newProfile]; | 487 [self windowChangedToProfile:newProfile]; |
489 } else if (BrowserList::empty()) { | 488 } else if (chrome::GetTotalBrowserCount() == 0) { |
490 [self windowChangedToProfile: | 489 [self windowChangedToProfile: |
491 g_browser_process->profile_manager()->GetLastUsedProfile()]; | 490 g_browser_process->profile_manager()->GetLastUsedProfile()]; |
492 } | 491 } |
493 } | 492 } |
494 | 493 |
495 // Called on Lion and later when a popover (e.g. dictionary) is shown. | 494 // Called on Lion and later when a popover (e.g. dictionary) is shown. |
496 - (void)popoverDidShow:(NSNotification*)notify { | 495 - (void)popoverDidShow:(NSNotification*)notify { |
497 hasPopover_ = YES; | 496 hasPopover_ = YES; |
498 [self fixCloseMenuItemKeyEquivalents]; | 497 [self fixCloseMenuItemKeyEquivalents]; |
499 } | 498 } |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 | 1351 |
1353 //--------------------------------------------------------------------------- | 1352 //--------------------------------------------------------------------------- |
1354 | 1353 |
1355 namespace app_controller_mac { | 1354 namespace app_controller_mac { |
1356 | 1355 |
1357 bool IsOpeningNewWindow() { | 1356 bool IsOpeningNewWindow() { |
1358 return g_is_opening_new_window; | 1357 return g_is_opening_new_window; |
1359 } | 1358 } |
1360 | 1359 |
1361 } // namespace app_controller_mac | 1360 } // namespace app_controller_mac |
OLD | NEW |