mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1481176 - P2. Move nsContentTypeParser to its own file. r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D2800
This commit is contained in:
parent
35a7076534
commit
e4e8c5f1a8
@ -299,6 +299,7 @@ UNIFIED_SOURCES += [
|
||||
'nsContentPermissionHelper.cpp',
|
||||
'nsContentPolicy.cpp',
|
||||
'nsContentSink.cpp',
|
||||
'nsContentTypeParser.cpp',
|
||||
'nsCopySupport.cpp',
|
||||
'nsDataDocumentContentPolicy.cpp',
|
||||
'nsDocument.cpp',
|
||||
|
40
dom/base/nsContentTypeParser.cpp
Normal file
40
dom/base/nsContentTypeParser.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#include "nsContentTypeParser.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
nsContentTypeParser::nsContentTypeParser(const nsAString& aString)
|
||||
: mString(aString)
|
||||
, mService(nullptr)
|
||||
{
|
||||
CallGetService("@mozilla.org/network/mime-hdrparam;1", &mService);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentTypeParser::GetType(nsAString& aResult) const
|
||||
{
|
||||
nsresult rv = GetParameter(nullptr, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsContentUtils::ASCIIToLower(aResult);
|
||||
return NS_OK;
|
||||
}
|
@ -6424,40 +6424,7 @@ nsContentUtils::CheckMayLoad(nsIPrincipal* aPrincipal, nsIChannel* aChannel, boo
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsContentTypeParser::GetType(nsAString& aResult) const
|
||||
{
|
||||
nsresult rv = GetParameter(nullptr, aResult);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsContentUtils::ASCIIToLower(aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
||||
bool
|
||||
nsContentUtils::CanAccessNativeAnon()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user