Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef nsHostObjectProtocolHandler_h |
michael@0 | 6 | #define nsHostObjectProtocolHandler_h |
michael@0 | 7 | |
michael@0 | 8 | #include "mozilla/Attributes.h" |
michael@0 | 9 | #include "nsIProtocolHandler.h" |
michael@0 | 10 | #include "nsIURI.h" |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | #include "nsIInputStream.h" |
michael@0 | 13 | |
michael@0 | 14 | #define BLOBURI_SCHEME "blob" |
michael@0 | 15 | #define MEDIASTREAMURI_SCHEME "mediastream" |
michael@0 | 16 | #define MEDIASOURCEURI_SCHEME "mediasource" |
michael@0 | 17 | #define FONTTABLEURI_SCHEME "moz-fonttable" |
michael@0 | 18 | #define RTSPURI_SCHEME "rtsp" |
michael@0 | 19 | |
michael@0 | 20 | class nsIDOMBlob; |
michael@0 | 21 | class nsIDOMMediaStream; |
michael@0 | 22 | class nsIPrincipal; |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace dom { |
michael@0 | 26 | class MediaSource; |
michael@0 | 27 | } |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | class nsHostObjectProtocolHandler : public nsIProtocolHandler |
michael@0 | 31 | { |
michael@0 | 32 | public: |
michael@0 | 33 | nsHostObjectProtocolHandler(); |
michael@0 | 34 | virtual ~nsHostObjectProtocolHandler() {} |
michael@0 | 35 | NS_DECL_ISUPPORTS |
michael@0 | 36 | |
michael@0 | 37 | // nsIProtocolHandler methods, except for GetScheme which is only defined |
michael@0 | 38 | // in subclasses. |
michael@0 | 39 | NS_IMETHOD GetDefaultPort(int32_t *aDefaultPort) MOZ_OVERRIDE; |
michael@0 | 40 | NS_IMETHOD GetProtocolFlags(uint32_t *aProtocolFlags) MOZ_OVERRIDE; |
michael@0 | 41 | NS_IMETHOD NewURI(const nsACString & aSpec, const char * aOriginCharset, nsIURI *aBaseURI, nsIURI * *_retval) MOZ_OVERRIDE; |
michael@0 | 42 | NS_IMETHOD NewChannel(nsIURI *aURI, nsIChannel * *_retval) MOZ_OVERRIDE; |
michael@0 | 43 | NS_IMETHOD AllowPort(int32_t port, const char * scheme, bool *_retval) MOZ_OVERRIDE; |
michael@0 | 44 | |
michael@0 | 45 | static nsresult GenerateURIString(const nsACString &aScheme, |
michael@0 | 46 | nsACString &aUri); |
michael@0 | 47 | |
michael@0 | 48 | // Methods for managing uri->object mapping |
michael@0 | 49 | // AddDataEntry creates the URI with the given scheme and returns it in aUri |
michael@0 | 50 | static nsresult AddDataEntry(const nsACString& aScheme, |
michael@0 | 51 | nsISupports* aObject, |
michael@0 | 52 | nsIPrincipal* aPrincipal, |
michael@0 | 53 | nsACString& aUri); |
michael@0 | 54 | static void RemoveDataEntry(const nsACString& aUri); |
michael@0 | 55 | static nsIPrincipal* GetDataEntryPrincipal(const nsACString& aUri); |
michael@0 | 56 | static void Traverse(const nsACString& aUri, nsCycleCollectionTraversalCallback& aCallback); |
michael@0 | 57 | |
michael@0 | 58 | private: |
michael@0 | 59 | static void Init(void); |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | class nsBlobProtocolHandler : public nsHostObjectProtocolHandler |
michael@0 | 63 | { |
michael@0 | 64 | public: |
michael@0 | 65 | NS_IMETHOD GetScheme(nsACString &result) MOZ_OVERRIDE; |
michael@0 | 66 | }; |
michael@0 | 67 | |
michael@0 | 68 | class nsMediaStreamProtocolHandler : public nsHostObjectProtocolHandler |
michael@0 | 69 | { |
michael@0 | 70 | public: |
michael@0 | 71 | NS_IMETHOD GetScheme(nsACString &result) MOZ_OVERRIDE; |
michael@0 | 72 | }; |
michael@0 | 73 | |
michael@0 | 74 | class nsMediaSourceProtocolHandler : public nsHostObjectProtocolHandler |
michael@0 | 75 | { |
michael@0 | 76 | public: |
michael@0 | 77 | NS_IMETHOD GetScheme(nsACString &result) MOZ_OVERRIDE; |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | class nsFontTableProtocolHandler : public nsHostObjectProtocolHandler |
michael@0 | 81 | { |
michael@0 | 82 | public: |
michael@0 | 83 | NS_IMETHOD GetScheme(nsACString &result); |
michael@0 | 84 | NS_IMETHOD NewURI(const nsACString & aSpec, const char * aOriginCharset, nsIURI *aBaseURI, nsIURI * *_retval); |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | inline bool IsBlobURI(nsIURI* aUri) |
michael@0 | 88 | { |
michael@0 | 89 | bool isBlob; |
michael@0 | 90 | return NS_SUCCEEDED(aUri->SchemeIs(BLOBURI_SCHEME, &isBlob)) && isBlob; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | inline bool IsRtspURI(nsIURI* aUri) |
michael@0 | 94 | { |
michael@0 | 95 | bool isRtsp; |
michael@0 | 96 | return NS_SUCCEEDED(aUri->SchemeIs(RTSPURI_SCHEME, &isRtsp)) && isRtsp; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | inline bool IsMediaStreamURI(nsIURI* aUri) |
michael@0 | 100 | { |
michael@0 | 101 | bool isStream; |
michael@0 | 102 | return NS_SUCCEEDED(aUri->SchemeIs(MEDIASTREAMURI_SCHEME, &isStream)) && isStream; |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | inline bool IsMediaSourceURI(nsIURI* aUri) |
michael@0 | 106 | { |
michael@0 | 107 | bool isMediaSource; |
michael@0 | 108 | return NS_SUCCEEDED(aUri->SchemeIs(MEDIASOURCEURI_SCHEME, &isMediaSource)) && isMediaSource; |
michael@0 | 109 | } |
michael@0 | 110 | |
michael@0 | 111 | inline bool IsFontTableURI(nsIURI* aUri) |
michael@0 | 112 | { |
michael@0 | 113 | bool isFont; |
michael@0 | 114 | return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont; |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | extern nsresult |
michael@0 | 118 | NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream); |
michael@0 | 119 | |
michael@0 | 120 | extern nsresult |
michael@0 | 121 | NS_GetStreamForMediaStreamURI(nsIURI* aURI, nsIDOMMediaStream** aStream); |
michael@0 | 122 | |
michael@0 | 123 | extern nsresult |
michael@0 | 124 | NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource); |
michael@0 | 125 | |
michael@0 | 126 | #define NS_BLOBPROTOCOLHANDLER_CID \ |
michael@0 | 127 | { 0xb43964aa, 0xa078, 0x44b2, \ |
michael@0 | 128 | { 0xb0, 0x6b, 0xfd, 0x4d, 0x1b, 0x17, 0x2e, 0x66 } } |
michael@0 | 129 | |
michael@0 | 130 | #define NS_MEDIASTREAMPROTOCOLHANDLER_CID \ |
michael@0 | 131 | { 0x27d1fa24, 0x2b73, 0x4db3, \ |
michael@0 | 132 | { 0xab, 0x48, 0xb9, 0x83, 0x83, 0x40, 0xe0, 0x81 } } |
michael@0 | 133 | |
michael@0 | 134 | #define NS_MEDIASOURCEPROTOCOLHANDLER_CID \ |
michael@0 | 135 | { 0x12ef31fc, 0xa8fb, 0x4661, \ |
michael@0 | 136 | { 0x9a, 0x63, 0xfb, 0x61, 0x04,0x5d, 0xb8, 0x61 } } |
michael@0 | 137 | |
michael@0 | 138 | #define NS_FONTTABLEPROTOCOLHANDLER_CID \ |
michael@0 | 139 | { 0x3fc8f04e, 0xd719, 0x43ca, \ |
michael@0 | 140 | { 0x9a, 0xd0, 0x18, 0xee, 0x32, 0x02, 0x11, 0xf2 } } |
michael@0 | 141 | |
michael@0 | 142 | #endif /* nsHostObjectProtocolHandler_h */ |