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

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 5 years, 10 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/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()), java_delegate_() {
28 }
29
30 ScopedJavaLocalRef<jobject> DownloadOverwriteInfoBar::CreateRenderInfoBar(
31 JNIEnv* env) {
32 java_delegate_.Reset(Java_DownloadOverwriteInfoBarDelegate_create(env));
33 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
34 ScopedJavaLocalRef<jstring> j_file_name =
35 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName());
36 ScopedJavaLocalRef<jstring> j_dir_name =
37 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName());
38 ScopedJavaLocalRef<jstring> j_dir_full_path =
39 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath());
40 return Java_DownloadOverwriteInfoBarDelegate_showDownloadOverwriteInfoBar(
41 env, java_delegate_.obj(), reinterpret_cast<intptr_t>(this),
42 j_file_name.obj(), j_dir_name.obj(), j_dir_full_path.obj());
43 }
44
45 void DownloadOverwriteInfoBar::ProcessButton(int action,
46 const std::string& action_value) {
47 if (!owner())
48 return; // We're closing; don't call anything, it might access the owner.
49
50 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
51 if (action == InfoBarAndroid::ACTION_OVERWRITE)
52 delegate->OverwriteExistingFile();
53 else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE)
54 delegate->CreateNewFile();
55 else
56 DCHECK(false);
Peter Kasting 2015/02/18 21:32:29 Just to be sure, this function never gets reached
Changwan Ryu 2015/02/19 07:41:15 Correct. We have a separate function to handle clo
57
58 RemoveSelf();
59 }
60
61 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() {
62 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate());
63 }
64
65 // Native JNI methods ---------------------------------------------------------
66
67 bool RegisterDownloadOverwriteInfoBarDelegate(JNIEnv* env) {
68 return RegisterNativesImpl(env);
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698