Bug 630364 - external application handlers do not honor warning preferences. r=blassey. a=blocking-fennec
authorDoug Turner <dougt@dougt.org>
Wed, 09 Feb 2011 11:40:24 -0800
changeset 62247 128423281c995525d1e88ff458544b70446b6309
parent 62246 787ec4f8b8062d6a3800c470d7194c41f11d36fb
child 62248 e71960b6957c068088d74ee3cd0f5e16a38f6eb3
push idunknown
push userunknown
push dateunknown
reviewersblassey, blocking-fennec
bugs630364
milestone2.0b12pre
Bug 630364 - external application handlers do not honor warning preferences. r=blassey. a=blocking-fennec
uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
uriloader/exthandler/android/nsMIMEInfoAndroid.h
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.cpp
@@ -51,19 +51,20 @@ nsMIMEInfoAndroid::LaunchDefaultWithFile
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::LoadUriInternal(nsIURI * aURI)
 {
   nsCString uriSpec;
   aURI->GetSpec(uriSpec);
+
   if (mozilla::AndroidBridge::Bridge())
     return mozilla::AndroidBridge::Bridge()->
-      OpenUriExternal(uriSpec, mMimeType) ? NS_OK : NS_ERROR_FAILURE;
+      OpenUriExternal(uriSpec, EmptyCString()) ? NS_OK : NS_ERROR_FAILURE;
 
   return NS_ERROR_FAILURE;
 }
 
 
 PRBool
 nsMIMEInfoAndroid::GetMimeInfoForMimeType(const nsACString& aMimeType,
                                           nsMIMEInfoAndroid** aMimeInfo)
@@ -109,22 +110,21 @@ nsMIMEInfoAndroid::GetMimeInfoForFileExt
 /**
  * Returns MIME info for the aURL, which may contain the whole URL or only a protocol
  */
 nsresult
 nsMIMEInfoAndroid::GetMimeInfoForURL(const nsACString &aURL,
                                      PRBool *found,
                                      nsIHandlerInfo **info)
 {
-  const nsCString &emptyC = EmptyCString();
-  mozilla::AndroidBridge* bridge = mozilla::AndroidBridge::Bridge();
-  nsMIMEInfoAndroid *mimeinfo = new nsMIMEInfoAndroid(emptyC);
+  nsMIMEInfoAndroid *mimeinfo = new nsMIMEInfoAndroid(aURL);
   NS_ADDREF(*info = mimeinfo);
   *found = PR_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 = nsnull;
   bridge->GetHandlersForURL(nsCAutoString(aURL).get(), 
@@ -144,17 +144,17 @@ nsMIMEInfoAndroid::GetMimeInfoForURL(con
   }
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::GetType(nsACString& aType)
 {
-  aType.Assign(mMimeType);
+  aType.Assign(mType);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::GetDescription(nsAString& aDesc)
 {
   aDesc.Assign(mDescription);
   return NS_OK;
@@ -336,30 +336,30 @@ nsMIMEInfoAndroid::SetPrimaryExtension(c
   mExtensions.InsertElementAt(0, aExtension);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::GetMIMEType(nsACString & aMIMEType)
 {
-  aMIMEType.Assign(mMimeType);
+  aMIMEType.Assign(mType);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::Equals(nsIMIMEInfo *aMIMEInfo, PRBool *aRetVal)
 {
   if (!aMIMEInfo) return NS_ERROR_NULL_POINTER;
 
   nsCAutoString type;
   nsresult rv = aMIMEInfo->GetMIMEType(type);
   if (NS_FAILED(rv)) return rv;
 
-  *aRetVal = mMimeType.Equals(type);
+  *aRetVal = mType.Equals(type);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsMIMEInfoAndroid::GetPossibleLocalHandlers(nsIArray * *aPossibleLocalHandlers)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
@@ -370,17 +370,17 @@ nsMIMEInfoAndroid::LaunchWithFile(nsIFil
 {
   nsIURI* uri;
   NS_NewFileURI(&uri, aFile);
   LoadUriInternal(uri);
   return NS_OK;
 }
 
 nsMIMEInfoAndroid::nsMIMEInfoAndroid(const nsACString& aMIMEType) :
-  mMimeType(aMIMEType), mAlwaysAsk(PR_TRUE),
+  mType(aMIMEType), mAlwaysAsk(PR_TRUE),
   mPrefAction(nsIMIMEInfo::useHelperApp)
 {
   mPrefApp = new nsMIMEInfoAndroid::SystemChooser(this);
   nsresult rv;
   mHandlerApps = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
   mHandlerApps->AppendElement(mPrefApp, PR_FALSE);
 }
 
--- a/uriloader/exthandler/android/nsMIMEInfoAndroid.h
+++ b/uriloader/exthandler/android/nsMIMEInfoAndroid.h
@@ -60,17 +60,17 @@ public:
   NS_DECL_NSIHANDLERINFO
 
   nsMIMEInfoAndroid(const nsACString& aMIMEType);
 
 protected:
   virtual NS_HIDDEN_(nsresult) LaunchDefaultWithFile(nsIFile* aFile);
   virtual NS_HIDDEN_(nsresult) LoadUriInternal(nsIURI *aURI);
   nsCOMPtr<nsIMutableArray> mHandlerApps;
-  nsCString mMimeType;
+  nsCString mType;
   nsTArray<nsCString> mExtensions;
   PRBool mAlwaysAsk;
   nsHandlerInfoAction mPrefAction;
   nsString mDescription;
   nsCOMPtr<nsIHandlerApp> mPrefApp;
   
   class SystemChooser : public nsIHandlerApp {
   public: