| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/browser_shutdown.h" | 9 #include "chrome/browser/browser_shutdown.h" |
| 10 #include "chrome/browser/download/download_service.h" | 10 #include "chrome/browser/download/download_service.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 current_browser_ = NULL; | 68 current_browser_ = NULL; |
| 69 | 69 |
| 70 if (proceed) | 70 if (proceed) |
| 71 TryToCloseBrowsers(); | 71 TryToCloseBrowsers(); |
| 72 else | 72 else |
| 73 CancelBrowserClose(); | 73 CancelBrowserClose(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void BrowserCloseManager::CheckForDownloadsInProgress() { | 76 void BrowserCloseManager::CheckForDownloadsInProgress() { |
| 77 int download_count = DownloadService::DownloadCountAllProfiles(); | 77 int download_count = DownloadService::NonDangerousDownloadCountAllProfiles(); |
| 78 if (download_count == 0) { | 78 if (download_count == 0) { |
| 79 CloseBrowsers(); | 79 CloseBrowsers(); |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 ConfirmCloseWithPendingDownloads( | 82 ConfirmCloseWithPendingDownloads( |
| 83 download_count, | 83 download_count, |
| 84 base::Bind(&BrowserCloseManager::OnReportDownloadsCancellable, this)); | 84 base::Bind(&BrowserCloseManager::OnReportDownloadsCancellable, this)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void BrowserCloseManager::ConfirmCloseWithPendingDownloads( | 87 void BrowserCloseManager::ConfirmCloseWithPendingDownloads( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 106 CancelBrowserClose(); | 106 CancelBrowserClose(); |
| 107 | 107 |
| 108 // Open the downloads page for each profile with downloads in progress. | 108 // Open the downloads page for each profile with downloads in progress. |
| 109 std::vector<Profile*> profiles( | 109 std::vector<Profile*> profiles( |
| 110 g_browser_process->profile_manager()->GetLoadedProfiles()); | 110 g_browser_process->profile_manager()->GetLoadedProfiles()); |
| 111 for (std::vector<Profile*>::iterator it = profiles.begin(); | 111 for (std::vector<Profile*>::iterator it = profiles.begin(); |
| 112 it != profiles.end(); | 112 it != profiles.end(); |
| 113 ++it) { | 113 ++it) { |
| 114 DownloadService* download_service = | 114 DownloadService* download_service = |
| 115 DownloadServiceFactory::GetForBrowserContext(*it); | 115 DownloadServiceFactory::GetForBrowserContext(*it); |
| 116 if (download_service->DownloadCount() > 0) { | 116 if (download_service->NonDangerousDownloadCount() > 0) { |
| 117 Browser* browser = | 117 Browser* browser = |
| 118 chrome::FindOrCreateTabbedBrowser(*it, chrome::GetActiveDesktop()); | 118 chrome::FindOrCreateTabbedBrowser(*it, chrome::GetActiveDesktop()); |
| 119 DCHECK(browser); | 119 DCHECK(browser); |
| 120 chrome::ShowDownloads(browser); | 120 chrome::ShowDownloads(browser); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 void BrowserCloseManager::CloseBrowsers() { | 125 void BrowserCloseManager::CloseBrowsers() { |
| 126 // Tell everyone that we are shutting down. | 126 // Tell everyone that we are shutting down. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 155 it_ptr.reset(new chrome::BrowserIterator()); | 155 it_ptr.reset(new chrome::BrowserIterator()); |
| 156 if (!it_ptr->done() && browser == **it_ptr) { | 156 if (!it_ptr->done() && browser == **it_ptr) { |
| 157 // Destroying the browser should have removed it from the browser list. | 157 // Destroying the browser should have removed it from the browser list. |
| 158 // We should never get here. | 158 // We should never get here. |
| 159 NOTREACHED(); | 159 NOTREACHED(); |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 } | 164 } |
| OLD | NEW |