Bug 757927 - Return the result of loadUriInternal instead of always returning NS_OK. r=wesj, r=blassey
authorJames Gilbertson <james.gilbertson@luniv.ca>
Fri, 18 Apr 2014 22:00:00 -0400
changeset 180247 d1ce42fc5cc37f3f4a9e424c210328ac32ecc2ce
parent 180246 6fa6a3e42d65981df45b24326826f7be387fb5e5
child 180248 cabda6c7f0e9bd18ca13da17bd44e2b402c08cca
push id26658
push userryanvm@gmail.com
push dateFri, 25 Apr 2014 20:24:05 +0000
treeherdermozilla-central@0e91262606a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswesj, blassey
bugs757927
milestone31.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 757927 - Return the result of loadUriInternal instead of always returning NS_OK. r=wesj, r=blassey
uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
@@ -12,35 +12,41 @@
 
 using namespace mozilla::widget::android;
 
 NS_IMPL_ISUPPORTS2(nsMIMEInfoAndroid, nsIMIMEInfo, nsIHandlerInfo)
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::LaunchDefaultWithFile(nsIFile* aFile)
 {
-  LaunchWithFile(aFile);
-  return NS_OK;
+  return LaunchWithFile(aFile);
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
 {
   nsCString uriSpec;
   aURI->GetSpec(uriSpec);
 
   nsCString uriScheme;
   aURI->GetScheme(uriScheme);
 
-  return mozilla::widget::android::GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec),
-    (mType.Equals(uriScheme) || mType.Equals(uriSpec)) ?
-     EmptyString() : NS_ConvertUTF8toUTF16(mType)) ? NS_OK : NS_ERROR_FAILURE;
+  nsAutoString mimeType;
+  if (mType.Equals(uriScheme) || mType.Equals(uriSpec)) {
+    mimeType = EmptyString();
+  } else {
+    mimeType = NS_ConvertUTF8toUTF16(mType);
+  }
+
+  if (GeckoAppShell::OpenUriExternal(NS_ConvertUTF8toUTF16(uriSpec), mimeType)) {
+    return NS_OK;
+  }
+  return NS_ERROR_FAILURE;
 }
 
-
 bool
 nsMIMEInfoAndroid::GetMimeInfoForMimeType(const nsACString& aMimeType,
                                           nsMIMEInfoAndroid** aMimeInfo)
 {
   nsRefPtr<nsMIMEInfoAndroid> info = new nsMIMEInfoAndroid(aMimeType);
   mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge();
   // we don't have access to the bridge, so just assume we can handle
   // the mime type for now and let the system deal with it
@@ -53,44 +59,44 @@ nsMIMEInfoAndroid::GetMimeInfoForMimeTyp
 
   if (!IsUTF8(aMimeType, true))
     return false;
 
   NS_ConvertUTF8toUTF16 mimeType(aMimeType);
 
   bridge->GetHandlersForMimeType(mimeType,
                                  info->mHandlerApps, &systemDefault);
-  
+
   if (systemDefault)
     info->mPrefApp = systemDefault;
 
   nsAutoCString fileExt;
   bridge->GetExtensionFromMimeType(aMimeType, fileExt);
   info->SetPrimaryExtension(fileExt);
-  
+
   uint32_t len;
   info->mHandlerApps->GetLength(&len);
   if (len == 1) {
     info.forget(aMimeInfo);
     return false;
   }
-  
+
   info.forget(aMimeInfo);
   return true;
 }
-  
+
 bool
 nsMIMEInfoAndroid::GetMimeInfoForFileExt(const nsACString& aFileExt,
                                          nsMIMEInfoAndroid **aMimeInfo)
 {
   nsCString mimeType;
   if (mozilla::AndroidBridge::Bridge())
     mozilla::AndroidBridge::Bridge()->
       GetMimeTypeFromExtensions(aFileExt, mimeType);
-  
+
   // "*/*" means that the bridge didn't know.
   if (mimeType.Equals(nsDependentCString("*/*"), nsCaseInsensitiveCStringComparator()))
     return false;
 
   bool found = GetMimeInfoForMimeType(mimeType, aMimeInfo);
   (*aMimeInfo)->SetPrimaryExtension(aFileExt);
   return found;
 }
@@ -101,47 +107,47 @@ nsMIMEInfoAndroid::GetMimeInfoForFileExt
 nsresult
 nsMIMEInfoAndroid::GetMimeInfoForURL(const nsACString &aURL,
                                      bool *found,
                                      nsIHandlerInfo **info)
 {
   nsMIMEInfoAndroid *mimeinfo = new nsMIMEInfoAndroid(aURL);
   NS_ADDREF(*info = mimeinfo);
   *found = true;
-  
+
   mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge();
   if (!bridge) {
     // we don't have access to the bridge, so just assume we can handle
     // the protocol for now and let the system deal with it
     return NS_OK;
   }
 
   nsIHandlerApp* systemDefault = nullptr;
   bridge->GetHandlersForURL(NS_ConvertUTF8toUTF16(aURL),
                             mimeinfo->mHandlerApps, &systemDefault);
-  
+
   if (systemDefault)
     mimeinfo->mPrefApp = systemDefault;
 
 
   nsAutoCString fileExt;
   nsAutoCString mimeType;
   mimeinfo->GetType(mimeType);
   bridge->GetExtensionFromMimeType(mimeType, fileExt);
   mimeinfo->SetPrimaryExtension(fileExt);
-  
+
   uint32_t len;
   mimeinfo->mHandlerApps->GetLength(&len);
   if (len == 1) {
     // Code that calls this requires an object regardless if the OS has
     // something for us, so we return the empty object.
     *found = false;
     return NS_OK;
   }
-  
+
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::GetType(nsACString& aType)
 {
   aType.Assign(mType);
   return NS_OK;
@@ -354,18 +360,17 @@ nsMIMEInfoAndroid::GetPossibleLocalHandl
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::LaunchWithFile(nsIFile *aFile)
 {
   nsCOMPtr<nsIURI> uri;
   NS_NewFileURI(getter_AddRefs(uri), aFile);
-  LoadUriInternal(uri);
-  return NS_OK;
+  return LoadUriInternal(uri);
 }
 
 nsMIMEInfoAndroid::nsMIMEInfoAndroid(const nsACString& aMIMEType) :
   mType(aMIMEType), mAlwaysAsk(true),
   mPrefAction(nsIMIMEInfo::useHelperApp)
 {
   mPrefApp = new nsMIMEInfoAndroid::SystemChooser(this);
   nsresult rv;