Line data Source code
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 nsResProtocolHandler_h___
7 : #define nsResProtocolHandler_h___
8 :
9 : #include "SubstitutingProtocolHandler.h"
10 :
11 : #include "nsIResProtocolHandler.h"
12 : #include "nsInterfaceHashtable.h"
13 : #include "nsWeakReference.h"
14 : #include "nsStandardURL.h"
15 :
16 : class nsISubstitutionObserver;
17 :
18 : struct SubstitutionMapping;
19 : class nsResProtocolHandler final : public nsIResProtocolHandler,
20 : public mozilla::SubstitutingProtocolHandler,
21 : public nsSupportsWeakReference
22 : {
23 : public:
24 : NS_DECL_ISUPPORTS_INHERITED
25 : NS_DECL_NSIRESPROTOCOLHANDLER
26 :
27 3209 : NS_FORWARD_NSIPROTOCOLHANDLER(mozilla::SubstitutingProtocolHandler::)
28 :
29 3 : nsResProtocolHandler()
30 3 : : SubstitutingProtocolHandler("resource", URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE,
31 3 : /* aEnforceFileOrJar = */ false)
32 3 : {}
33 :
34 : MOZ_MUST_USE nsresult Init();
35 :
36 : NS_IMETHOD SetSubstitution(const nsACString& aRoot, nsIURI* aBaseURI) override;
37 :
38 0 : NS_IMETHOD GetSubstitution(const nsACString& aRoot, nsIURI** aResult) override
39 : {
40 0 : return mozilla::SubstitutingProtocolHandler::GetSubstitution(aRoot, aResult);
41 : }
42 :
43 0 : NS_IMETHOD HasSubstitution(const nsACString& aRoot, bool* aResult) override
44 : {
45 0 : return mozilla::SubstitutingProtocolHandler::HasSubstitution(aRoot, aResult);
46 : }
47 :
48 577 : NS_IMETHOD ResolveURI(nsIURI *aResURI, nsACString& aResult) override
49 : {
50 577 : return mozilla::SubstitutingProtocolHandler::ResolveURI(aResURI, aResult);
51 : }
52 :
53 0 : NS_IMETHOD AddObserver(nsISubstitutionObserver *aObserver) override
54 : {
55 0 : return mozilla::SubstitutingProtocolHandler::AddObserver(aObserver);
56 : }
57 :
58 0 : NS_IMETHOD RemoveObserver(nsISubstitutionObserver *aObserver) override
59 : {
60 0 : return mozilla::SubstitutingProtocolHandler::RemoveObserver(aObserver);
61 : }
62 :
63 : protected:
64 : MOZ_MUST_USE nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) override;
65 0 : virtual ~nsResProtocolHandler() {}
66 :
67 : MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
68 : const nsACString& aPath,
69 : const nsACString& aPathname,
70 : nsACString& aResult) override;
71 :
72 : private:
73 : nsCString mAppURI;
74 : nsCString mGREURI;
75 : };
76 :
77 : #endif /* nsResProtocolHandler_h___ */
|