OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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/duplicate_download_infobar.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" |
| 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/android/download/duplicate_download_infobar_delegate.h" |
| 13 #include "jni/DuplicateDownloadInfoBar_jni.h" |
| 14 |
| 15 using chrome::android::DuplicateDownloadInfoBarDelegate; |
| 16 |
| 17 // static |
| 18 std::unique_ptr<infobars::InfoBar> DuplicateDownloadInfoBar::CreateInfoBar( |
| 19 std::unique_ptr<DuplicateDownloadInfoBarDelegate> delegate) { |
| 20 return base::WrapUnique(new DuplicateDownloadInfoBar(std::move(delegate))); |
| 21 } |
| 22 |
| 23 DuplicateDownloadInfoBar::~DuplicateDownloadInfoBar() { |
| 24 } |
| 25 |
| 26 DuplicateDownloadInfoBar::DuplicateDownloadInfoBar( |
| 27 std::unique_ptr<DuplicateDownloadInfoBarDelegate> delegate) |
| 28 : ConfirmInfoBar(std::move(delegate)) {} |
| 29 |
| 30 base::android::ScopedJavaLocalRef<jobject> |
| 31 DuplicateDownloadInfoBar::CreateRenderInfoBar(JNIEnv* env) { |
| 32 DuplicateDownloadInfoBarDelegate* delegate = GetDelegate(); |
| 33 |
| 34 base::android::ScopedJavaLocalRef<jstring> j_file_path = |
| 35 base::android::ConvertUTF8ToJavaString(env, delegate->GetFilePath()); |
| 36 base::android::ScopedJavaLocalRef<jstring> j_page_url = |
| 37 base::android::ConvertUTF8ToJavaString(env, delegate->GetPageURL()); |
| 38 base::android::ScopedJavaLocalRef<jobject> java_infobar( |
| 39 Java_DuplicateDownloadInfoBar_createInfoBar( |
| 40 env, j_file_path, delegate->IsOfflinePage(), j_page_url, |
| 41 delegate->IsOffTheRecord())); |
| 42 return java_infobar; |
| 43 } |
| 44 |
| 45 DuplicateDownloadInfoBarDelegate* DuplicateDownloadInfoBar::GetDelegate() { |
| 46 return static_cast<DuplicateDownloadInfoBarDelegate*>(delegate()); |
| 47 } |
OLD | NEW |