| 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 182 } |
| 182 | 183 |
| 183 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { | 184 printing::BackgroundPrintingManager* GetBackgroundPrintingManager() { |
| 184 return g_browser_process->background_printing_manager(); | 185 return g_browser_process->background_printing_manager(); |
| 185 } | 186 } |
| 186 | 187 |
| 187 // Returns true if all browsers can be closed without user interaction. | 188 // Returns true if all browsers can be closed without user interaction. |
| 188 // This currently checks if there is pending download, or if it needs to | 189 // This currently checks if there is pending download, or if it needs to |
| 189 // handle unload handler. | 190 // handle unload handler. |
| 190 bool AreAllBrowsersCloseable() { | 191 bool AreAllBrowsersCloseable() { |
| 191 for (BrowserList::const_iterator i = BrowserList::begin(); | 192 BrowserList::const_iterator browser_it = BrowserList::begin(); |
| 192 i != BrowserList::end(); ++i) { | 193 if (browser_it == BrowserList::end()) |
| 193 bool normal_downloads_are_present = false; | 194 return true; |
| 194 bool incognito_downloads_are_present = false; | 195 |
| 195 (*i)->CheckDownloadsInProgress(&normal_downloads_are_present, | 196 // If there are any downloads active, all browsers are not closeable. |
| 196 &incognito_downloads_are_present); | 197 if (DownloadService::DownloadCountAllProfiles() > 0) |
| 197 if (normal_downloads_are_present || | 198 return false; |
| 198 incognito_downloads_are_present || | 199 |
| 199 (*i)->TabsNeedBeforeUnloadFired()) | 200 // Check TabsNeedBeforeUnloadFired(). |
| 201 for (; browser_it != BrowserList::end(); ++browser_it) { |
| 202 if ((*browser_it)->TabsNeedBeforeUnloadFired()) |
| 200 return false; | 203 return false; |
| 201 } | 204 } |
| 202 return true; | 205 return true; |
| 203 } | 206 } |
| 204 | 207 |
| 205 #if defined(OS_CHROMEOS) | 208 #if defined(OS_CHROMEOS) |
| 206 | 209 |
| 207 bool signout = false; | 210 bool signout = false; |
| 208 | 211 |
| 209 // Fast shutdown for ChromeOS. It tells session manager to start | 212 // Fast shutdown for ChromeOS. It tells session manager to start |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 // If no more TabContents from Browsers, check the BackgroundPrintingManager. | 793 // If no more TabContents from Browsers, check the BackgroundPrintingManager. |
| 791 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { | 794 while (bg_printing_iterator_ != GetBackgroundPrintingManager()->end()) { |
| 792 cur_ = *bg_printing_iterator_; | 795 cur_ = *bg_printing_iterator_; |
| 793 CHECK(cur_); | 796 CHECK(cur_); |
| 794 ++bg_printing_iterator_; | 797 ++bg_printing_iterator_; |
| 795 return; | 798 return; |
| 796 } | 799 } |
| 797 // Reached the end - no more TabContents. | 800 // Reached the end - no more TabContents. |
| 798 cur_ = NULL; | 801 cur_ = NULL; |
| 799 } | 802 } |
| OLD | NEW |