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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "chrome/app/chrome_command_ids.h" | 24 #include "chrome/app/chrome_command_ids.h" |
25 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" | 25 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h" |
26 #include "chrome/browser/apps/app_window_registry_util.h" | 26 #include "chrome/browser/apps/app_window_registry_util.h" |
27 #include "chrome/browser/background/background_application_list_model.h" | 27 #include "chrome/browser/background/background_application_list_model.h" |
28 #include "chrome/browser/background/background_mode_manager.h" | 28 #include "chrome/browser/background/background_mode_manager.h" |
29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
30 #include "chrome/browser/browser_shutdown.h" | 30 #include "chrome/browser/browser_shutdown.h" |
31 #include "chrome/browser/chrome_notification_types.h" | 31 #include "chrome/browser/chrome_notification_types.h" |
32 #include "chrome/browser/command_updater.h" | 32 #include "chrome/browser/command_updater.h" |
33 #include "chrome/browser/download/download_service.h" | 33 #include "chrome/browser/download/download_core_service.h" |
34 #include "chrome/browser/download/download_service_factory.h" | 34 #include "chrome/browser/download/download_core_service_factory.h" |
35 #include "chrome/browser/extensions/extension_service.h" | 35 #include "chrome/browser/extensions/extension_service.h" |
36 #include "chrome/browser/first_run/first_run.h" | 36 #include "chrome/browser/first_run/first_run.h" |
37 #include "chrome/browser/lifetime/application_lifetime.h" | 37 #include "chrome/browser/lifetime/application_lifetime.h" |
38 #include "chrome/browser/lifetime/keep_alive_types.h" | 38 #include "chrome/browser/lifetime/keep_alive_types.h" |
39 #include "chrome/browser/lifetime/scoped_keep_alive.h" | 39 #include "chrome/browser/lifetime/scoped_keep_alive.h" |
40 #include "chrome/browser/mac/mac_startup_profiler.h" | 40 #include "chrome/browser/mac/mac_startup_profiler.h" |
41 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 41 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
42 #include "chrome/browser/profiles/profile_attributes_entry.h" | 42 #include "chrome/browser/profiles/profile_attributes_entry.h" |
43 #include "chrome/browser/profiles/profile_attributes_storage.h" | 43 #include "chrome/browser/profiles/profile_attributes_storage.h" |
44 #include "chrome/browser/profiles/profile_manager.h" | 44 #include "chrome/browser/profiles/profile_manager.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 | 407 |
408 content::NotificationService::current()->Notify( | 408 content::NotificationService::current()->Notify( |
409 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, | 409 chrome::NOTIFICATION_CLOSE_ALL_BROWSERS_REQUEST, |
410 content::NotificationService::AllSources(), | 410 content::NotificationService::AllSources(), |
411 content::NotificationService::NoDetails()); | 411 content::NotificationService::NoDetails()); |
412 // This will close all browser sessions. | 412 // This will close all browser sessions. |
413 chrome::CloseAllBrowsers(); | 413 chrome::CloseAllBrowsers(); |
414 | 414 |
415 // At this point, the user has already chosen to cancel downloads. If we | 415 // At this point, the user has already chosen to cancel downloads. If we |
416 // were to shut down as usual, the downloads would be cancelled in | 416 // were to shut down as usual, the downloads would be cancelled in |
417 // DownloadService::Shutdown(). | 417 // DownloadCoreService::Shutdown(). |
418 DownloadService::CancelAllDownloads(); | 418 DownloadCoreService::CancelAllDownloads(); |
419 | 419 |
420 return NO; | 420 return NO; |
421 } | 421 } |
422 | 422 |
423 size_t num_browsers = chrome::GetTotalBrowserCount(); | 423 size_t num_browsers = chrome::GetTotalBrowserCount(); |
424 | 424 |
425 // Initiate a shutdown (via chrome::CloseAllBrowsersAndQuit()) if we aren't | 425 // Initiate a shutdown (via chrome::CloseAllBrowsersAndQuit()) if we aren't |
426 // already shutting down. | 426 // already shutting down. |
427 if (!browser_shutdown::IsTryingToQuit()) { | 427 if (!browser_shutdown::IsTryingToQuit()) { |
428 content::NotificationService::current()->Notify( | 428 content::NotificationService::current()->Notify( |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 // Check all profiles for in progress downloads, and if we find any, prompt the | 780 // Check all profiles for in progress downloads, and if we find any, prompt the |
781 // user to see if we should continue to exit (and thus cancel the downloads), or | 781 // user to see if we should continue to exit (and thus cancel the downloads), or |
782 // if we should wait. | 782 // if we should wait. |
783 - (BOOL)shouldQuitWithInProgressDownloads { | 783 - (BOOL)shouldQuitWithInProgressDownloads { |
784 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 784 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
785 if (!profile_manager) | 785 if (!profile_manager) |
786 return YES; | 786 return YES; |
787 | 787 |
788 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); | 788 std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles()); |
789 for (size_t i = 0; i < profiles.size(); ++i) { | 789 for (size_t i = 0; i < profiles.size(); ++i) { |
790 DownloadService* download_service = | 790 DownloadCoreService* download_core_service = |
791 DownloadServiceFactory::GetForBrowserContext(profiles[i]); | 791 DownloadCoreServiceFactory::GetForBrowserContext(profiles[i]); |
792 DownloadManager* download_manager = | 792 DownloadManager* download_manager = |
793 (download_service->HasCreatedDownloadManager() ? | 793 (download_core_service->HasCreatedDownloadManager() |
794 BrowserContext::GetDownloadManager(profiles[i]) : NULL); | 794 ? BrowserContext::GetDownloadManager(profiles[i]) |
| 795 : NULL); |
795 if (download_manager && | 796 if (download_manager && |
796 download_manager->NonMaliciousInProgressCount() > 0) { | 797 download_manager->NonMaliciousInProgressCount() > 0) { |
797 int downloadCount = download_manager->NonMaliciousInProgressCount(); | 798 int downloadCount = download_manager->NonMaliciousInProgressCount(); |
798 if ([self userWillWaitForInProgressDownloads:downloadCount]) { | 799 if ([self userWillWaitForInProgressDownloads:downloadCount]) { |
799 // Create a new browser window (if necessary) and navigate to the | 800 // Create a new browser window (if necessary) and navigate to the |
800 // downloads page if the user chooses to wait. | 801 // downloads page if the user chooses to wait. |
801 Browser* browser = chrome::FindBrowserWithProfile(profiles[i]); | 802 Browser* browser = chrome::FindBrowserWithProfile(profiles[i]); |
802 if (!browser) { | 803 if (!browser) { |
803 browser = new Browser(Browser::CreateParams(profiles[i], true)); | 804 browser = new Browser(Browser::CreateParams(profiles[i], true)); |
804 browser->window()->Show(); | 805 browser->window()->Show(); |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 | 1609 |
1609 //--------------------------------------------------------------------------- | 1610 //--------------------------------------------------------------------------- |
1610 | 1611 |
1611 namespace app_controller_mac { | 1612 namespace app_controller_mac { |
1612 | 1613 |
1613 bool IsOpeningNewWindow() { | 1614 bool IsOpeningNewWindow() { |
1614 return g_is_opening_new_window; | 1615 return g_is_opening_new_window; |
1615 } | 1616 } |
1616 | 1617 |
1617 } // namespace app_controller_mac | 1618 } // namespace app_controller_mac |
OLD | NEW |