Bug 1100100 - "Downloaded file can't be opened from "Downloads" page" [r=wjohnston]
authorwesj <wjohnston@mozilla.com>
Fri, 19 Dec 2014 13:46:00 -0800
changeset 238312 de7d50fd87f8cb51fcb3964550efb6b573da4bd7
parent 238311 a275c8158e7838c27f9de30e9f7d8c89f330e1c1
child 238313 c0d25f0788a8655ce4a85e4070e49b442f960ad3
push id7472
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 20:36:27 +0000
treeherdermozilla-aurora@300ca104f8fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswjohnston
bugs1100100
milestone37.0a1
Bug 1100100 - "Downloaded file can't be opened from "Downloads" page" [r=wjohnston]
mobile/android/base/GeckoAppShell.java
--- a/mobile/android/base/GeckoAppShell.java
+++ b/mobile/android/base/GeckoAppShell.java
@@ -1163,34 +1163,36 @@ public class GeckoAppShell
 
         if (action.equalsIgnoreCase(Intent.ACTION_SEND)) {
             Intent shareIntent = getShareIntent(context, targetURI, mimeType, title);
             return Intent.createChooser(shareIntent,
                                         context.getResources().getString(R.string.share_title)); 
         }
 
         final Uri uri = normalizeUriScheme(targetURI.indexOf(':') >= 0 ? Uri.parse(targetURI) : new Uri.Builder().scheme(targetURI).build());
-        if (mimeType.length() > 0) {
+        if (!TextUtils.isEmpty(mimeType)) {
             Intent intent = getIntentForActionString(action);
             intent.setDataAndType(uri, mimeType);
             return intent;
         }
 
         if (!isUriSafeForScheme(uri)) {
             return null;
         }
 
         final String scheme = uri.getScheme();
 
         // Compute our most likely intent, then check to see if there are any
         // custom handlers that would apply.
         // Start with the original URI. If we end up modifying it, we'll
         // overwrite it.
+        final String extension = MimeTypeMap.getFileExtensionFromUrl(targetURI);
+        final String mimeType2 = getMimeTypeFromExtension(extension);
         final Intent intent = getIntentForActionString(action);
-        intent.setData(uri);
+        intent.setDataAndType(uri, mimeType2);
 
         if ("vnd.youtube".equals(scheme) &&
             !hasHandlersForIntent(intent) &&
             !TextUtils.isEmpty(uri.getSchemeSpecificPart())) {
 
             // Return an intent with a URI that will open the YouTube page in the
             // current Fennec instance.
             final Class<?> c;