| 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/download/download_target_determiner.h" | 5 #include "chrome/browser/download/download_target_determiner.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 ScheduleCallbackAndDeleteSelf(); | 785 ScheduleCallbackAndDeleteSelf(); |
| 786 } | 786 } |
| 787 | 787 |
| 788 Profile* DownloadTargetDeterminer::GetProfile() const { | 788 Profile* DownloadTargetDeterminer::GetProfile() const { |
| 789 DCHECK(download_->GetBrowserContext()); | 789 DCHECK(download_->GetBrowserContext()); |
| 790 return Profile::FromBrowserContext(download_->GetBrowserContext()); | 790 return Profile::FromBrowserContext(download_->GetBrowserContext()); |
| 791 } | 791 } |
| 792 | 792 |
| 793 bool DownloadTargetDeterminer::ShouldPromptForDownload( | 793 bool DownloadTargetDeterminer::ShouldPromptForDownload( |
| 794 const base::FilePath& filename) const { | 794 const base::FilePath& filename) const { |
| 795 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 796 // Don't prompt user about saving path on Android. |
| 797 // TODO(qinmin): show an error toast to warn user in certain cases. |
| 798 return false; |
| 799 #endif |
| 795 if (is_resumption_) { | 800 if (is_resumption_) { |
| 796 #if BUILDFLAG(ANDROID_JAVA_UI) | |
| 797 // In case of file error, prompting user with the overwritten infobar | |
| 798 // won't solve the issue. Return false so that resumption will fail again | |
| 799 // if user hasn't performed any action to resolve file errors. | |
| 800 // TODO(qinmin): show an error toast to warn user that resume cannot | |
| 801 // continue due to file errors. http://crbug.com/581106. | |
| 802 return false; | |
| 803 #else | |
| 804 // For resumed downloads, if the target disposition or prefs require | 801 // For resumed downloads, if the target disposition or prefs require |
| 805 // prompting, the user has already been prompted. Try to respect the user's | 802 // prompting, the user has already been prompted. Try to respect the user's |
| 806 // selection, unless we've discovered that the target path cannot be used | 803 // selection, unless we've discovered that the target path cannot be used |
| 807 // for some reason. | 804 // for some reason. |
| 808 content::DownloadInterruptReason reason = download_->GetLastReason(); | 805 content::DownloadInterruptReason reason = download_->GetLastReason(); |
| 809 return (reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED || | 806 return (reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED || |
| 810 reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE || | 807 reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_NO_SPACE || |
| 811 reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE); | 808 reason == content::DOWNLOAD_INTERRUPT_REASON_FILE_TOO_LARGE); |
| 812 #endif | |
| 813 } | 809 } |
| 814 | 810 |
| 815 // If the download path is forced, don't prompt. | 811 // If the download path is forced, don't prompt. |
| 816 if (!download_->GetForcedFilePath().empty()) { | 812 if (!download_->GetForcedFilePath().empty()) { |
| 817 // 'Save As' downloads shouldn't have a forced path. | 813 // 'Save As' downloads shouldn't have a forced path. |
| 818 DCHECK(DownloadItem::TARGET_DISPOSITION_PROMPT != | 814 DCHECK(DownloadItem::TARGET_DISPOSITION_PROMPT != |
| 819 download_->GetTargetDisposition()); | 815 download_->GetTargetDisposition()); |
| 820 return false; | 816 return false; |
| 821 } | 817 } |
| 822 | 818 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 945 const base::FilePath& suggested_path) { | 941 const base::FilePath& suggested_path) { |
| 946 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 942 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
| 947 } | 943 } |
| 948 | 944 |
| 949 #if defined(OS_WIN) | 945 #if defined(OS_WIN) |
| 950 // static | 946 // static |
| 951 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { | 947 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { |
| 952 return g_is_adobe_reader_up_to_date_; | 948 return g_is_adobe_reader_up_to_date_; |
| 953 } | 949 } |
| 954 #endif | 950 #endif |
| OLD | NEW |