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 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsdirectoryviewer__h____ |
michael@0 | 7 | #define nsdirectoryviewer__h____ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsNetUtil.h" |
michael@0 | 10 | #include "nsIStreamListener.h" |
michael@0 | 11 | #include "nsIContentViewer.h" |
michael@0 | 12 | #include "nsIHTTPIndex.h" |
michael@0 | 13 | #include "nsIRDFService.h" |
michael@0 | 14 | #include "nsIRDFDataSource.h" |
michael@0 | 15 | #include "nsIRDFLiteral.h" |
michael@0 | 16 | #include "nsIDocumentLoaderFactory.h" |
michael@0 | 17 | #include "nsITimer.h" |
michael@0 | 18 | #include "nsISupportsArray.h" |
michael@0 | 19 | #include "nsXPIDLString.h" |
michael@0 | 20 | #include "nsIDirIndexListener.h" |
michael@0 | 21 | #include "nsIFTPChannel.h" |
michael@0 | 22 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 23 | |
michael@0 | 24 | class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory |
michael@0 | 25 | { |
michael@0 | 26 | public: |
michael@0 | 27 | nsDirectoryViewerFactory(); |
michael@0 | 28 | virtual ~nsDirectoryViewerFactory(); |
michael@0 | 29 | |
michael@0 | 30 | // nsISupports interface |
michael@0 | 31 | NS_DECL_ISUPPORTS |
michael@0 | 32 | NS_DECL_NSIDOCUMENTLOADERFACTORY |
michael@0 | 33 | }; |
michael@0 | 34 | |
michael@0 | 35 | class nsHTTPIndex : public nsIHTTPIndex, |
michael@0 | 36 | public nsIRDFDataSource, |
michael@0 | 37 | public nsIStreamListener, |
michael@0 | 38 | public nsIDirIndexListener, |
michael@0 | 39 | public nsIInterfaceRequestor, |
michael@0 | 40 | public nsIFTPEventSink |
michael@0 | 41 | { |
michael@0 | 42 | private: |
michael@0 | 43 | |
michael@0 | 44 | // note: these are NOT statics due to the native of nsHTTPIndex |
michael@0 | 45 | // where it may or may not be treated as a singleton |
michael@0 | 46 | |
michael@0 | 47 | nsCOMPtr<nsIRDFResource> kNC_Child; |
michael@0 | 48 | nsCOMPtr<nsIRDFResource> kNC_Comment; |
michael@0 | 49 | nsCOMPtr<nsIRDFResource> kNC_Loading; |
michael@0 | 50 | nsCOMPtr<nsIRDFResource> kNC_URL; |
michael@0 | 51 | nsCOMPtr<nsIRDFResource> kNC_Description; |
michael@0 | 52 | nsCOMPtr<nsIRDFResource> kNC_ContentLength; |
michael@0 | 53 | nsCOMPtr<nsIRDFResource> kNC_LastModified; |
michael@0 | 54 | nsCOMPtr<nsIRDFResource> kNC_ContentType; |
michael@0 | 55 | nsCOMPtr<nsIRDFResource> kNC_FileType; |
michael@0 | 56 | nsCOMPtr<nsIRDFResource> kNC_IsContainer; |
michael@0 | 57 | nsCOMPtr<nsIRDFLiteral> kTrueLiteral; |
michael@0 | 58 | nsCOMPtr<nsIRDFLiteral> kFalseLiteral; |
michael@0 | 59 | |
michael@0 | 60 | nsCOMPtr<nsIRDFService> mDirRDF; |
michael@0 | 61 | |
michael@0 | 62 | protected: |
michael@0 | 63 | // We grab a reference to the content viewer container (which |
michael@0 | 64 | // indirectly owns us) so that we can insert ourselves as a global |
michael@0 | 65 | // in the script context _after_ the XUL doc has been embedded into |
michael@0 | 66 | // content viewer. We'll know that this has happened once we receive |
michael@0 | 67 | // an OnStartRequest() notification |
michael@0 | 68 | |
michael@0 | 69 | nsCOMPtr<nsIRDFDataSource> mInner; |
michael@0 | 70 | nsCOMPtr<nsISupportsArray> mConnectionList; |
michael@0 | 71 | nsCOMPtr<nsISupportsArray> mNodeList; |
michael@0 | 72 | nsCOMPtr<nsITimer> mTimer; |
michael@0 | 73 | nsCOMPtr<nsIDirIndexParser> mParser; |
michael@0 | 74 | nsCString mBaseURL; |
michael@0 | 75 | nsCString mEncoding; |
michael@0 | 76 | bool mBindToGlobalObject; |
michael@0 | 77 | nsIInterfaceRequestor* mRequestor; // WEAK |
michael@0 | 78 | nsCOMPtr<nsIRDFResource> mDirectory; |
michael@0 | 79 | |
michael@0 | 80 | nsHTTPIndex(nsIInterfaceRequestor* aRequestor); |
michael@0 | 81 | nsresult CommonInit(void); |
michael@0 | 82 | nsresult Init(nsIURI* aBaseURL); |
michael@0 | 83 | void GetDestination(nsIRDFResource* r, nsXPIDLCString& dest); |
michael@0 | 84 | bool isWellknownContainerURI(nsIRDFResource *r); |
michael@0 | 85 | nsresult AddElement(nsIRDFResource *parent, nsIRDFResource *prop, |
michael@0 | 86 | nsIRDFNode *child); |
michael@0 | 87 | |
michael@0 | 88 | static void FireTimer(nsITimer* aTimer, void* aClosure); |
michael@0 | 89 | |
michael@0 | 90 | public: |
michael@0 | 91 | nsHTTPIndex(); |
michael@0 | 92 | virtual ~nsHTTPIndex(); |
michael@0 | 93 | nsresult Init(void); |
michael@0 | 94 | |
michael@0 | 95 | static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer, |
michael@0 | 96 | nsIHTTPIndex** aResult); |
michael@0 | 97 | |
michael@0 | 98 | // nsIHTTPIndex interface |
michael@0 | 99 | NS_DECL_NSIHTTPINDEX |
michael@0 | 100 | |
michael@0 | 101 | // NSIRDFDataSource interface |
michael@0 | 102 | NS_DECL_NSIRDFDATASOURCE |
michael@0 | 103 | |
michael@0 | 104 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 105 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 106 | |
michael@0 | 107 | NS_DECL_NSIDIRINDEXLISTENER |
michael@0 | 108 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 109 | NS_DECL_NSIFTPEVENTSINK |
michael@0 | 110 | |
michael@0 | 111 | // nsISupports interface |
michael@0 | 112 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 113 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsHTTPIndex, nsIHTTPIndex) |
michael@0 | 114 | }; |
michael@0 | 115 | |
michael@0 | 116 | // {82776710-5690-11d3-BE36-00104BDE6048} |
michael@0 | 117 | #define NS_DIRECTORYVIEWERFACTORY_CID \ |
michael@0 | 118 | { 0x82776710, 0x5690, 0x11d3, { 0xbe, 0x36, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } |
michael@0 | 119 | |
michael@0 | 120 | #endif // nsdirectoryviewer__h____ |