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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ChromeDownloadDelegate.java

Issue 1854523002: If a download is initiated by download attribute, don't use stream viewer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 package org.chromium.chrome.browser.download; 5 package org.chromium.chrome.browser.download;
6 6
7 import android.Manifest.permission; 7 import android.Manifest.permission;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.DownloadManager; 9 import android.app.DownloadManager;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 @Override 142 @Override
143 public void onDestroyed(Tab tab) { 143 public void onDestroyed(Tab tab) {
144 mTab = null; 144 mTab = null;
145 } 145 }
146 }); 146 });
147 147
148 mPendingRequest = null; 148 mPendingRequest = null;
149 mDangerousDownloadListener = new DangerousDownloadListener(); 149 mDangerousDownloadListener = new DangerousDownloadListener();
150 } 150 }
151 151
152 /**
153 * Request a download from the given url, or if a streaming viewer is availa ble stream the
154 * content into the viewer.
155 * @param downloadInfo Information about the download.
156 */
157 @Override 152 @Override
158 public void requestHttpGetDownload(DownloadInfo downloadInfo) { 153 public void requestHttpGetDownload(DownloadInfo downloadInfo, boolean mustDo wnload) {
159 // If we're dealing with A/V content that's not explicitly marked for do wnload, check if it 154 // If we're dealing with A/V content that's not explicitly marked for do wnload, check if it
160 // is streamable. 155 // is streamable.
161 if (!DownloadManagerService.isAttachment(downloadInfo.getContentDisposit ion())) { 156 if (!mustDownload) {
162 // Query the package manager to see if there's a registered handler that matches. 157 // Query the package manager to see if there's a registered handler that matches.
163 Intent intent = new Intent(Intent.ACTION_VIEW); 158 Intent intent = new Intent(Intent.ACTION_VIEW);
164 intent.setDataAndType(Uri.parse(downloadInfo.getUrl()), downloadInfo .getMimeType()); 159 intent.setDataAndType(Uri.parse(downloadInfo.getUrl()), downloadInfo .getMimeType());
165 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 160 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
166 // If the intent is resolved to ourselves, we don't want to attempt to load the url 161 // If the intent is resolved to ourselves, we don't want to attempt to load the url
167 // only to try and download it again. 162 // only to try and download it again.
168 if (DownloadManagerService.openIntent(mContext, intent, false)) { 163 if (DownloadManagerService.openIntent(mContext, intent, false)) {
169 return; 164 return;
170 } 165 }
171 } 166 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 private static native String nativeGetDownloadWarningText(String filename); 626 private static native String nativeGetDownloadWarningText(String filename);
632 private static native boolean nativeIsDownloadDangerous(String filename); 627 private static native boolean nativeIsDownloadDangerous(String filename);
633 private static native void nativeDangerousDownloadValidated( 628 private static native void nativeDangerousDownloadValidated(
634 Object tab, String downloadGuid, boolean accept); 629 Object tab, String downloadGuid, boolean accept);
635 private static native void nativeLaunchDownloadOverwriteInfoBar(ChromeDownlo adDelegate delegate, 630 private static native void nativeLaunchDownloadOverwriteInfoBar(ChromeDownlo adDelegate delegate,
636 Tab tab, DownloadInfo downloadInfo, String fileName, String dirName, 631 Tab tab, DownloadInfo downloadInfo, String fileName, String dirName,
637 String dirFullPath); 632 String dirFullPath);
638 private static native void nativeLaunchPermissionUpdateInfoBar( 633 private static native void nativeLaunchPermissionUpdateInfoBar(
639 Tab tab, String permission, long callbackId); 634 Tab tab, String permission, long callbackId);
640 } 635 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/download/DownloadManagerService.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698