|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsJSProtocolHandler_h___ |
|
7 #define nsJSProtocolHandler_h___ |
|
8 |
|
9 #include "mozilla/Attributes.h" |
|
10 #include "nsIProtocolHandler.h" |
|
11 #include "nsITextToSubURI.h" |
|
12 #include "nsIURI.h" |
|
13 #include "nsIMutable.h" |
|
14 #include "nsISerializable.h" |
|
15 #include "nsIClassInfo.h" |
|
16 #include "nsSimpleURI.h" |
|
17 |
|
18 #define NS_JSPROTOCOLHANDLER_CID \ |
|
19 { /* bfc310d2-38a0-11d3-8cd3-0060b0fc14a3 */ \ |
|
20 0xbfc310d2, \ |
|
21 0x38a0, \ |
|
22 0x11d3, \ |
|
23 {0x8c, 0xd3, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \ |
|
24 } |
|
25 |
|
26 #define NS_JSURI_CID \ |
|
27 { /* 58f089ee-512a-42d2-a935-d0c874128930 */ \ |
|
28 0x58f089ee, \ |
|
29 0x512a, \ |
|
30 0x42d2, \ |
|
31 {0xa9, 0x35, 0xd0, 0xc8, 0x74, 0x12, 0x89, 0x30} \ |
|
32 } |
|
33 |
|
34 #define NS_JSPROTOCOLHANDLER_CONTRACTID \ |
|
35 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "javascript" |
|
36 |
|
37 |
|
38 class nsJSProtocolHandler : public nsIProtocolHandler |
|
39 { |
|
40 public: |
|
41 NS_DECL_ISUPPORTS |
|
42 |
|
43 // nsIProtocolHandler methods: |
|
44 NS_DECL_NSIPROTOCOLHANDLER |
|
45 |
|
46 // nsJSProtocolHandler methods: |
|
47 nsJSProtocolHandler(); |
|
48 virtual ~nsJSProtocolHandler(); |
|
49 |
|
50 static nsresult |
|
51 Create(nsISupports *aOuter, REFNSIID aIID, void **aResult); |
|
52 |
|
53 nsresult Init(); |
|
54 |
|
55 protected: |
|
56 |
|
57 nsresult EnsureUTF8Spec(const nsAFlatCString &aSpec, const char *aCharset, |
|
58 nsACString &aUTF8Spec); |
|
59 |
|
60 nsCOMPtr<nsITextToSubURI> mTextToSubURI; |
|
61 }; |
|
62 |
|
63 |
|
64 class nsJSURI : public nsSimpleURI |
|
65 { |
|
66 public: |
|
67 using nsSimpleURI::Read; |
|
68 using nsSimpleURI::Write; |
|
69 |
|
70 nsJSURI() {} |
|
71 |
|
72 nsJSURI(nsIURI* aBaseURI) : mBaseURI(aBaseURI) {} |
|
73 |
|
74 nsIURI* GetBaseURI() const |
|
75 { |
|
76 return mBaseURI; |
|
77 } |
|
78 |
|
79 NS_DECL_ISUPPORTS_INHERITED |
|
80 |
|
81 // nsIURI overrides |
|
82 virtual nsSimpleURI* StartClone(RefHandlingEnum refHandlingMode) MOZ_OVERRIDE; |
|
83 |
|
84 // nsISerializable overrides |
|
85 NS_IMETHOD Read(nsIObjectInputStream* aStream) MOZ_OVERRIDE; |
|
86 NS_IMETHOD Write(nsIObjectOutputStream* aStream) MOZ_OVERRIDE; |
|
87 |
|
88 // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our |
|
89 // nsISerializable impl works right. |
|
90 NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) MOZ_OVERRIDE; |
|
91 //NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr ); |
|
92 |
|
93 protected: |
|
94 virtual nsresult EqualsInternal(nsIURI* other, |
|
95 RefHandlingEnum refHandlingMode, |
|
96 bool* result) MOZ_OVERRIDE; |
|
97 private: |
|
98 nsCOMPtr<nsIURI> mBaseURI; |
|
99 }; |
|
100 |
|
101 #endif /* nsJSProtocolHandler_h___ */ |