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
--- 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;