OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/browser_list.h" | 5 #include "chrome/browser/ui/browser_list.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/browser_shutdown.h" | 12 #include "chrome/browser/browser_shutdown.h" |
| 13 #include "chrome/browser/download/download_service.h" |
13 #include "chrome/browser/metrics/thread_watcher.h" | 14 #include "chrome/browser/metrics/thread_watcher.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/printing/background_printing_manager.h" | 16 #include "chrome/browser/printing/background_printing_manager.h" |
16 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
17 #include "chrome/browser/ui/browser_window.h" | 18 #include "chrome/browser/ui/browser_window.h" |
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
19 #include "chrome/common/chrome_notification_types.h" | 20 #include "chrome/common/chrome_notification_types.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
21 #include "content/browser/renderer_host/render_process_host.h" | 22 #include "content/browser/renderer_host/render_process_host.h" |
22 #include "content/browser/tab_contents/navigation_details.h" | 23 #include "content/browser/tab_contents/navigation_details.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 181 } |
181 | 182 |
182 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { | 183 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { |
183 return g_browser_process->background_printing_manager(); | 184 return g_browser_process->background_printing_manager(); |
184 } | 185 } |
185 | 186 |
186 // Returns true if all browsers can be closed without user interaction. | 187 // Returns true if all browsers can be closed without user interaction. |
187 // This currently checks if there is pending download, or if it needs to | 188 // This currently checks if there is pending download, or if it needs to |
188 // handle unload handler. | 189 // handle unload handler. |
189 bool AreAllBrowsersCloseable() { | 190 bool AreAllBrowsersCloseable() { |
190 for (BrowserList::const_iterator i = BrowserList::begin(); | 191 BrowserList::const_iterator browser_it = BrowserList::begin(); |
191 i != BrowserList::end(); ++i) { | 192 if (browser_it == BrowserList::end()) |
192 bool normal_downloads_are_present = false; | 193 return true; |
193 bool incognito_downloads_are_present = false; | 194 |
194 (*i)->CheckDownloadsInProgress(&normal_downloads_are_present, | 195 // If there are any downloads active, all browsers are not closeable. |
195 &incognito_downloads_are_present); | 196 if (DownloadService::TotalDownloadCount() > 0) |
196 if (normal_downloads_are_present || | 197 return false; |
197 incognito_downloads_are_present || | 198 |
198 (*i)->TabsNeedBeforeUnloadFired()) | 199 // Check TabsNeedBeforeUnloadFired(). |
| 200 for (; browser_it != BrowserList::end(); ++browser_it) { |
| 201 if ((*browser_it)->TabsNeedBeforeUnloadFired()) |
199 return false; | 202 return false; |
200 } | 203 } |
201 return true; | 204 return true; |
202 } | 205 } |
203 | 206 |
204 #if defined(OS_CHROMEOS) | 207 #if defined(OS_CHROMEOS) |
205 | 208 |
206 bool signout = false; | 209 bool signout = false; |
207 | 210 |
208 // Fast shutdown for ChromeOS. It tells session manager to start | 211 // Fast shutdown for ChromeOS. It tells session manager to start |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 790 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
788 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 791 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
789 cur_ = *bg_printing_iterator_; | 792 cur_ = *bg_printing_iterator_; |
790 CHECK(cur_); | 793 CHECK(cur_); |
791 ++bg_printing_iterator_; | 794 ++bg_printing_iterator_; |
792 return; | 795 return; |
793 } | 796 } |
794 // Reached the end - no more TabContents. | 797 // Reached the end - no more TabContents. |
795 cur_ = NULL; | 798 cur_ = NULL; |
796 } | 799 } |
OLD | NEW |