Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 33 #include "chrome/browser/extensions/webstore_installer.h" | 33 #include "chrome/browser/extensions/webstore_installer.h" |
| 34 #include "extensions/common/feature_switch.h" | 34 #include "extensions/common/feature_switch.h" |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #if defined(ENABLE_PLUGINS) | 37 #if defined(ENABLE_PLUGINS) |
| 38 #include "chrome/browser/plugins/plugin_prefs.h" | 38 #include "chrome/browser/plugins/plugin_prefs.h" |
| 39 #include "content/public/browser/plugin_service.h" | 39 #include "content/public/browser/plugin_service.h" |
| 40 #include "content/public/common/webplugininfo.h" | 40 #include "content/public/common/webplugininfo.h" |
| 41 #endif | 41 #endif |
| 42 | 42 |
| 43 #if defined(OS_ANDROID) | |
| 44 #include "chrome/browser/android/download/download_controller.h" | |
| 45 #include "chrome/browser/android/download/download_manager_service.h" | |
| 46 #endif | |
| 47 | |
| 43 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
| 44 #include "chrome/browser/ui/pdf/adobe_reader_info_win.h" | 49 #include "chrome/browser/ui/pdf/adobe_reader_info_win.h" |
| 45 #endif | 50 #endif |
| 46 | 51 |
| 47 using content::BrowserThread; | 52 using content::BrowserThread; |
| 48 using content::DownloadItem; | 53 using content::DownloadItem; |
| 49 using safe_browsing::DownloadFileType; | 54 using safe_browsing::DownloadFileType; |
| 50 | 55 |
| 51 namespace { | 56 namespace { |
| 52 | 57 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 return QUIT_DOLOOP; | 315 return QUIT_DOLOOP; |
| 311 } | 316 } |
| 312 | 317 |
| 313 void DownloadTargetDeterminer::ReserveVirtualPathDone( | 318 void DownloadTargetDeterminer::ReserveVirtualPathDone( |
| 314 const base::FilePath& path, bool verified) { | 319 const base::FilePath& path, bool verified) { |
| 315 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 320 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 316 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() | 321 DVLOG(20) << "Reserved path: " << path.AsUTF8Unsafe() |
| 317 << " Verified:" << verified; | 322 << " Verified:" << verified; |
| 318 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); | 323 DCHECK_EQ(STATE_PROMPT_USER_FOR_DOWNLOAD_PATH, next_state_); |
| 319 #if BUILDFLAG(ANDROID_JAVA_UI) | 324 #if BUILDFLAG(ANDROID_JAVA_UI) |
| 320 // If we cannot reserve the path and the WebContent is already gone, there is | 325 if (!verified) { |
| 321 // no way to prompt user for an infobar. This could happen when user try to | 326 if (path.empty()) { |
| 322 // resume a download after another process has overwritten the same file. | 327 CancelOnFailureAndDeleteSelf(); |
| 323 // TODO(qinmin): show an error toast to the user. http://crbug.com/581106. | 328 DownloadManagerService::OnDownloadCanceled( |
| 324 if (!verified && !download_->GetWebContents()) { | 329 download_, DownloadController::CANCEL_REASON_NO_EXTERNAL_STORAGE); |
| 325 CancelOnFailureAndDeleteSelf(); | 330 return; |
| 326 return; | 331 } else if (!download_->GetWebContents()) { |
|
asanka
2016/07/07 21:12:48
Nit: 'else' unnecessary.
qinmin
2016/07/07 22:49:37
Done.
| |
| 332 // If we cannot reserve the path and the WebContent is already gone, there | |
| 333 // is no way to prompt user for an infobar. This could happen when user | |
| 334 // try to resume a download after another process has overwritten the same | |
| 335 // file. | |
| 336 // TODO(qinmin): show an error toast to the user. http://crbug.com/581106. | |
|
Yaron
2016/07/07 19:24:23
aren't you fixing this? OnDownloadCanceled will to
qinmin
2016/07/07 21:09:47
Done.
| |
| 337 CancelOnFailureAndDeleteSelf(); | |
| 338 DownloadManagerService::OnDownloadCanceled( | |
| 339 download_, | |
| 340 DownloadController::CANCEL_REASON_CANNOT_DETERMINE_DOWNLOAD_TARGET); | |
| 341 return; | |
| 342 } | |
| 327 } | 343 } |
| 328 #endif | 344 #endif |
| 329 should_prompt_ = (should_prompt_ || !verified); | 345 should_prompt_ = (should_prompt_ || !verified); |
| 330 virtual_path_ = path; | 346 virtual_path_ = path; |
| 331 DoLoop(); | 347 DoLoop(); |
| 332 } | 348 } |
| 333 | 349 |
| 334 DownloadTargetDeterminer::Result | 350 DownloadTargetDeterminer::Result |
| 335 DownloadTargetDeterminer::DoPromptUserForDownloadPath() { | 351 DownloadTargetDeterminer::DoPromptUserForDownloadPath() { |
| 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 352 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 925 const base::FilePath& suggested_path) { | 941 const base::FilePath& suggested_path) { |
| 926 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); | 942 return base::FilePath(suggested_path.value() + kCrdownloadSuffix); |
| 927 } | 943 } |
| 928 | 944 |
| 929 #if defined(OS_WIN) | 945 #if defined(OS_WIN) |
| 930 // static | 946 // static |
| 931 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { | 947 bool DownloadTargetDeterminer::IsAdobeReaderUpToDate() { |
| 932 return g_is_adobe_reader_up_to_date_; | 948 return g_is_adobe_reader_up_to_date_; |
| 933 } | 949 } |
| 934 #endif | 950 #endif |
| OLD | NEW |