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