| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "chrome/browser/lifetime/browser_close_manager.h" | 5 #include "chrome/browser/lifetime/browser_close_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "chrome/browser/background/background_mode_manager.h" | 12 #include "chrome/browser/background/background_mode_manager.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/browser_shutdown.h" | 14 #include "chrome/browser/browser_shutdown.h" |
| 15 #include "chrome/browser/download/download_service.h" | 15 #include "chrome/browser/download/download_core_service.h" |
| 16 #include "chrome/browser/download/download_service_factory.h" | 16 #include "chrome/browser/download/download_core_service_factory.h" |
| 17 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/chrome_pages.h" | 23 #include "chrome/browser/ui/chrome_pages.h" |
| 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 24 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 25 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 26 #include "chrome/common/features.h" | 26 #include "chrome/common/features.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Navigates a browser window for |profile|, creating one if necessary, to the | 31 // Navigates a browser window for |profile|, creating one if necessary, to the |
| 32 // downloads page if there are downloads in progress for |profile|. | 32 // downloads page if there are downloads in progress for |profile|. |
| 33 void ShowInProgressDownloads(Profile* profile) { | 33 void ShowInProgressDownloads(Profile* profile) { |
| 34 DownloadService* download_service = | 34 DownloadCoreService* download_core_service = |
| 35 DownloadServiceFactory::GetForBrowserContext(profile); | 35 DownloadCoreServiceFactory::GetForBrowserContext(profile); |
| 36 if (download_service->NonMaliciousDownloadCount() > 0) { | 36 if (download_core_service->NonMaliciousDownloadCount() > 0) { |
| 37 chrome::ScopedTabbedBrowserDisplayer displayer(profile); | 37 chrome::ScopedTabbedBrowserDisplayer displayer(profile); |
| 38 chrome::ShowDownloads(displayer.browser()); | 38 chrome::ShowDownloads(displayer.browser()); |
| 39 } | 39 } |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 BrowserCloseManager::BrowserCloseManager() : current_browser_(nullptr) { | 44 BrowserCloseManager::BrowserCloseManager() : current_browser_(nullptr) { |
| 45 } | 45 } |
| 46 | 46 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 CancelBrowserClose(); | 94 CancelBrowserClose(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void BrowserCloseManager::CheckForDownloadsInProgress() { | 97 void BrowserCloseManager::CheckForDownloadsInProgress() { |
| 98 #if defined(OS_MACOSX) | 98 #if defined(OS_MACOSX) |
| 99 // Mac has its own in-progress downloads prompt in app_controller_mac.mm. | 99 // Mac has its own in-progress downloads prompt in app_controller_mac.mm. |
| 100 CloseBrowsers(); | 100 CloseBrowsers(); |
| 101 return; | 101 return; |
| 102 #endif | 102 #endif |
| 103 | 103 |
| 104 int download_count = DownloadService::NonMaliciousDownloadCountAllProfiles(); | 104 int download_count = |
| 105 DownloadCoreService::NonMaliciousDownloadCountAllProfiles(); |
| 105 if (download_count == 0) { | 106 if (download_count == 0) { |
| 106 CloseBrowsers(); | 107 CloseBrowsers(); |
| 107 return; | 108 return; |
| 108 } | 109 } |
| 109 | 110 |
| 110 ConfirmCloseWithPendingDownloads( | 111 ConfirmCloseWithPendingDownloads( |
| 111 download_count, | 112 download_count, |
| 112 base::Bind(&BrowserCloseManager::OnReportDownloadsCancellable, this)); | 113 base::Bind(&BrowserCloseManager::OnReportDownloadsCancellable, this)); |
| 113 } | 114 } |
| 114 | 115 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 browser->window()->DestroyBrowser(); | 181 browser->window()->DestroyBrowser(); |
| 181 // Destroying the browser should have removed it from the browser list. | 182 // Destroying the browser should have removed it from the browser list. |
| 182 DCHECK(BrowserList::GetInstance()->end() == | 183 DCHECK(BrowserList::GetInstance()->end() == |
| 183 std::find(BrowserList::GetInstance()->begin(), | 184 std::find(BrowserList::GetInstance()->begin(), |
| 184 BrowserList::GetInstance()->end(), browser)); | 185 BrowserList::GetInstance()->end(), browser)); |
| 185 } | 186 } |
| 186 } | 187 } |
| 187 | 188 |
| 188 g_browser_process->notification_ui_manager()->CancelAll(); | 189 g_browser_process->notification_ui_manager()->CancelAll(); |
| 189 } | 190 } |
| OLD | NEW |