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

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

Issue 2058593002: Add UMA for studying download cancellation reasons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h" 15 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
16 #include "components/infobars/core/infobar.h" 16 #include "components/infobars/core/infobar.h"
17 #include "content/public/browser/android/download_controller_android.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 20
20 namespace { 21 namespace {
21 22
22 void DeleteExistingDownloadFile( 23 void DeleteExistingDownloadFile(
23 const base::FilePath& download_path, 24 const base::FilePath& download_path,
24 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 25 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
25 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 26 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
26 base::File::Info info; 27 base::File::Info info;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return suggested_download_path_.DirName().BaseName().value(); 90 return suggested_download_path_.DirName().BaseName().value();
90 } 91 }
91 92
92 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath() 93 std::string ChromeDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath()
93 const { 94 const {
94 return suggested_download_path_.DirName().value(); 95 return suggested_download_path_.DirName().value();
95 } 96 }
96 97
97 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() { 98 void ChromeDownloadManagerOverwriteInfoBarDelegate::InfoBarDismissed() {
98 file_selected_callback_.Run(base::FilePath()); 99 file_selected_callback_.Run(base::FilePath());
100 content::DownloadControllerAndroid::RecordDownloadCancelReason(
101 content::DownloadControllerAndroid::kOverwriteInfobarDismissed);
99 } 102 }
100 103
101 void ChromeDownloadManagerOverwriteInfoBarDelegate::CreateNewFileInternal( 104 void ChromeDownloadManagerOverwriteInfoBarDelegate::CreateNewFileInternal(
102 const base::FilePath& suggested_download_path, 105 const base::FilePath& suggested_download_path,
103 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) { 106 const DownloadTargetDeterminerDelegate::FileSelectedCallback& callback) {
104 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); 107 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE);
105 int uniquifier = base::GetUniquePathNumber(suggested_download_path, 108 int uniquifier = base::GetUniquePathNumber(suggested_download_path,
106 base::FilePath::StringType()); 109 base::FilePath::StringType());
107 base::FilePath new_path = suggested_download_path; 110 base::FilePath new_path = suggested_download_path;
108 if (uniquifier > 0) { 111 if (uniquifier > 0) {
109 new_path = suggested_download_path.InsertBeforeExtensionASCII( 112 new_path = suggested_download_path.InsertBeforeExtensionASCII(
110 base::StringPrintf(" (%d)", uniquifier)); 113 base::StringPrintf(" (%d)", uniquifier));
111 } 114 }
112 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 115 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
113 base::Bind(callback, new_path)); 116 base::Bind(callback, new_path));
114 } 117 }
115 118
116 } // namespace android 119 } // namespace android
117 } // namespace chrome 120 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698