michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsJSProtocolHandler_h___ michael@0: #define nsJSProtocolHandler_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsIProtocolHandler.h" michael@0: #include "nsITextToSubURI.h" michael@0: #include "nsIURI.h" michael@0: #include "nsIMutable.h" michael@0: #include "nsISerializable.h" michael@0: #include "nsIClassInfo.h" michael@0: #include "nsSimpleURI.h" michael@0: michael@0: #define NS_JSPROTOCOLHANDLER_CID \ michael@0: { /* bfc310d2-38a0-11d3-8cd3-0060b0fc14a3 */ \ michael@0: 0xbfc310d2, \ michael@0: 0x38a0, \ michael@0: 0x11d3, \ michael@0: {0x8c, 0xd3, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ michael@0: } michael@0: michael@0: #define NS_JSURI_CID \ michael@0: { /* 58f089ee-512a-42d2-a935-d0c874128930 */ \ michael@0: 0x58f089ee, \ michael@0: 0x512a, \ michael@0: 0x42d2, \ michael@0: {0xa9, 0x35, 0xd0, 0xc8, 0x74, 0x12, 0x89, 0x30} \ michael@0: } michael@0: michael@0: #define NS_JSPROTOCOLHANDLER_CONTRACTID \ michael@0: NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "javascript" michael@0: michael@0: michael@0: class nsJSProtocolHandler : public nsIProtocolHandler michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIProtocolHandler methods: michael@0: NS_DECL_NSIPROTOCOLHANDLER michael@0: michael@0: // nsJSProtocolHandler methods: michael@0: nsJSProtocolHandler(); michael@0: virtual ~nsJSProtocolHandler(); michael@0: michael@0: static nsresult michael@0: Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); michael@0: michael@0: nsresult Init(); michael@0: michael@0: protected: michael@0: michael@0: nsresult EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset, michael@0: nsACString &aUTF8Spec); michael@0: michael@0: nsCOMPtr mTextToSubURI; michael@0: }; michael@0: michael@0: michael@0: class nsJSURI : public nsSimpleURI michael@0: { michael@0: public: michael@0: using nsSimpleURI::Read; michael@0: using nsSimpleURI::Write; michael@0: michael@0: nsJSURI() {} michael@0: michael@0: nsJSURI(nsIURI* aBaseURI) : mBaseURI(aBaseURI) {} michael@0: michael@0: nsIURI* GetBaseURI() const michael@0: { michael@0: return mBaseURI; michael@0: } michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIURI overrides michael@0: virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode) MOZ_OVERRIDE; michael@0: michael@0: // nsISerializable overrides michael@0: NS_IMETHOD Read(nsIObjectInputStream* aStream) MOZ_OVERRIDE; michael@0: NS_IMETHOD Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE; michael@0: michael@0: // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our michael@0: // nsISerializable impl works right. michael@0: NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) MOZ_OVERRIDE; michael@0: //NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr ); michael@0: michael@0: protected: michael@0: virtual nsresult EqualsInternal(nsIURI* other, michael@0: RefHandlingEnum refHandlingMode, michael@0: bool* result) MOZ_OVERRIDE; michael@0: private: michael@0: nsCOMPtr mBaseURI; michael@0: }; michael@0: michael@0: #endif /* nsJSProtocolHandler_h___ */