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

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

Issue 580043002: [Android] Prompt with infobar on filename conflict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/download/android_download_manager_overwrite_inf obar_delegate.h"
6
7 #include "base/android/jni_string.h"
8 #include "base/files/file_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/stringprintf.h"
11 #include "chrome/browser/android/download/chrome_download_delegate.h"
12 #include "chrome/browser/infobars/infobar_service.h"
13 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h"
14 #include "components/infobars/core/infobar.h"
15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/web_contents.h"
17
18 using base::android::ScopedJavaLocalRef;
19
20 namespace chrome {
21 namespace android {
22
23 AndroidDownloadManagerOverwriteInfoBarDelegate::
24 ~AndroidDownloadManagerOverwriteInfoBarDelegate() {
25 }
26
27 // static
28 void AndroidDownloadManagerOverwriteInfoBarDelegate::Create(
29 InfoBarService* infobar_service,
30 const std::string& file_name,
31 const std::string& dir_name,
32 const std::string& dir_full_path,
33 jobject chrome_download_delegate,
34 jobject download_info) {
35 infobar_service->AddInfoBar(DownloadOverwriteInfoBar::CreateInfoBar(
36 make_scoped_ptr(new AndroidDownloadManagerOverwriteInfoBarDelegate(
37 file_name, dir_name, dir_full_path, chrome_download_delegate,
38 download_info))));
39 }
40
41 void AndroidDownloadManagerOverwriteInfoBarDelegate::OverwriteExistingFile() {
42 ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
43 chrome_download_delegate_.obj(), true, download_info_.obj());
44 }
45
46 void AndroidDownloadManagerOverwriteInfoBarDelegate::CreateNewFile() {
47 ChromeDownloadDelegate::EnqueueDownloadManagerRequest(
48 chrome_download_delegate_.obj(), false, download_info_.obj());
49 }
50
51 AndroidDownloadManagerOverwriteInfoBarDelegate::
Ted C 2015/03/04 16:24:24 This should go right under Create to match the hea
Changwan Ryu 2015/03/04 16:41:33 Done.
52 AndroidDownloadManagerOverwriteInfoBarDelegate(
53 const std::string& file_name,
54 const std::string& dir_name,
55 const std::string& dir_full_path,
56 jobject chrome_download_delegate,
57 jobject download_info)
58 : file_name_(file_name),
59 dir_name_(dir_name),
60 dir_full_path_(dir_full_path) {
61 JNIEnv* env = base::android::AttachCurrentThread();
62 chrome_download_delegate_.Reset(env, chrome_download_delegate);
63 download_info_.Reset(env, download_info);
64 }
65
66 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetFileName()
67 const {
68 return file_name_;
69 }
70
71 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetDirName() const {
72 return dir_name_;
73 }
74
75 std::string AndroidDownloadManagerOverwriteInfoBarDelegate::GetDirFullPath()
76 const {
77 return dir_full_path_;
78 }
79
80 } // namespace android
81 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698