| 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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 // Show the download page so the user can figure-out what downloads are still | 672 // Show the download page so the user can figure-out what downloads are still |
| 673 // in-progress. | 673 // in-progress. |
| 674 chrome::ShowDownloads(this); | 674 chrome::ShowDownloads(this); |
| 675 } | 675 } |
| 676 | 676 |
| 677 Browser::DownloadClosePreventionType Browser::OkToCloseWithInProgressDownloads( | 677 Browser::DownloadClosePreventionType Browser::OkToCloseWithInProgressDownloads( |
| 678 int* num_downloads_blocking) const { | 678 int* num_downloads_blocking) const { |
| 679 DCHECK(num_downloads_blocking); | 679 DCHECK(num_downloads_blocking); |
| 680 *num_downloads_blocking = 0; | 680 *num_downloads_blocking = 0; |
| 681 | 681 |
| 682 if (IsAttemptingToCloseBrowser()) | |
| 683 return DOWNLOAD_CLOSE_OK; | |
| 684 | |
| 685 // If we're not running a full browser process with a profile manager | 682 // If we're not running a full browser process with a profile manager |
| 686 // (testing), it's ok to close the browser. | 683 // (testing), it's ok to close the browser. |
| 687 if (!g_browser_process->profile_manager()) | 684 if (!g_browser_process->profile_manager()) |
| 688 return DOWNLOAD_CLOSE_OK; | 685 return DOWNLOAD_CLOSE_OK; |
| 689 | 686 |
| 690 int total_download_count = DownloadService::DownloadCountAllProfiles(); | 687 int total_download_count = DownloadService::DownloadCountAllProfiles(); |
| 691 if (total_download_count == 0) | 688 if (total_download_count == 0) |
| 692 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. | 689 return DOWNLOAD_CLOSE_OK; // No downloads; can definitely close. |
| 693 | 690 |
| 694 // Figure out how many windows are open total, and associated with this | 691 // Figure out how many windows are open total, and associated with this |
| (...skipping 18 matching lines...) Expand all Loading... |
| 713 if (total_window_count == 0) { | 710 if (total_window_count == 0) { |
| 714 *num_downloads_blocking = total_download_count; | 711 *num_downloads_blocking = total_download_count; |
| 715 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; | 712 return DOWNLOAD_CLOSE_BROWSER_SHUTDOWN; |
| 716 } | 713 } |
| 717 | 714 |
| 718 // If there aren't any other windows on our profile, and we're an incognito | 715 // If there aren't any other windows on our profile, and we're an incognito |
| 719 // profile, and there are downloads associated with that profile, | 716 // profile, and there are downloads associated with that profile, |
| 720 // those downloads would be cancelled by our window (-> profile) close. | 717 // those downloads would be cancelled by our window (-> profile) close. |
| 721 DownloadService* download_service = | 718 DownloadService* download_service = |
| 722 DownloadServiceFactory::GetForProfile(profile()); | 719 DownloadServiceFactory::GetForProfile(profile()); |
| 723 if (profile_window_count == 0 && download_service->DownloadCount() > 0 && | 720 if ((profile_window_count == 0) && |
| 721 (download_service->DownloadCount() > 0) && |
| 724 profile()->IsOffTheRecord()) { | 722 profile()->IsOffTheRecord()) { |
| 725 *num_downloads_blocking = download_service->DownloadCount(); | 723 *num_downloads_blocking = download_service->DownloadCount(); |
| 726 return DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE; | 724 return DOWNLOAD_CLOSE_LAST_WINDOW_IN_INCOGNITO_PROFILE; |
| 727 } | 725 } |
| 728 | 726 |
| 729 // Those are the only conditions under which we will block shutdown. | 727 // Those are the only conditions under which we will block shutdown. |
| 730 return DOWNLOAD_CLOSE_OK; | 728 return DOWNLOAD_CLOSE_OK; |
| 731 } | 729 } |
| 732 | 730 |
| 733 //////////////////////////////////////////////////////////////////////////////// | 731 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2265 if (contents && !allow_js_access) { | 2263 if (contents && !allow_js_access) { |
| 2266 contents->web_contents()->GetController().LoadURL( | 2264 contents->web_contents()->GetController().LoadURL( |
| 2267 target_url, | 2265 target_url, |
| 2268 content::Referrer(), | 2266 content::Referrer(), |
| 2269 content::PAGE_TRANSITION_LINK, | 2267 content::PAGE_TRANSITION_LINK, |
| 2270 std::string()); // No extra headers. | 2268 std::string()); // No extra headers. |
| 2271 } | 2269 } |
| 2272 | 2270 |
| 2273 return contents != NULL; | 2271 return contents != NULL; |
| 2274 } | 2272 } |
| OLD | NEW |