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

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: changed function order according to headers 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/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 "base/files/file_path.h"
12 #include "chrome/browser/android/download/download_overwrite_infobar_delegate.h"
13 #include "jni/DownloadOverwriteInfoBar_jni.h"
14
15 using chrome::android::DownloadOverwriteInfoBarDelegate;
16
17 // static
18 scoped_ptr<infobars::InfoBar> DownloadOverwriteInfoBar::CreateInfoBar(
19 scoped_ptr<DownloadOverwriteInfoBarDelegate> delegate) {
20 return make_scoped_ptr(new DownloadOverwriteInfoBar(delegate.Pass()));
21 }
22
23 DownloadOverwriteInfoBar::~DownloadOverwriteInfoBar() {
24 }
25
26 DownloadOverwriteInfoBar::DownloadOverwriteInfoBar(
27 scoped_ptr<DownloadOverwriteInfoBarDelegate> delegate)
28 : InfoBarAndroid(delegate.Pass()) {
29 }
30
31 base::android::ScopedJavaLocalRef<jobject>
32 DownloadOverwriteInfoBar::CreateRenderInfoBar(JNIEnv* env) {
33 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
34
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 base::android::ScopedJavaLocalRef<jobject> java_infobar(
42 Java_DownloadOverwriteInfoBar_createInfoBar(
43 env, reinterpret_cast<intptr_t>(this), j_file_name.obj(),
44 j_dir_name.obj(), j_dir_full_path.obj()));
45 return java_infobar;
46 }
47
48 void DownloadOverwriteInfoBar::ProcessButton(int action,
49 const std::string& action_value) {
50 if (!owner())
51 return; // We're closing; don't call anything, it might access the owner.
52
53 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate();
54 if (action == InfoBarAndroid::ACTION_OVERWRITE)
55 delegate->OverwriteExistingFile();
56 else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE)
57 delegate->CreateNewFile();
58 else
59 DCHECK(false);
60
61 RemoveSelf();
62 }
63
64 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() {
65 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate());
66 }
67
68 // Native JNI methods ---------------------------------------------------------
69
70 bool RegisterDownloadOverwriteInfoBarDelegate(JNIEnv* env) {
71 return RegisterNativesImpl(env);
72 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/infobars/download_overwrite_infobar.h ('k') | chrome/browser/ui/android/infobars/infobar_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698