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

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

Issue 2014803002: Move DownloadControllerAndroid from content/ to chrome/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix failing tests/bugs Created 4 years, 6 months 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"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "chrome/browser/android/download/download_controller.h"
14 #include "chrome/browser/infobars/infobar_service.h" 15 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h" 16 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
16 #include "components/infobars/core/infobar.h" 17 #include "components/infobars/core/infobar.h"
17 #include "content/public/browser/android/download_controller_android.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 20
21 using content::DownloadControllerAndroid;
22
23 namespace { 21 namespace {
24 22
25 void DeleteExistingDownloadFile( 23 void DeleteExistingDownloadFile(
26 const base::FilePath& download_path, 24 const base::FilePath& download_path,
27 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 25 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
28 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 26 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
29 base::File::Info info; 27 base::File::Info info;
30 if (GetFileInfo(download_path, &info) && !info.is_directory) 28 if (GetFileInfo(download_path, &info) && !info.is_directory)
31 base::DeleteFile(download_path, false); 29 base::DeleteFile(download_path, false);
32 30
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return suggested_download_path_.DirName().BaseName().value(); 90 return suggested_download_path_.DirName().BaseName().value();
93 } 91 }
94 92
95 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath() 93 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath()
96 const { 94 const {
97 return suggested_download_path_.DirName().value(); 95 return suggested_download_path_.DirName().value();
98 } 96 }
99 97
100 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() { 98 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() {
101 file_selected_callback_.Run(base::FilePath()); 99 file_selected_callback_.Run(base::FilePath());
102 DownloadControllerAndroid::RecordDownloadCancelReason( 100 DownloadController::RecordDownloadCancelReason(
103 DownloadControllerAndroid::CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED); 101 DownloadController::CANCEL_REASON_OVERWRITE_INFOBAR_DISMISSED);
104 } 102 }
105 103
106 void ChromeDownloadManagerOverwriteInfoBarDelegate::CreateNewFileInternal( 104 void ChromeDownloadManagerOverwriteInfoBarDelegate::CreateNewFileInternal(
107 const base::FilePath& suggested_download_path, 105 const base::FilePath& suggested_download_path,
108 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 106 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
109 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 107 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
110 int uniquifier = base::GetUniquePathNumber(suggested_download_path, 108 int uniquifier = base::GetUniquePathNumber(suggested_download_path,
111 base::FilePath::StringType()); 109 base::FilePath::StringType());
112 base::FilePath new_path = suggested_download_path; 110 base::FilePath new_path = suggested_download_path;
113 if (uniquifier > 0) { 111 if (uniquifier > 0) {
114 new_path = suggested_download_path.InsertBeforeExtensionASCII( 112 new_path = suggested_download_path.InsertBeforeExtensionASCII(
115 base::StringPrintf(" (%d)", uniquifier)); 113 base::StringPrintf(" (%d)", uniquifier));
116 } 114 }
117 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 115 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
118 base::Bind(callback, new_path)); 116 base::Bind(callback, new_path));
119 } 117 }
120 118
121 } // namespace android 119 } // namespace android
122 } // namespace chrome 120 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | chrome/browser/android/download/download_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698