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 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/background/background_mode_manager.h" | 25 #include "chrome/browser/background/background_mode_manager.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/browser_shutdown.h" | 27 #include "chrome/browser/browser_shutdown.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 28 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/command_updater.h" | 29 #include "chrome/browser/command_updater.h" |
30 #include "chrome/browser/download/download_service.h" | 30 #include "chrome/browser/download/download_service.h" |
31 #include "chrome/browser/download/download_service_factory.h" | 31 #include "chrome/browser/download/download_service_factory.h" |
32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
33 #include "chrome/browser/first_run/first_run.h" | 33 #include "chrome/browser/first_run/first_run.h" |
34 #include "chrome/browser/lifetime/application_lifetime.h" | 34 #include "chrome/browser/lifetime/application_lifetime.h" |
| 35 #include "chrome/browser/lifetime/browser_keep_alive.h" |
35 #include "chrome/browser/mac/mac_startup_profiler.h" | 36 #include "chrome/browser/mac/mac_startup_profiler.h" |
36 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 37 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
37 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 38 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
38 #include "chrome/browser/profiles/profile_manager.h" | 39 #include "chrome/browser/profiles/profile_manager.h" |
39 #include "chrome/browser/profiles/profiles_state.h" | 40 #include "chrome/browser/profiles/profiles_state.h" |
40 #include "chrome/browser/sessions/session_restore.h" | 41 #include "chrome/browser/sessions/session_restore.h" |
41 #include "chrome/browser/sessions/session_service.h" | 42 #include "chrome/browser/sessions/session_service.h" |
42 #include "chrome/browser/sessions/session_service_factory.h" | 43 #include "chrome/browser/sessions/session_service_factory.h" |
43 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 44 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
44 #include "chrome/browser/signin/signin_manager_factory.h" | 45 #include "chrome/browser/signin/signin_manager_factory.h" |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
511 runModalLoopForApplication:app]; | 512 runModalLoopForApplication:app]; |
512 } | 513 } |
513 | 514 |
514 // Called when the app is shutting down. Clean-up as appropriate. | 515 // Called when the app is shutting down. Clean-up as appropriate. |
515 - (void)applicationWillTerminate:(NSNotification*)aNotification { | 516 - (void)applicationWillTerminate:(NSNotification*)aNotification { |
516 // There better be no browser windows left at this point. | 517 // There better be no browser windows left at this point. |
517 CHECK_EQ(0u, chrome::GetTotalBrowserCount()); | 518 CHECK_EQ(0u, chrome::GetTotalBrowserCount()); |
518 | 519 |
519 // Tell BrowserList not to keep the browser process alive. Once all the | 520 // Tell BrowserList not to keep the browser process alive. Once all the |
520 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). | 521 // browsers get dealloc'd, it will stop the RunLoop and fall back into main(). |
521 chrome::DecrementKeepAliveCount(); | 522 keep_alive_.reset(); |
522 | 523 |
523 // Reset all pref watching, as this object outlives the prefs system. | 524 // Reset all pref watching, as this object outlives the prefs system. |
524 profilePrefRegistrar_.reset(); | 525 profilePrefRegistrar_.reset(); |
525 localPrefRegistrar_.RemoveAll(); | 526 localPrefRegistrar_.RemoveAll(); |
526 | 527 |
527 [self unregisterEventHandlers]; | 528 [self unregisterEventHandlers]; |
528 | 529 |
529 appShimMenuController_.reset(); | 530 appShimMenuController_.reset(); |
530 | 531 |
531 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(), | 532 STLDeleteContainerPairSecondPointers(profileBookmarkMenuBridgeMap_.begin(), |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 | 724 |
724 // This is called after profiles have been loaded and preferences registered. | 725 // This is called after profiles have been loaded and preferences registered. |
725 // It is safe to access the default profile here. | 726 // It is safe to access the default profile here. |
726 - (void)applicationDidFinishLaunching:(NSNotification*)notify { | 727 - (void)applicationDidFinishLaunching:(NSNotification*)notify { |
727 MacStartupProfiler::GetInstance()->Profile( | 728 MacStartupProfiler::GetInstance()->Profile( |
728 MacStartupProfiler::DID_FINISH_LAUNCHING); | 729 MacStartupProfiler::DID_FINISH_LAUNCHING); |
729 MacStartupProfiler::GetInstance()->RecordMetrics(); | 730 MacStartupProfiler::GetInstance()->RecordMetrics(); |
730 | 731 |
731 // Notify BrowserList to keep the application running so it doesn't go away | 732 // Notify BrowserList to keep the application running so it doesn't go away |
732 // when all the browser windows get closed. | 733 // when all the browser windows get closed. |
733 chrome::IncrementKeepAliveCount(); | 734 keep_alive_.reset(new browser_lifetime::ScopedKeepAlive); |
734 | 735 |
735 [self setUpdateCheckInterval]; | 736 [self setUpdateCheckInterval]; |
736 | 737 |
737 // Start managing the menu for app windows. This needs to be done here because | 738 // Start managing the menu for app windows. This needs to be done here because |
738 // main menu item titles are not yet initialized in awakeFromNib. | 739 // main menu item titles are not yet initialized in awakeFromNib. |
739 [self initAppShimMenuController]; | 740 [self initAppShimMenuController]; |
740 | 741 |
741 // If enabled, keep Chrome alive when apps are open instead of quitting all | 742 // If enabled, keep Chrome alive when apps are open instead of quitting all |
742 // apps. | 743 // apps. |
743 quitWithAppsController_ = new QuitWithAppsController(); | 744 quitWithAppsController_ = new QuitWithAppsController(); |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 | 1702 |
1702 //--------------------------------------------------------------------------- | 1703 //--------------------------------------------------------------------------- |
1703 | 1704 |
1704 namespace app_controller_mac { | 1705 namespace app_controller_mac { |
1705 | 1706 |
1706 bool IsOpeningNewWindow() { | 1707 bool IsOpeningNewWindow() { |
1707 return g_is_opening_new_window; | 1708 return g_is_opening_new_window; |
1708 } | 1709 } |
1709 | 1710 |
1710 } // namespace app_controller_mac | 1711 } // namespace app_controller_mac |
OLD | NEW |