Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: chrome/browser/android/download/chrome_download_manager_overwrite_infobar_delegate.cc

Issue 2453633006: [downloads] Move platform specific code out of DownloadTargetDeterminer. (Closed)
Patch Set: . Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/android/download/chrome_download_manager_overwrite_info bar_delegate.h" 5 #include "chrome/browser/android/download/chrome_download_manager_overwrite_info bar_delegate.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 22
23 namespace { 23 namespace {
24 24
25 void DeleteExistingDownloadFileDone( 25 void DeleteExistingDownloadFileDone(
26 const base::FilePath& download_path, 26 const base::FilePath& download_path,
27 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 27 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 28 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
29 DownloadManagerService::GetInstance()->RemoveDownloadsForPath( 29 DownloadManagerService::GetInstance()->RemoveDownloadsForPath(
30 download_path); 30 download_path);
31 callback.Run(download_path); 31 callback.Run(DownloadConfirmationResult::CONFIRMED, download_path);
32 } 32 }
33 33
34 void DeleteExistingDownloadFile( 34 void DeleteExistingDownloadFile(
35 const base::FilePath& download_path, 35 const base::FilePath& download_path,
36 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 36 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
37 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 37 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
38 base::File::Info info; 38 base::File::Info info;
39 if (GetFileInfo(download_path, &info) && !info.is_directory) 39 if (GetFileInfo(download_path, &info) && !info.is_directory)
40 base::DeleteFile(download_path, false); 40 base::DeleteFile(download_path, false);
41 41
42 content::BrowserThread::PostTask( 42 content::BrowserThread::PostTask(
43 content::BrowserThread::UI, FROM_HERE, 43 content::BrowserThread::UI, FROM_HERE,
44 base::Bind(&DeleteExistingDownloadFileDone, download_path, callback)); 44 base::Bind(&DeleteExistingDownloadFileDone, download_path, callback));
45 } 45 }
46 46
47 void CreateNewFileDone( 47 void CreateNewFileDone(
48 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback, 48 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback,
49 const base::FilePath& target_path, bool verified) { 49 const base::FilePath& target_path,
50 DownloadTargetResult result) {
50 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 51 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
51 if (verified) 52 callback.Run(result == DownloadTargetResult::SUCCESS
52 callback.Run(target_path); 53 ? DownloadConfirmationResult::CONFIRMED
53 else 54 : DownloadConfirmationResult::CANCELED,
54 callback.Run(base::FilePath()); 55 target_path);
55 } 56 }
56 57
57 } // namespace 58 } // namespace
58 59
59 namespace chrome { 60 namespace chrome {
60 namespace android { 61 namespace android {
61 62
62 ChromeDownloadManagerOverwriteInfoBarDelegate:: 63 ChromeDownloadManagerOverwriteInfoBarDelegate::
63 ~ChromeDownloadManagerOverwriteInfoBarDelegate() { 64 ~ChromeDownloadManagerOverwriteInfoBarDelegate() {
64 if (download_item_) 65 if (download_item_)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirName() const { 136 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirName() const {
136 return suggested_download_path_.DirName().BaseName().value(); 137 return suggested_download_path_.DirName().BaseName().value();
137 } 138 }
138 139
139 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath() 140 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath()
140 const { 141 const {
141 return suggested_download_path_.DirName().value(); 142 return suggested_download_path_.DirName().value();
142 } 143 }
143 144
144 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() { 145 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() {
145 file_selected_callback_.Run(base::FilePath()); 146 file_selected_callback_.Run(DownloadConfirmationResult::CANCELED,
147 base::FilePath());
146 DownloadController::RecordDownloadCancelReason( 148 DownloadController::RecordDownloadCancelReason(
147 DownloadController::CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED); 149 DownloadController::CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED);
148 } 150 }
149 151
150 } // namespace android 152 } // namespace android
151 } // namespace chrome 153 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698