Chromium Code Reviews| Index: chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc |
| diff --git a/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc b/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc |
| index 902dbe00145d0c38ef02ba56e5c3cc79ee1ed97d..6c343e5e8a18d90ae5d5be7c5fc0ece846d3480f 100644 |
| --- a/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc |
| +++ b/chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc |
| @@ -13,24 +13,38 @@ |
| #include "base/memory/ptr_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "chrome/browser/android/download/download_controller.h" |
| +#include "chrome/browser/android/download/download_manager_service.h" |
| #include "chrome/browser/infobars/infobar_service.h" |
| #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h" |
| #include "components/infobars/core/infobar.h" |
| +#include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/web_contents.h" |
| namespace { |
| +void DeleteExistingDownloadFileDone( |
| + bool is_off_the_record, |
| + const base::Closure& callback) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| + DownloadManagerService::GetInstance()->CheckForExternallyRemovedDownloads( |
|
Theresa
2016/09/15 03:28:30
The check for externally removed downloads doesn't
qinmin
2016/09/15 22:18:56
I believe CheckForExternallyRemovedDownloads() doe
Theresa
2016/09/15 22:44:09
When I was adding the checks for externally downlo
qinmin
2016/09/15 23:14:00
Yes, I have tested this patch and it works as inte
Theresa
2016/09/15 23:50:32
Yes, that's what I expected. In #5 step, the downl
qinmin
2016/09/16 00:14:59
Thanks, Theresa. Yes, you are correct. The deletio
|
| + nullptr, nullptr, is_off_the_record); |
| + callback.Run(); |
| +} |
| + |
| void DeleteExistingDownloadFile( |
| const base::FilePath& download_path, |
| + bool is_off_the_record, |
| const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { |
| DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| base::File::Info info; |
| if (GetFileInfo(download_path, &info) && !info.is_directory) |
| base::DeleteFile(download_path, false); |
| - content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| - base::Bind(callback, download_path)); |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&DeleteExistingDownloadFileDone, is_off_the_record, |
| + base::Bind(callback, download_path))); |
| } |
| void CreateNewFileDone( |
| @@ -89,9 +103,13 @@ ChromeDownloadManagerOverwriteInfoBarDelegate::GetIdentifier() const { |
| } |
| bool ChromeDownloadManagerOverwriteInfoBarDelegate::OverwriteExistingFile() { |
| + if (!download_item_) |
| + return true; |
| + |
| content::BrowserThread::PostTask( |
| content::BrowserThread::FILE, FROM_HERE, |
| base::Bind(&DeleteExistingDownloadFile, suggested_download_path_, |
| + download_item_->GetBrowserContext()->IsOffTheRecord(), |
| file_selected_callback_)); |
| return true; |
| } |