зеркало из https://github.com/mozilla/gecko-dev.git
Bug 716570 - Rename blob URI scheme from "moz-filedata" to "blob" per spec. r=sicking
--HG-- rename : content/base/src/nsFileDataProtocolHandler.cpp => content/base/src/nsBlobProtocolHandler.cpp rename : content/base/src/nsFileDataProtocolHandler.h => content/base/src/nsBlobProtocolHandler.h
This commit is contained in:
Родитель
00ef7f2537
Коммит
b71556db7e
|
@ -68,7 +68,7 @@ interface nsIDOMBlob : nsISupports
|
|||
|
||||
[noscript] readonly attribute nsIInputStream internalStream;
|
||||
// The caller is responsible for releasing the internalUrl from the
|
||||
// moz-filedata: protocol handler
|
||||
// blob: protocol handler
|
||||
[noscript] DOMString getInternalUrl(in nsIPrincipal principal);
|
||||
|
||||
[optional_argc] nsIDOMBlob mozSlice([optional] in long long start,
|
||||
|
|
|
@ -1495,7 +1495,7 @@ public:
|
|||
* Register/Unregister a filedata uri as being "owned" by this document.
|
||||
* I.e. that its lifetime is connected with this document. When the document
|
||||
* goes away it should "kill" the uri by calling
|
||||
* nsFileDataProtocolHandler::RemoveFileDataEntry
|
||||
* nsBlobProtocolHandler::RemoveFileDataEntry
|
||||
*/
|
||||
virtual void RegisterFileDataUri(const nsACString& aUri) = 0;
|
||||
virtual void UnregisterFileDataUri(const nsACString& aUri) = 0;
|
||||
|
|
|
@ -151,7 +151,7 @@ CPPSRCS = \
|
|||
nsXMLHttpRequest.cpp \
|
||||
nsXMLNameSpaceMap.cpp \
|
||||
Link.cpp \
|
||||
nsFileDataProtocolHandler.cpp \
|
||||
nsBlobProtocolHandler.cpp \
|
||||
nsFrameMessageManager.cpp \
|
||||
nsInProcessTabChildGlobal.cpp \
|
||||
ThirdPartyUtil.cpp \
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
#include "nsSimpleURI.h"
|
||||
#include "nsDOMError.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -60,7 +60,7 @@ struct FileDataInfo
|
|||
static nsClassHashtable<nsCStringHashKey, FileDataInfo>* gFileDataTable;
|
||||
|
||||
void
|
||||
nsFileDataProtocolHandler::AddFileDataEntry(nsACString& aUri,
|
||||
nsBlobProtocolHandler::AddFileDataEntry(nsACString& aUri,
|
||||
nsIDOMBlob* aFile,
|
||||
nsIPrincipal* aPrincipal)
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ nsFileDataProtocolHandler::AddFileDataEntry(nsACString& aUri,
|
|||
}
|
||||
|
||||
void
|
||||
nsFileDataProtocolHandler::RemoveFileDataEntry(nsACString& aUri)
|
||||
nsBlobProtocolHandler::RemoveFileDataEntry(nsACString& aUri)
|
||||
{
|
||||
if (gFileDataTable) {
|
||||
gFileDataTable->Remove(aUri);
|
||||
|
@ -90,7 +90,7 @@ nsFileDataProtocolHandler::RemoveFileDataEntry(nsACString& aUri)
|
|||
}
|
||||
|
||||
nsIPrincipal*
|
||||
nsFileDataProtocolHandler::GetFileDataEntryPrincipal(nsACString& aUri)
|
||||
nsBlobProtocolHandler::GetFileDataEntryPrincipal(nsACString& aUri)
|
||||
{
|
||||
if (!gFileDataTable) {
|
||||
return nsnull;
|
||||
|
@ -109,7 +109,7 @@ static FileDataInfo*
|
|||
GetFileDataInfo(const nsACString& aUri)
|
||||
{
|
||||
NS_ASSERTION(StringBeginsWith(aUri,
|
||||
NS_LITERAL_CSTRING(FILEDATA_SCHEME ":")),
|
||||
NS_LITERAL_CSTRING(BLOBURI_SCHEME ":")),
|
||||
"Bad URI");
|
||||
|
||||
if (!gFileDataTable) {
|
||||
|
@ -124,23 +124,23 @@ GetFileDataInfo(const nsACString& aUri)
|
|||
// -----------------------------------------------------------------------
|
||||
// Uri
|
||||
|
||||
#define NS_FILEDATAURI_CID \
|
||||
#define NS_BLOBURI_CID \
|
||||
{ 0xf5475c51, 0x59a7, 0x4757, \
|
||||
{ 0xb3, 0xd9, 0xe2, 0x11, 0xa9, 0x41, 0x08, 0x72 } }
|
||||
|
||||
static NS_DEFINE_CID(kFILEDATAURICID, NS_FILEDATAURI_CID);
|
||||
static NS_DEFINE_CID(kBLOBURICID, NS_BLOBURI_CID);
|
||||
|
||||
class nsFileDataURI : public nsSimpleURI,
|
||||
class nsBlobURI : public nsSimpleURI,
|
||||
public nsIURIWithPrincipal
|
||||
{
|
||||
public:
|
||||
nsFileDataURI(nsIPrincipal* aPrincipal) :
|
||||
nsBlobURI(nsIPrincipal* aPrincipal) :
|
||||
nsSimpleURI(), mPrincipal(aPrincipal)
|
||||
{}
|
||||
virtual ~nsFileDataURI() {}
|
||||
virtual ~nsBlobURI() {}
|
||||
|
||||
// For use only from deserialization
|
||||
nsFileDataURI() : nsSimpleURI() {}
|
||||
nsBlobURI() : nsSimpleURI() {}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIURIWITHPRINCIPAL
|
||||
|
@ -154,9 +154,9 @@ public:
|
|||
RefHandlingEnum aRefHandlingMode,
|
||||
bool* aResult);
|
||||
|
||||
// Override StartClone to hand back a nsFileDataURI
|
||||
// Override StartClone to hand back a nsBlobURI
|
||||
virtual nsSimpleURI* StartClone(RefHandlingEnum /* unused */)
|
||||
{ return new nsFileDataURI(); }
|
||||
{ return new nsBlobURI(); }
|
||||
|
||||
nsCOMPtr<nsIPrincipal> mPrincipal;
|
||||
};
|
||||
|
@ -164,12 +164,12 @@ public:
|
|||
static NS_DEFINE_CID(kThisSimpleURIImplementationCID,
|
||||
NS_THIS_SIMPLEURI_IMPLEMENTATION_CID);
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(nsFileDataURI, nsSimpleURI)
|
||||
NS_IMPL_RELEASE_INHERITED(nsFileDataURI, nsSimpleURI)
|
||||
NS_IMPL_ADDREF_INHERITED(nsBlobURI, nsSimpleURI)
|
||||
NS_IMPL_RELEASE_INHERITED(nsBlobURI, nsSimpleURI)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsFileDataURI)
|
||||
NS_INTERFACE_MAP_BEGIN(nsBlobURI)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURIWithPrincipal)
|
||||
if (aIID.Equals(kFILEDATAURICID))
|
||||
if (aIID.Equals(kBLOBURICID))
|
||||
foundInterface = static_cast<nsIURI*>(this);
|
||||
else if (aIID.Equals(kThisSimpleURIImplementationCID)) {
|
||||
// Need to return explicitly here, because if we just set foundInterface
|
||||
|
@ -184,7 +184,7 @@ NS_INTERFACE_MAP_END_INHERITING(nsSimpleURI)
|
|||
// nsIURIWithPrincipal methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetPrincipal(nsIPrincipal** aPrincipal)
|
||||
nsBlobURI::GetPrincipal(nsIPrincipal** aPrincipal)
|
||||
{
|
||||
NS_IF_ADDREF(*aPrincipal = mPrincipal);
|
||||
|
||||
|
@ -192,7 +192,7 @@ nsFileDataURI::GetPrincipal(nsIPrincipal** aPrincipal)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetPrincipalUri(nsIURI** aUri)
|
||||
nsBlobURI::GetPrincipalUri(nsIURI** aUri)
|
||||
{
|
||||
if (mPrincipal) {
|
||||
mPrincipal->GetURI(aUri);
|
||||
|
@ -207,7 +207,7 @@ nsFileDataURI::GetPrincipalUri(nsIURI** aUri)
|
|||
// nsISerializable methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::Read(nsIObjectInputStream* aStream)
|
||||
nsBlobURI::Read(nsIObjectInputStream* aStream)
|
||||
{
|
||||
nsresult rv = nsSimpleURI::Read(aStream);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -216,7 +216,7 @@ nsFileDataURI::Read(nsIObjectInputStream* aStream)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::Write(nsIObjectOutputStream* aStream)
|
||||
nsBlobURI::Write(nsIObjectOutputStream* aStream)
|
||||
{
|
||||
nsresult rv = nsSimpleURI::Write(aStream);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -228,7 +228,7 @@ nsFileDataURI::Write(nsIObjectOutputStream* aStream)
|
|||
|
||||
// nsIURI methods:
|
||||
nsresult
|
||||
nsFileDataURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
|
||||
nsBlobURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
|
||||
nsIURI** aClone)
|
||||
{
|
||||
nsCOMPtr<nsIURI> simpleClone;
|
||||
|
@ -237,22 +237,22 @@ nsFileDataURI::CloneInternal(nsSimpleURI::RefHandlingEnum aRefHandlingMode,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#ifdef DEBUG
|
||||
nsRefPtr<nsFileDataURI> uriCheck;
|
||||
rv = simpleClone->QueryInterface(kFILEDATAURICID, getter_AddRefs(uriCheck));
|
||||
nsRefPtr<nsBlobURI> uriCheck;
|
||||
rv = simpleClone->QueryInterface(kBLOBURICID, getter_AddRefs(uriCheck));
|
||||
NS_ABORT_IF_FALSE(NS_SUCCEEDED(rv) && uriCheck,
|
||||
"Unexpected!");
|
||||
#endif
|
||||
|
||||
nsFileDataURI* fileDataURI = static_cast<nsFileDataURI*>(simpleClone.get());
|
||||
nsBlobURI* blobURI = static_cast<nsBlobURI*>(simpleClone.get());
|
||||
|
||||
fileDataURI->mPrincipal = mPrincipal;
|
||||
blobURI->mPrincipal = mPrincipal;
|
||||
|
||||
simpleClone.forget(aClone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* virtual */ nsresult
|
||||
nsFileDataURI::EqualsInternal(nsIURI* aOther,
|
||||
nsBlobURI::EqualsInternal(nsIURI* aOther,
|
||||
nsSimpleURI::RefHandlingEnum aRefHandlingMode,
|
||||
bool* aResult)
|
||||
{
|
||||
|
@ -261,32 +261,32 @@ nsFileDataURI::EqualsInternal(nsIURI* aOther,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsRefPtr<nsFileDataURI> otherFileDataUri;
|
||||
aOther->QueryInterface(kFILEDATAURICID, getter_AddRefs(otherFileDataUri));
|
||||
if (!otherFileDataUri) {
|
||||
nsRefPtr<nsBlobURI> otherBlobUri;
|
||||
aOther->QueryInterface(kBLOBURICID, getter_AddRefs(otherBlobUri));
|
||||
if (!otherBlobUri) {
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Compare the member data that our base class knows about.
|
||||
if (!nsSimpleURI::EqualsInternal(otherFileDataUri, aRefHandlingMode)) {
|
||||
if (!nsSimpleURI::EqualsInternal(otherBlobUri, aRefHandlingMode)) {
|
||||
*aResult = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Compare the piece of additional member data that we add to base class.
|
||||
if (mPrincipal && otherFileDataUri->mPrincipal) {
|
||||
if (mPrincipal && otherBlobUri->mPrincipal) {
|
||||
// Both of us have mPrincipals. Compare them.
|
||||
return mPrincipal->Equals(otherFileDataUri->mPrincipal, aResult);
|
||||
return mPrincipal->Equals(otherBlobUri->mPrincipal, aResult);
|
||||
}
|
||||
// else, at least one of us lacks a principal; only equal if *both* lack it.
|
||||
*aResult = (!mPrincipal && !otherFileDataUri->mPrincipal);
|
||||
*aResult = (!mPrincipal && !otherBlobUri->mPrincipal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIClassInfo methods:
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
nsBlobURI::GetInterfaces(PRUint32 *count, nsIID * **array)
|
||||
{
|
||||
*count = 0;
|
||||
*array = nsnull;
|
||||
|
@ -294,14 +294,14 @@ nsFileDataURI::GetInterfaces(PRUint32 *count, nsIID * **array)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
|
||||
nsBlobURI::GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
|
||||
{
|
||||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetContractID(char * *aContractID)
|
||||
nsBlobURI::GetContractID(char * *aContractID)
|
||||
{
|
||||
// Make sure to modify any subclasses as needed if this ever
|
||||
// changes.
|
||||
|
@ -310,14 +310,14 @@ nsFileDataURI::GetContractID(char * *aContractID)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetClassDescription(char * *aClassDescription)
|
||||
nsBlobURI::GetClassDescription(char * *aClassDescription)
|
||||
{
|
||||
*aClassDescription = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetClassID(nsCID * *aClassID)
|
||||
nsBlobURI::GetClassID(nsCID * *aClassID)
|
||||
{
|
||||
// Make sure to modify any subclasses as needed if this ever
|
||||
// changes to not call the virtual GetClassIDNoAlloc.
|
||||
|
@ -328,47 +328,47 @@ nsFileDataURI::GetClassID(nsCID * *aClassID)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
|
||||
nsBlobURI::GetImplementationLanguage(PRUint32 *aImplementationLanguage)
|
||||
{
|
||||
*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetFlags(PRUint32 *aFlags)
|
||||
nsBlobURI::GetFlags(PRUint32 *aFlags)
|
||||
{
|
||||
*aFlags = nsIClassInfo::MAIN_THREAD_ONLY;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
|
||||
nsBlobURI::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
|
||||
{
|
||||
*aClassIDNoAlloc = kFILEDATAURICID;
|
||||
*aClassIDNoAlloc = kBLOBURICID;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Protocol handler
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFileDataProtocolHandler, nsIProtocolHandler)
|
||||
NS_IMPL_ISUPPORTS1(nsBlobProtocolHandler, nsIProtocolHandler)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::GetScheme(nsACString &result)
|
||||
nsBlobProtocolHandler::GetScheme(nsACString &result)
|
||||
{
|
||||
result.AssignLiteral(FILEDATA_SCHEME);
|
||||
result.AssignLiteral(BLOBURI_SCHEME);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
nsBlobProtocolHandler::GetDefaultPort(PRInt32 *result)
|
||||
{
|
||||
*result = -1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::GetProtocolFlags(PRUint32 *result)
|
||||
nsBlobProtocolHandler::GetProtocolFlags(PRUint32 *result)
|
||||
{
|
||||
*result = URI_NORELATIVE | URI_NOAUTH | URI_LOADABLE_BY_SUBSUMERS |
|
||||
URI_IS_LOCAL_RESOURCE | URI_NON_PERSISTABLE;
|
||||
|
@ -376,7 +376,7 @@ nsFileDataProtocolHandler::GetProtocolFlags(PRUint32 *result)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::NewURI(const nsACString& aSpec,
|
||||
nsBlobProtocolHandler::NewURI(const nsACString& aSpec,
|
||||
const char *aCharset,
|
||||
nsIURI *aBaseURI,
|
||||
nsIURI **aResult)
|
||||
|
@ -387,8 +387,8 @@ nsFileDataProtocolHandler::NewURI(const nsACString& aSpec,
|
|||
FileDataInfo* info =
|
||||
GetFileDataInfo(aSpec);
|
||||
|
||||
nsRefPtr<nsFileDataURI> uri =
|
||||
new nsFileDataURI(info ? info->mPrincipal.get() : nsnull);
|
||||
nsRefPtr<nsBlobURI> uri =
|
||||
new nsBlobURI(info ? info->mPrincipal.get() : nsnull);
|
||||
|
||||
rv = uri->SetSpec(aSpec);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -400,7 +400,7 @@ nsFileDataProtocolHandler::NewURI(const nsACString& aSpec,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
nsBlobProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
||||
{
|
||||
*result = nsnull;
|
||||
|
||||
|
@ -448,7 +448,7 @@ nsFileDataProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileDataProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
|
||||
nsBlobProtocolHandler::AllowPort(PRInt32 port, const char *scheme,
|
||||
bool *_retval)
|
||||
{
|
||||
// don't override anything.
|
|
@ -34,17 +34,17 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsFileDataProtocolHandler_h___
|
||||
#define nsFileDataProtocolHandler_h___
|
||||
#ifndef nsBlobProtocolHandler_h
|
||||
#define nsBlobProtocolHandler_h
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
|
||||
#define FILEDATA_SCHEME "moz-filedata"
|
||||
#define BLOBURI_SCHEME "blob"
|
||||
|
||||
class nsIDOMBlob;
|
||||
class nsIPrincipal;
|
||||
|
||||
class nsFileDataProtocolHandler : public nsIProtocolHandler
|
||||
class nsBlobProtocolHandler : public nsIProtocolHandler
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -52,9 +52,9 @@ public:
|
|||
// nsIProtocolHandler methods:
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
|
||||
// nsFileDataProtocolHandler methods:
|
||||
nsFileDataProtocolHandler() {}
|
||||
virtual ~nsFileDataProtocolHandler() {}
|
||||
// nsBlobProtocolHandler methods:
|
||||
nsBlobProtocolHandler() {}
|
||||
virtual ~nsBlobProtocolHandler() {}
|
||||
|
||||
// Methods for managing uri->file mapping
|
||||
static void AddFileDataEntry(nsACString& aUri,
|
||||
|
@ -65,8 +65,8 @@ public:
|
|||
|
||||
};
|
||||
|
||||
#define NS_FILEDATAPROTOCOLHANDLER_CID \
|
||||
#define NS_BLOBPROTOCOLHANDLER_CID \
|
||||
{ 0xb43964aa, 0xa078, 0x44b2, \
|
||||
{ 0xb0, 0x6b, 0xfd, 0x4d, 0x1b, 0x17, 0x2e, 0x66 } }
|
||||
|
||||
#endif /* nsFileDataProtocolHandler_h___ */
|
||||
#endif /* nsBlobProtocolHandler_h */
|
|
@ -60,7 +60,7 @@
|
|||
#include "nsNetCID.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIUUIDGenerator.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "CheckedInt.h"
|
||||
#include "nsJSUtils.h"
|
||||
|
@ -288,10 +288,10 @@ nsDOMFileBase::GetInternalUrl(nsIPrincipal* aPrincipal, nsAString& aURL)
|
|||
char chars[NSID_LENGTH];
|
||||
id.ToProvidedString(chars);
|
||||
|
||||
nsCString url = NS_LITERAL_CSTRING(FILEDATA_SCHEME ":") +
|
||||
nsCString url = NS_LITERAL_CSTRING(BLOBURI_SCHEME ":") +
|
||||
Substring(chars + 1, chars + NSID_LENGTH - 2);
|
||||
|
||||
nsFileDataProtocolHandler::AddFileDataEntry(url, this,
|
||||
nsBlobProtocolHandler::AddFileDataEntry(url, this,
|
||||
aPrincipal);
|
||||
|
||||
CopyASCIItoUTF16(url, aURL);
|
||||
|
@ -668,6 +668,6 @@ nsDOMFileInternalUrlHolder::~nsDOMFileInternalUrlHolder() {
|
|||
if (!mUrl.IsEmpty()) {
|
||||
nsCAutoString narrowUrl;
|
||||
CopyUTF16toUTF8(mUrl, narrowUrl);
|
||||
nsFileDataProtocolHandler::RemoveFileDataEntry(narrowUrl);
|
||||
nsBlobProtocolHandler::RemoveFileDataEntry(narrowUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsLayoutStatics.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "xpcpublic.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
|
|
@ -102,7 +102,7 @@ nsDataDocumentContentPolicy::ShouldLoad(PRUint32 aContentType,
|
|||
// also satisfy one of the following conditions:
|
||||
// - URI inherits security context, e.g. data URIs
|
||||
// OR
|
||||
// - URI loadable by subsumers, e.g. moz-filedata URIs
|
||||
// - URI loadable by subsumers, e.g. blob URIs
|
||||
// Any URI that doesn't meet these requirements will be rejected below.
|
||||
if (!HasFlags(aContentLocation,
|
||||
nsIProtocolHandler::URI_IS_LOCAL_RESOURCE) ||
|
||||
|
|
|
@ -144,7 +144,7 @@
|
|||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsILink.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsIParser.h"
|
||||
|
@ -1669,7 +1669,7 @@ nsDocument::~nsDocument()
|
|||
mPendingTitleChangeEvent.Revoke();
|
||||
|
||||
for (PRUint32 i = 0; i < mFileDataUris.Length(); ++i) {
|
||||
nsFileDataProtocolHandler::RemoveFileDataEntry(mFileDataUris[i]);
|
||||
nsBlobProtocolHandler::RemoveFileDataEntry(mFileDataUris[i]);
|
||||
}
|
||||
|
||||
// We don't want to leave residual locks on images. Make sure we're in an
|
||||
|
|
|
@ -180,7 +180,7 @@
|
|||
#include "nsAutoPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSSProps.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsIDOMFileList.h"
|
||||
#include "nsIURIFixup.h"
|
||||
|
@ -689,7 +689,7 @@ nsDOMMozURLProperty::RevokeObjectURL(const nsAString& aURL)
|
|||
}
|
||||
|
||||
nsIPrincipal* principal =
|
||||
nsFileDataProtocolHandler::GetFileDataEntryPrincipal(asciiurl);
|
||||
nsBlobProtocolHandler::GetFileDataEntryPrincipal(asciiurl);
|
||||
bool subsumes;
|
||||
if (principal && winPrincipal &&
|
||||
NS_SUCCEEDED(winPrincipal->Subsumes(principal, &subsumes)) &&
|
||||
|
@ -697,7 +697,7 @@ nsDOMMozURLProperty::RevokeObjectURL(const nsAString& aURL)
|
|||
if (mWindow->mDoc) {
|
||||
mWindow->mDoc->UnregisterFileDataUri(asciiurl);
|
||||
}
|
||||
nsFileDataProtocolHandler::RemoveFileDataEntry(asciiurl);
|
||||
nsBlobProtocolHandler::RemoveFileDataEntry(asciiurl);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
|
|
@ -114,7 +114,7 @@
|
|||
#include "nsDOMException.h"
|
||||
#include "nsDOMFileReader.h"
|
||||
#include "nsFormData.h"
|
||||
#include "nsFileDataProtocolHandler.h"
|
||||
#include "nsBlobProtocolHandler.h"
|
||||
#include "nsGlobalWindowCommands.h"
|
||||
#include "nsIControllerCommandTable.h"
|
||||
#include "nsJSProtocolHandler.h"
|
||||
|
@ -274,7 +274,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsEventSource)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebSocket)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDOMFileReader, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormData)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFileDataProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlobProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMParser)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsDOMStorageManager,
|
||||
nsDOMStorageManager::GetInstance)
|
||||
|
@ -738,7 +738,7 @@ NS_DEFINE_NAMED_CID(TRANSFORMIIX_NODESET_CID);
|
|||
NS_DEFINE_NAMED_CID(NS_XMLSERIALIZER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_FILEREADER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_FORMDATA_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_FILEDATAPROTOCOLHANDLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_BLOBPROTOCOLHANDLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_XMLHTTPREQUEST_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_EVENTSOURCE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WEBSOCKET_CID);
|
||||
|
@ -1009,7 +1009,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
|||
{ &kNS_XMLSERIALIZER_CID, false, NULL, nsDOMSerializerConstructor },
|
||||
{ &kNS_FILEREADER_CID, false, NULL, nsDOMFileReaderConstructor },
|
||||
{ &kNS_FORMDATA_CID, false, NULL, nsFormDataConstructor },
|
||||
{ &kNS_FILEDATAPROTOCOLHANDLER_CID, false, NULL, nsFileDataProtocolHandlerConstructor },
|
||||
{ &kNS_BLOBPROTOCOLHANDLER_CID, false, NULL, nsBlobProtocolHandlerConstructor },
|
||||
{ &kNS_XMLHTTPREQUEST_CID, false, NULL, nsXMLHttpRequestConstructor },
|
||||
{ &kNS_EVENTSOURCE_CID, false, NULL, nsEventSourceConstructor },
|
||||
{ &kNS_WEBSOCKET_CID, false, NULL, nsWebSocketConstructor },
|
||||
|
@ -1145,7 +1145,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
|||
{ NS_XMLSERIALIZER_CONTRACTID, &kNS_XMLSERIALIZER_CID },
|
||||
{ NS_FILEREADER_CONTRACTID, &kNS_FILEREADER_CID },
|
||||
{ NS_FORMDATA_CONTRACTID, &kNS_FORMDATA_CID },
|
||||
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX FILEDATA_SCHEME, &kNS_FILEDATAPROTOCOLHANDLER_CID },
|
||||
{ NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX BLOBURI_SCHEME, &kNS_BLOBPROTOCOLHANDLER_CID },
|
||||
{ NS_XMLHTTPREQUEST_CONTRACTID, &kNS_XMLHTTPREQUEST_CID },
|
||||
{ NS_EVENTSOURCE_CONTRACTID, &kNS_EVENTSOURCE_CID },
|
||||
{ NS_WEBSOCKET_CONTRACTID, &kNS_WEBSOCKET_CID },
|
||||
|
|
|
@ -86,7 +86,7 @@ interface nsICapturePicker : nsISupports
|
|||
|
||||
/**
|
||||
* Get the captured image/video/audio. This may be a data URI, file URI,
|
||||
* or a moz-filedata reference URI.
|
||||
* or a blob reference URI.
|
||||
*/
|
||||
readonly attribute nsIDOMFile file;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- This test checks to be sure we can render SVG-as-an-image
|
||||
from a MozBlobBuilder-generated 'moz-filedata' URI. -->
|
||||
from a MozBlobBuilder-generated 'blob' URI. -->
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<script>
|
||||
function go() {
|
||||
// Generate a moz-filedata URL encoding of an SVG document
|
||||
// Generate a blob URL encoding of an SVG document
|
||||
var filedataURL = generateMozFiledataURL();
|
||||
|
||||
// Tell our img element to render the URL
|
||||
|
@ -18,7 +18,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Helper function -- returns a moz-filedata URL representing a
|
||||
// Helper function -- returns a blob URL representing a
|
||||
// 100x100 fully-lime SVG document.
|
||||
function generateMozFiledataURL() {
|
||||
var blobBuilder = new self.MozBlobBuilder;
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- This test checks to be sure we allow MozBlobBuilder-generated
|
||||
'moz-filedata' URIs *inside of* SVG-as-an-image. -->
|
||||
'blob' URIs *inside of* SVG-as-an-image. -->
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<script>
|
||||
function go() {
|
||||
// Generate a moz-filedata URL encoding of an SVG document
|
||||
// Generate a blob URL encoding of an SVG document
|
||||
var filedataURL = generateMozFiledataURL();
|
||||
|
||||
// Now generate a data URI, containing our moz-filedata URI
|
||||
// Now generate a data URI, containing our blob URI
|
||||
var outerSVG =
|
||||
'<svg xmlns="http://www.w3.org/2000/svg" ' +
|
||||
'xmlns:xlink="http://www.w3.org/1999/xlink" ' +
|
||||
|
@ -27,7 +27,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Helper function -- returns a moz-filedata URL representing a
|
||||
// Helper function -- returns a blob URL representing a
|
||||
// 100x100 fully-lime SVG document.
|
||||
function generateMozFiledataURL() {
|
||||
var blobBuilder = new self.MozBlobBuilder;
|
||||
|
|
|
@ -223,9 +223,9 @@ var gTests = [
|
|||
path: "new%20Date()",
|
||||
ref: "",
|
||||
nsIURL: false, nsINestedURI: false },
|
||||
{ spec: "moz-filedata:123456",
|
||||
scheme: "moz-filedata",
|
||||
prePath: "moz-filedata:",
|
||||
{ spec: "blob:123456",
|
||||
scheme: "blob",
|
||||
prePath: "blob:",
|
||||
path: "123456",
|
||||
ref: "",
|
||||
nsIURL: false, nsINestedURI: false, immutable: true },
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
const Ci = Components.interfaces;
|
||||
const SIMPLEURI_SPEC = "data:text/plain,hello world";
|
||||
const FILEDATA_SPEC = "moz-filedata:123456";
|
||||
const BLOBURI_SPEC = "blob:123456";
|
||||
|
||||
function do_info(text, stack) {
|
||||
if (!stack)
|
||||
|
@ -27,13 +27,13 @@ function do_check_uri_neq(uri1, uri2)
|
|||
function run_test()
|
||||
{
|
||||
var simpleURI = NetUtil.newURI(SIMPLEURI_SPEC);
|
||||
var fileDataURI = NetUtil.newURI(FILEDATA_SPEC);
|
||||
var fileDataURI = NetUtil.newURI(BLOBURI_SPEC);
|
||||
|
||||
do_info("Checking that " + SIMPLEURI_SPEC + " != " + FILEDATA_SPEC);
|
||||
do_info("Checking that " + SIMPLEURI_SPEC + " != " + BLOBURI_SPEC);
|
||||
do_check_uri_neq(simpleURI, fileDataURI);
|
||||
|
||||
do_info("Changing the nsSimpleURI spec to match the nsFileDataURI");
|
||||
simpleURI.spec = FILEDATA_SPEC;
|
||||
simpleURI.spec = BLOBURI_SPEC;
|
||||
|
||||
do_info("Verifying that .spec matches");
|
||||
do_check_eq(simpleURI.spec, fileDataURI.spec);
|
||||
|
|
Загрузка…
Ссылка в новой задаче