2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef nsJSProtocolHandler_h___
|
|
|
|
#define nsJSProtocolHandler_h___
|
|
|
|
|
2013-06-05 09:15:48 -07:00
|
|
|
#include "mozilla/Attributes.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIProtocolHandler.h"
|
|
|
|
#include "nsITextToSubURI.h"
|
2008-11-18 14:54:36 -08:00
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsIMutable.h"
|
|
|
|
#include "nsISerializable.h"
|
|
|
|
#include "nsIClassInfo.h"
|
2011-05-25 13:23:07 -07:00
|
|
|
#include "nsSimpleURI.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#define NS_JSPROTOCOLHANDLER_CID \
|
|
|
|
{ /* bfc310d2-38a0-11d3-8cd3-0060b0fc14a3 */ \
|
|
|
|
0xbfc310d2, \
|
|
|
|
0x38a0, \
|
|
|
|
0x11d3, \
|
|
|
|
{0x8c, 0xd3, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
|
|
|
}
|
|
|
|
|
2008-11-18 14:54:36 -08:00
|
|
|
#define NS_JSURI_CID \
|
|
|
|
{ /* 58f089ee-512a-42d2-a935-d0c874128930 */ \
|
|
|
|
0x58f089ee, \
|
|
|
|
0x512a, \
|
|
|
|
0x42d2, \
|
|
|
|
{0xa9, 0x35, 0xd0, 0xc8, 0x74, 0x12, 0x89, 0x30} \
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_JSPROTOCOLHANDLER_CONTRACTID \
|
|
|
|
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "javascript"
|
|
|
|
|
|
|
|
|
|
|
|
class nsJSProtocolHandler : public nsIProtocolHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIProtocolHandler methods:
|
|
|
|
NS_DECL_NSIPROTOCOLHANDLER
|
|
|
|
|
|
|
|
// nsJSProtocolHandler methods:
|
|
|
|
nsJSProtocolHandler();
|
|
|
|
|
2010-06-10 11:11:11 -07:00
|
|
|
static nsresult
|
2007-03-22 10:30:00 -07:00
|
|
|
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
|
|
|
|
|
|
|
nsresult Init();
|
|
|
|
|
|
|
|
protected:
|
2014-06-23 12:56:07 -07:00
|
|
|
virtual ~nsJSProtocolHandler();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsresult EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset,
|
|
|
|
nsACString &aUTF8Spec);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITextToSubURI> mTextToSubURI;
|
|
|
|
};
|
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
|
|
|
|
class nsJSURI : public nsSimpleURI
|
2008-11-18 14:54:36 -08:00
|
|
|
{
|
|
|
|
public:
|
2012-08-07 00:06:29 -07:00
|
|
|
using nsSimpleURI::Read;
|
|
|
|
using nsSimpleURI::Write;
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
nsJSURI() {}
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2014-09-01 17:49:25 -07:00
|
|
|
explicit nsJSURI(nsIURI* aBaseURI) : mBaseURI(aBaseURI) {}
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
nsIURI* GetBaseURI() const
|
|
|
|
{
|
|
|
|
return mBaseURI;
|
|
|
|
}
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
// nsIURI overrides
|
2013-06-05 09:15:48 -07:00
|
|
|
virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode) MOZ_OVERRIDE;
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
// nsISerializable overrides
|
2013-06-05 09:15:48 -07:00
|
|
|
NS_IMETHOD Read(nsIObjectInputStream* aStream) MOZ_OVERRIDE;
|
|
|
|
NS_IMETHOD Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE;
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-25 13:23:07 -07:00
|
|
|
// Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
|
|
|
|
// nsISerializable impl works right.
|
2013-06-05 09:15:48 -07:00
|
|
|
NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) MOZ_OVERRIDE;
|
2011-05-25 13:23:07 -07:00
|
|
|
//NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr );
|
2008-11-18 14:54:36 -08:00
|
|
|
|
2011-05-26 01:20:06 -07:00
|
|
|
protected:
|
2014-07-08 14:23:17 -07:00
|
|
|
virtual ~nsJSURI() {}
|
|
|
|
|
2011-05-26 01:20:06 -07:00
|
|
|
virtual nsresult EqualsInternal(nsIURI* other,
|
|
|
|
RefHandlingEnum refHandlingMode,
|
2013-06-05 09:15:48 -07:00
|
|
|
bool* result) MOZ_OVERRIDE;
|
2008-11-18 14:54:36 -08:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
|
|
};
|
2011-05-25 13:23:07 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif /* nsJSProtocolHandler_h___ */
|