Index: chrome/browser/android/download/download_overwrite_infobar_delegate_for_android_download_manager.cc |
diff --git a/chrome/browser/android/download/download_overwrite_infobar_delegate_for_android_download_manager.cc b/chrome/browser/android/download/download_overwrite_infobar_delegate_for_android_download_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..881d5d8621cca497a9642d8cef58744124194b31 |
--- /dev/null |
+++ b/chrome/browser/android/download/download_overwrite_infobar_delegate_for_android_download_manager.cc |
@@ -0,0 +1,92 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/android/download/download_overwrite_infobar_delegate_for_android_download_manager.h" |
+ |
+#include "base/android/jni_string.h" |
+#include "base/files/file_util.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "base/strings/stringprintf.h" |
+#include "chrome/browser/android/download/chrome_download_delegate.h" |
+#include "chrome/browser/infobars/infobar_service.h" |
+#include "chrome/browser/ui/android/infobars/download_overwrite_infobar.h" |
+#include "components/infobars/core/infobar.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/web_contents.h" |
+ |
+using base::android::ScopedJavaLocalRef; |
+ |
+namespace chrome { |
+namespace android { |
+ |
+DownloadOverwriteInfoBarDelegateForAndroidDownloadManager:: |
+ ~DownloadOverwriteInfoBarDelegateForAndroidDownloadManager() { |
+} |
+ |
+// static |
+void DownloadOverwriteInfoBarDelegateForAndroidDownloadManager::Create( |
+ InfoBarService* infobar_service, |
+ const std::string& file_name, |
+ const std::string& dir_name, |
+ const std::string& dir_full_path, |
+ JavaObjectWeakGlobalRef chrome_download_delegate, |
+ const ScopedJavaGlobalRef<jobject>& download_info) { |
+ infobar_service->AddInfoBar( |
+ DownloadOverwriteInfoBar::CreateInfoBar(make_scoped_ptr( |
+ new DownloadOverwriteInfoBarDelegateForAndroidDownloadManager( |
+ file_name, dir_name, dir_full_path, chrome_download_delegate, |
+ download_info)))); |
+} |
+ |
+void DownloadOverwriteInfoBarDelegateForAndroidDownloadManager:: |
+ OverwriteExistingFile() { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ ChromeDownloadDelegate::EnqueueDownloadManagerRequest( |
+ env, chrome_download_delegate_, true, download_info_); |
+} |
+ |
+void DownloadOverwriteInfoBarDelegateForAndroidDownloadManager:: |
+ CreateNewFile() { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ ChromeDownloadDelegate::EnqueueDownloadManagerRequest( |
+ env, chrome_download_delegate_, false, download_info_); |
+} |
+ |
+DownloadOverwriteInfoBarDelegateForAndroidDownloadManager:: |
+ DownloadOverwriteInfoBarDelegateForAndroidDownloadManager( |
+ const std::string& file_name, |
+ const std::string& dir_name, |
+ const std::string& dir_full_path, |
+ JavaObjectWeakGlobalRef chrome_download_delegate, |
+ const ScopedJavaGlobalRef<jobject>& download_info) |
+ : file_name_(file_name), |
+ dir_name_(dir_name), |
+ dir_full_path_(dir_full_path) { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ chrome_download_delegate_ = chrome_download_delegate; |
Peter Kasting
2015/03/02 21:05:15
Nit: Can't this be initialized in the initializer
Changwan Ryu
2015/03/04 05:15:03
Not applicable as I've changed it to scopedjavaglo
|
+ download_info_.Reset(env, download_info.obj()); |
+} |
+ |
+std::string |
+DownloadOverwriteInfoBarDelegateForAndroidDownloadManager::GetFileName() const { |
+ return file_name_; |
+} |
+ |
+std::string |
+DownloadOverwriteInfoBarDelegateForAndroidDownloadManager::GetDirName() const { |
+ return dir_name_; |
+} |
+ |
+std::string |
+DownloadOverwriteInfoBarDelegateForAndroidDownloadManager::GetDirFullPath() |
+ const { |
+ return dir_full_path_; |
+} |
+ |
+void DownloadOverwriteInfoBarDelegateForAndroidDownloadManager:: |
+ InfoBarDismissed() { |
+} |
+ |
+} // namespace android |
+} // namespace chrome |