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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 weak_ptr_factory_.GetWeakPtr())); | 317 weak_ptr_factory_.GetWeakPtr())); |
318 return QUIT_DOLOOP; | 318 return QUIT_DOLOOP; |
319 } | 319 } |
320 | 320 |
321 void DownloadTargetDeterminer::ReserveVirtualPathDone( | 321 void DownloadTargetDeterminer::ReserveVirtualPathDone( |
322 const base::FilePath& path, bool verified) { | 322 const base::FilePath& path, bool verified) { |
323 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 323 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
324 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() | 324 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() |
325 << " Verified:" << verified; | 325 << " Verified:" << verified; |
326 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); | 326 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); |
327 #if BUILDFLAG(ANDROID_JAVA_UI) | 327 #if defined(OS_ANDROID) |
328 if (!verified) { | 328 if (!verified) { |
329 if (path.empty()) { | 329 if (path.empty()) { |
330 DownloadManagerService::OnDownloadCanceled( | 330 DownloadManagerService::OnDownloadCanceled( |
331 download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE); | 331 download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE); |
332 CancelOnFailureAndDeleteSelf(); | 332 CancelOnFailureAndDeleteSelf(); |
333 return; | 333 return; |
334 } | 334 } |
335 if (!download_->GetWebContents()) { | 335 if (!download_->GetWebContents()) { |
336 // If we cannot reserve the path and the WebContent is already gone, there | 336 // If we cannot reserve the path and the WebContent is already gone, there |
337 // is no way to prompt user for an infobar. This could happen after chrome | 337 // is no way to prompt user for an infobar. This could happen after chrome |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 ScheduleCallbackAndDeleteSelf(); | 787 ScheduleCallbackAndDeleteSelf(); |
788 } | 788 } |
789 | 789 |
790 Profile* DownloadTargetDeterminer::GetProfile() const { | 790 Profile* DownloadTargetDeterminer::GetProfile() const { |
791 DCHECK(download_->GetBrowserContext()); | 791 DCHECK(download_->GetBrowserContext()); |
792 return Profile::FromBrowserContext(download_->GetBrowserContext()); | 792 return Profile::FromBrowserContext(download_->GetBrowserContext()); |
793 } | 793 } |
794 | 794 |
795 bool DownloadTargetDeterminer::ShouldPromptForDownload( | 795 bool DownloadTargetDeterminer::ShouldPromptForDownload( |
796 const base::FilePath& filename) const { | 796 const base::FilePath& filename) const { |
797 #if BUILDFLAG(ANDROID_JAVA_UI) | 797 #if defined(OS_ANDROID) |
798 // Don't prompt user about saving path on Android. | 798 // Don't prompt user about saving path on Android. |
799 // TODO(qinmin): show an error toast to warn user in certain cases. | 799 // TODO(qinmin): show an error toast to warn user in certain cases. |
800 return false; | 800 return false; |
801 #endif | 801 #endif |
802 if (is_resumption_) { | 802 if (is_resumption_) { |
803 // For resumed downloads, if the target disposition or prefs require | 803 // For resumed downloads, if the target disposition or prefs require |
804 // prompting, the user has already been prompted. Try to respect the user's | 804 // prompting, the user has already been prompted. Try to respect the user's |
805 // selection, unless we've discovered that the target path cannot be used | 805 // selection, unless we've discovered that the target path cannot be used |
806 // for some reason. | 806 // for some reason. |
807 content::DownloadInterruptReason reason = download_->GetLastReason(); | 807 content::DownloadInterruptReason reason = download_->GetLastReason(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 const base::FilePath& suggested_path) { | 943 const base::FilePath& suggested_path) { |
944 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 944 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
945 } | 945 } |
946 | 946 |
947 #if defined(OS_WIN) | 947 #if defined(OS_WIN) |
948 // static | 948 // static |
949 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { | 949 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { |
950 return g_is_adobe_reader_up_to_date_; | 950 return g_is_adobe_reader_up_to_date_; |
951 } | 951 } |
952 #endif | 952 #endif |
OLD | NEW |