Bug 1332568 - Make nsContentTypeParser use nsMIMEHeaderParamImpl::DoGetParameter - r?mcmanus
MozReview-Commit-ID: 1APNkh0QyN5
--- a/dom/base/nsContentTypeParser.h
+++ b/dom/base/nsContentTypeParser.h
@@ -4,25 +4,22 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsContentTypeParser_h
#define nsContentTypeParser_h
#include "nsAString.h"
-class nsIMIMEHeaderParam;
-
class nsContentTypeParser {
public:
explicit nsContentTypeParser(const nsAString& aString);
~nsContentTypeParser();
nsresult GetParameter(const char* aParameterName, nsAString& aResult) const;
nsresult GetType(nsAString& aResult) const;
private:
NS_ConvertUTF16toUTF8 mString;
- nsIMIMEHeaderParam* mService;
};
#endif
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -141,17 +141,16 @@
#include "nsIImageLoadingContent.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIIOService.h"
#include "nsILineBreaker.h"
#include "nsILoadContext.h"
#include "nsILoadGroup.h"
#include "nsIMemoryReporter.h"
-#include "nsIMIMEHeaderParam.h"
#include "nsIMIMEService.h"
#include "nsINode.h"
#include "mozilla/dom/NodeInfo.h"
#include "nsIObjectLoadingContent.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIOfflineCacheUpdate.h"
#include "nsIParser.h"
@@ -172,16 +171,17 @@
#include "nsIURIWithPrincipal.h"
#include "nsIURL.h"
#include "nsIWebNavigation.h"
#include "nsIWindowMediator.h"
#include "nsIWordBreaker.h"
#include "nsIXPConnect.h"
#include "nsJSUtils.h"
#include "nsLWBrkCIID.h"
+#include "nsMIMEHeaderParamImpl.h"
#include "nsNetCID.h"
#include "nsNetUtil.h"
#include "nsNodeInfoManager.h"
#include "nsNullPrincipal.h"
#include "nsParserCIID.h"
#include "nsParserConstants.h"
#include "nsPIDOMWindow.h"
#include "nsPresContext.h"
@@ -6131,34 +6131,36 @@ nsContentUtils::CheckMayLoad(nsIPrincipa
nsCOMPtr<nsIURI> channelURI;
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(channelURI));
NS_ENSURE_SUCCESS(rv, false);
return NS_SUCCEEDED(aPrincipal->CheckMayLoad(channelURI, false, aAllowIfInheritsPrincipal));
}
nsContentTypeParser::nsContentTypeParser(const nsAString& aString)
- : mString(aString), mService(nullptr)
-{
- CallGetService("@mozilla.org/network/mime-hdrparam;1", &mService);
+ : mString(aString)
+{
}
nsContentTypeParser::~nsContentTypeParser()
{
- NS_IF_RELEASE(mService);
}
nsresult
nsContentTypeParser::GetParameter(const char* aParameterName,
nsAString& aResult) const
{
- NS_ENSURE_TRUE(mService, NS_ERROR_FAILURE);
- return mService->GetParameterHTTP(mString, aParameterName,
- EmptyCString(), false, nullptr,
- aResult);
+ return nsMIMEHeaderParamImpl::DoGetParameter(
+ /* aHeaderVal */ mString,
+ /* aParamName */ aParameterName,
+ /* aDecoding */ nsMIMEHeaderParamImpl::HTTP_FIELD_ENCODING,
+ /* aFallbackCharset */ EmptyCString(),
+ /* aTryLocaleCharset */ false,
+ /* aLang*/ nullptr,
+ aResult);
}
nsresult
nsContentTypeParser::GetType(nsAString& aResult) const
{
nsresult rv = GetParameter(nullptr, aResult);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::ASCIIToLower(aResult);