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

Side by Side Diff: chrome/browser/ui/android/infobars/download_overwrite_infobar.cc

Issue 580043002: [Android] Prompt with infobar on filename conflict (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed pkasting@'s comments Created 6 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
(Empty)
1 // Copyright 2014 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/ui/android/infobars/download_overwrite_infobar.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h"
10 #include "base/android/jni_weak_ref.h"
11 #include "chrome/browser/android/download_overwrite_infobar_delegate.h"
12 #include "jni/DownloadOverwriteInfoBarDelegate_jni.h"
13
14 using chrome::android::DownloadOverwriteInfoBarDelegate;
15
16 // static
17 scoped_ptr<infobars::InfoBar> DownloadOverwriteInfoBar::CreateInfoBar(
18 scoped_ptr<DownloadOverwriteInfoBarDelegate> delegate) {
19 return make_scoped_ptr(new DownloadOverwriteInfoBar(delegate.Pass()));
20 }
21
22 DownloadOverwriteInfoBar::~DownloadOverwriteInfoBar() {
23 }
24
25 DownloadOverwriteInfoBar::DownloadOverwriteInfoBar(
26 scoped_ptr<DownloadOverwriteInfoBarDelegate> delegate)
27 : InfoBarAndroid(delegate.Pass()),
28 java_delegate_() {
29 }
30
31 ScopedJavaLocalRef<jobject> DownloadOverwriteInfoBar::CreateRenderInfoBar(
32 JNIEnv* env) {
33 java_delegate_.Reset(Java_DownloadOverwriteInfoBarDelegate_create(env));
34 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
35 ScopedJavaLocalRef<jstring> j_file_name =
36 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName());
37 ScopedJavaLocalRef<jstring> j_dir_name =
38 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName());
39 ScopedJavaLocalRef<jstring> j_dir_full_path =
40 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath());
41 return Java_DownloadOverwriteInfoBarDelegate_showDownloadOverwriteInfoBar(
42 env, java_delegate_.obj(), reinterpret_cast<intptr_t>(this),
Ted C 2014/10/27 15:30:12 I think if the parameters don't all fit on a singl
Changwan Ryu 2014/10/28 04:59:44 Done.
43 j_file_name.obj(), j_dir_name.obj(), j_dir_full_path.obj());
44 }
45
46 void DownloadOverwriteInfoBar::ProcessButton(int action,
47 const std::string& action_value) {
48 if (!owner())
49 return; // We're closing; don't call anything, it might access the owner.
50
51 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
52 if (action == InfoBarAndroid::ACTION_OK)
53 delegate->AcceptOverwrite();
54 else if (action == InfoBarAndroid::ACTION_CANCEL)
55 delegate->CancelDownload();
56 else
57 DCHECK(false);
58
59 RemoveSelf();
60 }
61
62 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() {
63 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate());
64 }
65
66 // Native JNI methods ---------------------------------------------------------
67
68 bool RegisterDownloadOverwriteInfoBarDelegate(JNIEnv* env) {
69 return RegisterNativesImpl(env);
70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698