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

Unified Diff: chrome/browser/android/download/download_controller.cc

Issue 2871663004: Remove webContents check when download starts (Closed)
Patch Set: nits Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/download/download_controller.cc
diff --git a/chrome/browser/android/download/download_controller.cc b/chrome/browser/android/download/download_controller.cc
index 1cef85af13e09d8d76cd5bb5705ecd8edb2d59a4..fdeea220a52ad4605ff080dd9c560e6da8ce409b 100644
--- a/chrome/browser/android/download/download_controller.cc
+++ b/chrome/browser/android/download/download_controller.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/android/download/chrome_download_delegate.h"
#include "chrome/browser/android/download/dangerous_download_infobar_delegate.h"
#include "chrome/browser/android/download/download_manager_service.h"
+#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/permissions/permission_update_infobar_delegate_android.h"
#include "chrome/browser/ui/android/view_android_helper.h"
@@ -293,21 +294,26 @@ bool DownloadController::HasFileAccessPermission() {
void DownloadController::OnDownloadStarted(
DownloadItem* download_item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- WebContents* web_contents = download_item->GetWebContents();
- if (!web_contents)
- return;
// Register for updates to the DownloadItem.
download_item->AddObserver(this);
- ChromeDownloadDelegate* delegate =
- ChromeDownloadDelegate::FromWebContents(web_contents);
// For dangerous item, we need to show the dangerous infobar before the
// download can start.
- if (!download_item->IsDangerous() && delegate) {
- delegate->OnDownloadStarted(
- download_item->GetTargetFilePath().BaseName().value());
+ JNIEnv* env = base::android::AttachCurrentThread();
+ if (!download_item->IsDangerous()) {
+ Java_DownloadController_onDownloadStarted(
+ env, GetJavaObject()->Controller(env));
}
+
+ WebContents* web_contents = download_item->GetWebContents();
+ if (web_contents) {
+ TabAndroid* tab = TabAndroid::FromWebContents(web_contents);
+ if (tab && !tab->GetJavaObject().is_null()) {
+ Java_DownloadController_closeTabIfBlank(env, tab->GetJavaObject());
+ }
+ }
+
OnDownloadUpdated(download_item);
}
« no previous file with comments | « chrome/browser/android/download/chrome_download_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698