mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
8bbeee69cf
--HG-- rename : dom/base/BlobSet.cpp => dom/file/BlobSet.cpp rename : dom/base/BlobSet.h => dom/file/BlobSet.h rename : dom/base/File.cpp => dom/file/File.cpp rename : dom/base/File.h => dom/file/File.h rename : dom/base/FileList.cpp => dom/file/FileList.cpp rename : dom/base/FileList.h => dom/file/FileList.h rename : dom/base/FileReader.cpp => dom/file/FileReader.cpp rename : dom/base/FileReader.h => dom/file/FileReader.h rename : dom/base/MultipartBlobImpl.cpp => dom/file/MultipartBlobImpl.cpp rename : dom/base/MultipartBlobImpl.h => dom/file/MultipartBlobImpl.h rename : dom/base/MutableBlobStorage.cpp => dom/file/MutableBlobStorage.cpp rename : dom/base/MutableBlobStorage.h => dom/file/MutableBlobStorage.h rename : dom/base/MutableBlobStreamListener.cpp => dom/file/MutableBlobStreamListener.cpp rename : dom/base/MutableBlobStreamListener.h => dom/file/MutableBlobStreamListener.h rename : dom/ipc/Blob.cpp => dom/file/ipc/Blob.cpp rename : dom/ipc/BlobChild.h => dom/file/ipc/BlobChild.h rename : dom/ipc/BlobParent.h => dom/file/ipc/BlobParent.h rename : dom/ipc/BlobTypes.ipdlh => dom/file/ipc/BlobTypes.ipdlh rename : dom/ipc/PBlob.ipdl => dom/file/ipc/PBlob.ipdl rename : dom/ipc/PBlobStream.ipdl => dom/file/ipc/PBlobStream.ipdl rename : dom/ipc/nsIRemoteBlob.h => dom/file/ipc/nsIRemoteBlob.h rename : dom/base/nsHostObjectProtocolHandler.cpp => dom/file/nsHostObjectProtocolHandler.cpp rename : dom/base/nsHostObjectProtocolHandler.h => dom/file/nsHostObjectProtocolHandler.h rename : dom/base/nsHostObjectURI.cpp => dom/file/nsHostObjectURI.cpp rename : dom/base/nsHostObjectURI.h => dom/file/nsHostObjectURI.h rename : dom/base/nsIDOMBlob.idl => dom/file/nsIDOMBlob.idl rename : dom/base/nsIDOMFileList.idl => dom/file/nsIDOMFileList.idl rename : dom/base/test/create_file_objects.js => dom/file/tests/create_file_objects.js rename : dom/base/test/file_blobURL_expiring.html => dom/file/tests/file_blobURL_expiring.html rename : dom/base/test/file_mozfiledataurl_audio.ogg => dom/file/tests/file_mozfiledataurl_audio.ogg rename : dom/base/test/file_mozfiledataurl_doc.html => dom/file/tests/file_mozfiledataurl_doc.html rename : dom/base/test/file_mozfiledataurl_img.jpg => dom/file/tests/file_mozfiledataurl_img.jpg rename : dom/base/test/file_mozfiledataurl_inner.html => dom/file/tests/file_mozfiledataurl_inner.html rename : dom/base/test/file_mozfiledataurl_text.txt => dom/file/tests/file_mozfiledataurl_text.txt rename : dom/base/test/file_nonascii_blob_url.html => dom/file/tests/file_nonascii_blob_url.html rename : dom/base/test/fileapi_chromeScript.js => dom/file/tests/fileapi_chromeScript.js rename : dom/base/test/fileutils.js => dom/file/tests/fileutils.js rename : dom/base/test/test_blobURL_expiring.html => dom/file/tests/test_blobURL_expiring.html rename : dom/base/test/test_blob_fragment_and_query.html => dom/file/tests/test_blob_fragment_and_query.html rename : dom/base/test/test_blobconstructor.html => dom/file/tests/test_blobconstructor.html rename : dom/base/test/test_file_from_blob.html => dom/file/tests/test_file_from_blob.html rename : dom/base/test/test_file_negative_date.html => dom/file/tests/test_file_negative_date.html rename : dom/base/test/test_fileapi.html => dom/file/tests/test_fileapi.html rename : dom/base/test/test_fileapi_slice.html => dom/file/tests/test_fileapi_slice.html rename : dom/base/test/test_ipc_messagemanager_blob.html => dom/file/tests/test_ipc_messagemanager_blob.html rename : dom/base/test/test_mozfiledataurl.html => dom/file/tests/test_mozfiledataurl.html rename : dom/base/test/test_nonascii_blob_url.html => dom/file/tests/test_nonascii_blob_url.html
145 lines
4.8 KiB
C++
145 lines
4.8 KiB
C++
/* -*- 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/. */
|
|
|
|
#ifndef nsHostObjectProtocolHandler_h
|
|
#define nsHostObjectProtocolHandler_h
|
|
|
|
#include "mozilla/Attributes.h"
|
|
#include "nsIProtocolHandler.h"
|
|
#include "nsIURI.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsIInputStream.h"
|
|
#include "nsTArray.h"
|
|
|
|
#define BLOBURI_SCHEME "blob"
|
|
#define FONTTABLEURI_SCHEME "moz-fonttable"
|
|
#define RTSPURI_SCHEME "rtsp"
|
|
|
|
class nsIPrincipal;
|
|
|
|
namespace mozilla {
|
|
class BlobURLsReporter;
|
|
class DOMMediaStream;
|
|
namespace dom {
|
|
class BlobImpl;
|
|
class BlobURLRegistrationData;
|
|
class ContentParent;
|
|
class MediaSource;
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
class nsHostObjectProtocolHandler : public nsIProtocolHandler
|
|
{
|
|
public:
|
|
nsHostObjectProtocolHandler();
|
|
NS_DECL_ISUPPORTS
|
|
|
|
// nsIProtocolHandler methods, except for GetScheme which is only defined
|
|
// in subclasses.
|
|
NS_IMETHOD GetDefaultPort(int32_t *aDefaultPort) override;
|
|
NS_IMETHOD GetProtocolFlags(uint32_t *aProtocolFlags) override;
|
|
NS_IMETHOD NewURI(const nsACString & aSpec, const char * aOriginCharset, nsIURI *aBaseURI, nsIURI * *_retval) override;
|
|
NS_IMETHOD NewChannel2(nsIURI *aURI, nsILoadInfo *aLoadinfo, nsIChannel * *_retval) override;
|
|
NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel * *_retval) override;
|
|
NS_IMETHOD AllowPort(int32_t port, const char * scheme, bool *_retval) override;
|
|
|
|
// If principal is not null, its origin will be used to generate the URI.
|
|
static nsresult GenerateURIString(const nsACString &aScheme,
|
|
nsIPrincipal* aPrincipal,
|
|
nsACString &aUri);
|
|
static nsresult GenerateURIStringForBlobURL(nsIPrincipal* aPrincipal,
|
|
nsACString &aUri);
|
|
|
|
// Methods for managing uri->object mapping
|
|
// AddDataEntry creates the URI with the given scheme and returns it in aUri
|
|
static nsresult AddDataEntry(mozilla::dom::BlobImpl* aBlobImpl,
|
|
nsIPrincipal* aPrincipal,
|
|
nsACString& aUri);
|
|
static nsresult AddDataEntry(mozilla::DOMMediaStream* aMediaStream,
|
|
nsIPrincipal* aPrincipal,
|
|
nsACString& aUri);
|
|
static nsresult AddDataEntry(mozilla::dom::MediaSource* aMediaSource,
|
|
nsIPrincipal* aPrincipal,
|
|
nsACString& aUri);
|
|
// IPC only
|
|
static nsresult AddDataEntry(const nsACString& aURI,
|
|
nsIPrincipal* aPrincipal,
|
|
mozilla::dom::BlobImpl* aBlobImpl);
|
|
|
|
static void RemoveDataEntry(const nsACString& aUri,
|
|
bool aBroadcastToOTherProcesses = true);
|
|
|
|
// This is for IPC only.
|
|
static void RemoveDataEntries();
|
|
|
|
static bool HasDataEntry(const nsACString& aUri);
|
|
|
|
static nsIPrincipal* GetDataEntryPrincipal(const nsACString& aUri);
|
|
static void Traverse(const nsACString& aUri, nsCycleCollectionTraversalCallback& aCallback);
|
|
|
|
static bool
|
|
GetAllBlobURLEntries(nsTArray<mozilla::dom::BlobURLRegistrationData>& aRegistrations,
|
|
mozilla::dom::ContentParent* aCP);
|
|
|
|
protected:
|
|
virtual ~nsHostObjectProtocolHandler() {}
|
|
|
|
private:
|
|
static void Init();
|
|
};
|
|
|
|
class nsBlobProtocolHandler : public nsHostObjectProtocolHandler
|
|
{
|
|
public:
|
|
NS_IMETHOD GetScheme(nsACString &result) override;
|
|
};
|
|
|
|
class nsMediaSourceProtocolHandler : public nsHostObjectProtocolHandler
|
|
{
|
|
public:
|
|
NS_IMETHOD GetScheme(nsACString &result) override;
|
|
};
|
|
|
|
class nsFontTableProtocolHandler : public nsHostObjectProtocolHandler
|
|
{
|
|
public:
|
|
NS_IMETHOD GetScheme(nsACString &result);
|
|
NS_IMETHOD NewURI(const nsACString & aSpec, const char * aOriginCharset, nsIURI *aBaseURI, nsIURI * *_retval);
|
|
};
|
|
|
|
bool IsBlobURI(nsIURI* aUri);
|
|
bool IsMediaStreamURI(nsIURI* aUri);
|
|
bool IsMediaSourceURI(nsIURI* aUri);
|
|
|
|
inline bool IsRtspURI(nsIURI* aUri)
|
|
{
|
|
bool isRtsp;
|
|
return NS_SUCCEEDED(aUri->SchemeIs(RTSPURI_SCHEME, &isRtsp)) && isRtsp;
|
|
}
|
|
|
|
inline bool IsFontTableURI(nsIURI* aUri)
|
|
{
|
|
bool isFont;
|
|
return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont;
|
|
}
|
|
|
|
extern nsresult
|
|
NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob);
|
|
|
|
extern nsresult
|
|
NS_GetBlobForBlobURISpec(const nsACString& aSpec, mozilla::dom::BlobImpl** aBlob);
|
|
|
|
extern nsresult
|
|
NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream);
|
|
|
|
extern nsresult
|
|
NS_GetStreamForMediaStreamURI(nsIURI* aURI, mozilla::DOMMediaStream** aStream);
|
|
|
|
extern nsresult
|
|
NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource);
|
|
|
|
#endif /* nsHostObjectProtocolHandler_h */
|