OLD | NEW |
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/ui/android/infobars/download_overwrite_infobar.h" | 5 #include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 DownloadOverwriteInfoBar::CreateRenderInfoBar(JNIEnv* env) { | 35 DownloadOverwriteInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
36 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); | 36 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); |
37 | 37 |
38 ScopedJavaLocalRef<jstring> j_file_name = | 38 ScopedJavaLocalRef<jstring> j_file_name = |
39 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName()); | 39 base::android::ConvertUTF8ToJavaString(env, delegate->GetFileName()); |
40 ScopedJavaLocalRef<jstring> j_dir_name = | 40 ScopedJavaLocalRef<jstring> j_dir_name = |
41 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName()); | 41 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirName()); |
42 ScopedJavaLocalRef<jstring> j_dir_full_path = | 42 ScopedJavaLocalRef<jstring> j_dir_full_path = |
43 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath()); | 43 base::android::ConvertUTF8ToJavaString(env, delegate->GetDirFullPath()); |
44 base::android::ScopedJavaLocalRef<jobject> java_infobar( | 44 base::android::ScopedJavaLocalRef<jobject> java_infobar( |
45 Java_DownloadOverwriteInfoBar_createInfoBar( | 45 Java_DownloadOverwriteInfoBar_createInfoBar(env, j_file_name, j_dir_name, |
46 env, j_file_name.obj(), j_dir_name.obj(), j_dir_full_path.obj())); | 46 j_dir_full_path)); |
47 return java_infobar; | 47 return java_infobar; |
48 } | 48 } |
49 | 49 |
50 void DownloadOverwriteInfoBar::ProcessButton(int action) { | 50 void DownloadOverwriteInfoBar::ProcessButton(int action) { |
51 if (!owner()) | 51 if (!owner()) |
52 return; // We're closing; don't call anything, it might access the owner. | 52 return; // We're closing; don't call anything, it might access the owner. |
53 | 53 |
54 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); | 54 DownloadOverwriteInfoBarDelegate* delegate = GetDelegate(); |
55 if (action == InfoBarAndroid::ACTION_OVERWRITE) { | 55 if (action == InfoBarAndroid::ACTION_OVERWRITE) { |
56 if (delegate->OverwriteExistingFile()) | 56 if (delegate->OverwriteExistingFile()) |
57 RemoveSelf(); | 57 RemoveSelf(); |
58 } else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE) { | 58 } else if (action == InfoBarAndroid::ACTION_CREATE_NEW_FILE) { |
59 if (delegate->CreateNewFile()) | 59 if (delegate->CreateNewFile()) |
60 RemoveSelf(); | 60 RemoveSelf(); |
61 } else { | 61 } else { |
62 CHECK(false); | 62 CHECK(false); |
63 } | 63 } |
64 } | 64 } |
65 | 65 |
66 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() { | 66 DownloadOverwriteInfoBarDelegate* DownloadOverwriteInfoBar::GetDelegate() { |
67 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate()); | 67 return static_cast<DownloadOverwriteInfoBarDelegate*>(delegate()); |
68 } | 68 } |
OLD | NEW |