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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java

Issue 2469303002: 📰Open Downloads suggestions externally when appropriate (Closed)
Patch Set: whitespace Created 4 years, 1 month 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
Index: chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
index 8a92f12e6302dd7d303c5ecbaafba48bd9ebf48f..90c80dbb8778fa085ad6e0ce0992e29de01d7e83 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/download/ui/DownloadHistoryItemWrapper.java
@@ -4,17 +4,13 @@
package org.chromium.chrome.browser.download.ui;
-import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
-import android.content.Intent;
-import android.net.Uri;
import android.text.TextUtils;
import org.chromium.base.ContextUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.R;
-import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.download.DownloadItem;
import org.chromium.chrome.browser.download.DownloadUtils;
import org.chromium.chrome.browser.offlinepages.downloads.OfflinePageDownloadItem;
@@ -169,8 +165,6 @@ public String getMimeType() {
@Override
public void open() {
Context context = ContextUtils.getApplicationContext();
- Intent viewIntent = DownloadUtils.createViewIntentForDownloadItem(
- Uri.fromFile(getFile()), getMimeType());
if (mItem.hasBeenExternallyRemoved()) {
Toast.makeText(context, context.getString(R.string.download_cant_open_file),
@@ -178,30 +172,9 @@ public void open() {
return;
}
- // Check if Chrome should open the file itself.
- if (mBackendProvider.getDownloadDelegate().isDownloadOpenableInBrowser(
- mItem.getId(), mIsOffTheRecord, getMimeType())) {
- // Share URIs use the content:// scheme when able, which looks bad when displayed
- // in the URL bar.
- Uri fileUri = Uri.fromFile(getFile());
- Uri shareUri = DownloadUtils.getUriForItem(getFile());
- String mimeType = Intent.normalizeMimeType(getMimeType());
-
- Intent intent = DownloadUtils.getMediaViewerIntentForDownloadItem(
- fileUri, shareUri, mimeType);
- IntentHandler.startActivityForTrustedIntent(intent, context);
+ if (DownloadUtils.openFile(getFile(), getMimeType(), mIsOffTheRecord)) {
recordOpenSuccess();
- return;
- }
-
- // Check if any apps can open the file.
- try {
- context.startActivity(viewIntent);
- recordOpenSuccess();
- } catch (ActivityNotFoundException e) {
- // Can't launch the Intent.
- Toast.makeText(context, context.getString(R.string.download_cant_open_file),
- Toast.LENGTH_SHORT).show();
+ } else {
recordOpenFailure();
}
}

Powered by Google App Engine
This is Rietveld 408576698