| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 Browser::DownloadClosePreventionType Browser::OkToCloseWithInProgressDownloads( | 690 Browser::DownloadClosePreventionType Browser::OkToCloseWithInProgressDownloads( |
| 691 int* num_downloads_blocking) const { | 691 int* num_downloads_blocking) const { |
| 692 DCHECK(num_downloads_blocking); | 692 DCHECK(num_downloads_blocking); |
| 693 *num_downloads_blocking = 0; | 693 *num_downloads_blocking = 0; |
| 694 | 694 |
| 695 // If we're not running a full browser process with a profile manager | 695 // If we're not running a full browser process with a profile manager |
| 696 // (testing), it's ok to close the browser. | 696 // (testing), it's ok to close the browser. |
| 697 if (!g_browser_process->profile_manager()) | 697 if (!g_browser_process->profile_manager()) |
| 698 return DOWNLOAD_CLOSE_OK; | 698 return DOWNLOAD_CLOSE_OK; |
| 699 | 699 |
| 700 int total_download_count = DownloadService::DownloadCountAllProfiles(); | 700 int total_download_count = |
| 701 DownloadService::NonDangerousDownloadCountAllProfiles(); |
| 701 if (total_download_count == 0) | 702 if (total_download_count == 0) |
| 702 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. | 703 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. |
| 703 | 704 |
| 704 // Figure out how many windows are open total, and associated with this | 705 // Figure out how many windows are open total, and associated with this |
| 705 // profile, that are relevant for the ok-to-close decision. | 706 // profile, that are relevant for the ok-to-close decision. |
| 706 int profile_window_count = 0; | 707 int profile_window_count = 0; |
| 707 int total_window_count = 0; | 708 int total_window_count = 0; |
| 708 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 709 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
| 709 // Don't count this browser window or any other in the process of closing. | 710 // Don't count this browser window or any other in the process of closing. |
| 710 Browser* const browser = *it; | 711 Browser* const browser = *it; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 724 *num_downloads_blocking = total_download_count; | 725 *num_downloads_blocking = total_download_count; |
| 725 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; | 726 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; |
| 726 } | 727 } |
| 727 | 728 |
| 728 // If there aren't any other windows on our profile, and we're an incognito | 729 // If there aren't any other windows on our profile, and we're an incognito |
| 729 // profile, and there are downloads associated with that profile, | 730 // profile, and there are downloads associated with that profile, |
| 730 // those downloads would be cancelled by our window (-> profile) close. | 731 // those downloads would be cancelled by our window (-> profile) close. |
| 731 DownloadService* download_service = | 732 DownloadService* download_service = |
| 732 DownloadServiceFactory::GetForBrowserContext(profile()); | 733 DownloadServiceFactory::GetForBrowserContext(profile()); |
| 733 if ((profile_window_count == 0) && | 734 if ((profile_window_count == 0) && |
| 734 (download_service->DownloadCount() > 0) && | 735 (download_service->NonDangerousDownloadCount() > 0) && |
| 735 profile()->IsOffTheRecord()) { | 736 profile()->IsOffTheRecord()) { |
| 736 *num_downloads_blocking = download_service->DownloadCount(); | 737 *num_downloads_blocking = download_service->NonDangerousDownloadCount(); |
| 737 return DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE; | 738 return DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE; |
| 738 } | 739 } |
| 739 | 740 |
| 740 // Those are the only conditions under which we will block shutdown. | 741 // Those are the only conditions under which we will block shutdown. |
| 741 return DOWNLOAD_CLOSE_OK; | 742 return DOWNLOAD_CLOSE_OK; |
| 742 } | 743 } |
| 743 | 744 |
| 744 //////////////////////////////////////////////////////////////////////////////// | 745 //////////////////////////////////////////////////////////////////////////////// |
| 745 // Browser, Tab adding/showing functions: | 746 // Browser, Tab adding/showing functions: |
| 746 | 747 |
| (...skipping 1548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2295 if (contents && !allow_js_access) { | 2296 if (contents && !allow_js_access) { |
| 2296 contents->web_contents()->GetController().LoadURL( | 2297 contents->web_contents()->GetController().LoadURL( |
| 2297 target_url, | 2298 target_url, |
| 2298 content::Referrer(), | 2299 content::Referrer(), |
| 2299 content::PAGE_TRANSITION_LINK, | 2300 content::PAGE_TRANSITION_LINK, |
| 2300 std::string()); // No extra headers. | 2301 std::string()); // No extra headers. |
| 2301 } | 2302 } |
| 2302 | 2303 |
| 2303 return contents != NULL; | 2304 return contents != NULL; |
| 2304 } | 2305 } |
| OLD | NEW |