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/android/download/android_download_manager_duplicate_inf
obar_delegate.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/android/download/chrome_download_delegate.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/ui/android/infobars/duplicate_download_infobar.h" |
| 13 #include "components/infobars/core/infobar.h" |
| 14 |
| 15 using base::android::ScopedJavaLocalRef; |
| 16 |
| 17 namespace chrome { |
| 18 namespace android { |
| 19 |
| 20 AndroidDownloadManagerDuplicateInfoBarDelegate:: |
| 21 ~AndroidDownloadManagerDuplicateInfoBarDelegate() { |
| 22 } |
| 23 |
| 24 // static |
| 25 void AndroidDownloadManagerDuplicateInfoBarDelegate::Create( |
| 26 InfoBarService* infobar_service, |
| 27 const std::string& file_path, |
| 28 jobject chrome_download_delegate, |
| 29 jobject download_info, |
| 30 jboolean is_off_the_record) { |
| 31 infobar_service->AddInfoBar(DuplicateDownloadInfoBar::CreateInfoBar( |
| 32 base::WrapUnique(new AndroidDownloadManagerDuplicateInfoBarDelegate( |
| 33 file_path, chrome_download_delegate, download_info, |
| 34 is_off_the_record)))); |
| 35 } |
| 36 |
| 37 AndroidDownloadManagerDuplicateInfoBarDelegate:: |
| 38 AndroidDownloadManagerDuplicateInfoBarDelegate( |
| 39 const std::string& file_path, |
| 40 jobject chrome_download_delegate, |
| 41 jobject download_info, |
| 42 jboolean is_off_the_record) |
| 43 : file_path_(file_path), |
| 44 is_off_the_record_(is_off_the_record) { |
| 45 JNIEnv* env = base::android::AttachCurrentThread(); |
| 46 chrome_download_delegate_.Reset(env, chrome_download_delegate); |
| 47 download_info_.Reset(env, download_info); |
| 48 } |
| 49 |
| 50 infobars::InfoBarDelegate::InfoBarIdentifier |
| 51 AndroidDownloadManagerDuplicateInfoBarDelegate::GetIdentifier() const { |
| 52 return ANDROID_DOWNLOAD_MANAGER_DUPLICATE_INFOBAR_DELEGATE; |
| 53 } |
| 54 |
| 55 bool AndroidDownloadManagerDuplicateInfoBarDelegate::Accept() { |
| 56 bool tab_closed = ChromeDownloadDelegate::EnqueueDownloadManagerRequest( |
| 57 chrome_download_delegate_.obj(), true, download_info_.obj()); |
| 58 return !tab_closed; |
| 59 } |
| 60 |
| 61 bool AndroidDownloadManagerDuplicateInfoBarDelegate::Cancel() { |
| 62 return true; |
| 63 } |
| 64 |
| 65 std::string AndroidDownloadManagerDuplicateInfoBarDelegate::GetFilePath() |
| 66 const { |
| 67 return file_path_; |
| 68 } |
| 69 |
| 70 bool AndroidDownloadManagerDuplicateInfoBarDelegate::IsOffTheRecord() const { |
| 71 return is_off_the_record_; |
| 72 } |
| 73 |
| 74 } // namespace android |
| 75 } // namespace chrome |
OLD | NEW |