Bug 712748 - uriloader did not recognize ".jpg" filename extension because Android returned ".jpeg". r=cpeterson
authorIan Patterson <ipatterson@catalystitservices.com>
Fri, 14 Dec 2012 11:36:38 -0800
changeset 125213 11e5207523120ac832493e25647a049073950257
parent 125212 f75a9f57c14e796b6eae9637e3a40a602dc8bb18
child 125214 38754d5fcc855c326d3dad1722346ccbff0aeb9a
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpeterson
bugs712748
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 712748 - uriloader did not recognize ".jpg" filename extension because Android returned ".jpeg". r=cpeterson
uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
@@ -265,29 +265,25 @@ nsMIMEInfoAndroid::SetFileExtensions(con
     mExtensions.AppendElement(extList);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::ExtensionExists(const nsACString & aExtension, bool *aRetVal)
 {
   NS_ASSERTION(!aExtension.IsEmpty(), "no extension");
-  bool found = false;
-  uint32_t extCount = mExtensions.Length();
-  if (extCount < 1) return NS_OK;
 
-  for (uint8_t i=0; i < extCount; i++) {
-    const nsCString& ext = mExtensions[i];
-    if (ext.Equals(aExtension, nsCaseInsensitiveCStringComparator())) {
-      found = true;
-      break;
-    }
+  nsCString mimeType;
+  if (mozilla::AndroidBridge::Bridge()) {
+      mozilla::AndroidBridge::Bridge()->
+        GetMimeTypeFromExtensions(aExtension, mimeType);
   }
 
-  *aRetVal = found;
+  // "*/*" means the bridge didn't find anything (i.e., extension doesn't exist).
+  *aRetVal = !mimeType.Equals(nsDependentCString("*/*"), nsCaseInsensitiveCStringComparator());
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::AppendExtension(const nsACString & aExtension)
 {
   mExtensions.AppendElement(aExtension);
   return NS_OK;