Fixing bug 393756. Get the plugin mimetype from the file extension in the URI if no other type information is available. r+sr=bzbarsky@mit.edu
authorjst@mozilla.org
Thu, 27 Mar 2008 16:12:18 -0700
changeset 13648 40cd165b2c37c8518a57624f9fd08dc826d7f06e
parent 13647 76fb151fc96affe62fbc90af1e4aef85f93ed5f5
child 13649 d992d6a392259e395c35ba84798ca2d776fc39e4
push idunknown
push userunknown
push dateunknown
bugs393756
milestone1.9pre
Fixing bug 393756. Get the plugin mimetype from the file extension in the URI if no other type information is available. r+sr=bzbarsky@mit.edu
content/base/src/nsObjectLoadingContent.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -348,17 +348,18 @@ nsObjectLoadingContent::~nsObjectLoading
   DestroyImageLoadingContent();
   if (mFrameLoader) {
     mFrameLoader->Destroy();
   }
 }
 
 // nsIRequestObserver
 NS_IMETHODIMP
-nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
+nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
+                                       nsISupports *aContext)
 {
   if (aRequest != mChannel) {
     // This is a bit of an edge case - happens when a new load starts before the
     // previous one got here
     return NS_BINDING_ABORTED;
   }
 
   // We're done with the classifier
@@ -404,16 +405,27 @@ nsObjectLoadingContent::OnStartRequest(n
     // end up trying to dispatch to a nsFrameLoader, which will complain that
     // it couldn't find a way to handle application/octet-stream
 
     chan->SetContentType(mContentType);
   } else {
     mContentType = channelType;
   }
 
+  nsCOMPtr<nsIURI> uri;
+  chan->GetURI(getter_AddRefs(uri));
+
+  if (mContentType.EqualsASCII(APPLICATION_OCTET_STREAM)) {
+    nsCAutoString extType;
+    if (IsPluginEnabledByExtension(uri, extType)) {
+      mContentType = extType;
+      chan->SetContentType(extType);
+    }
+  }
+
   // Now find out what type the content is
   // UnloadContent will set our type to null; need to be sure to only set it to
   // the real value on success
   ObjectType newType = GetTypeOfContent(mContentType);
   LOG(("OBJLC [%p]: OnStartRequest: Content Type=<%s> Old type=%u New Type=%u\n",
        this, mContentType.get(), mType, newType));
 
   // Now do a content policy check
@@ -425,18 +437,16 @@ nsObjectLoadingContent::OnStartRequest(n
       break;
     case eType_Document:
       contentPolicyType = nsIContentPolicy::TYPE_SUBDOCUMENT;
       break;
     default:
       contentPolicyType = nsIContentPolicy::TYPE_OBJECT;
       break;
   }
-  nsCOMPtr<nsIURI> uri;
-  chan->GetURI(getter_AddRefs(uri));
   nsCOMPtr<nsIContent> thisContent = 
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   NS_ASSERTION(thisContent, "must be a content");
 
   nsIDocument* doc = thisContent->GetOwnerDoc();
   if (!doc) {
     Fallback(PR_FALSE);
     return NS_BINDING_ABORTED;