Bug 1698048 - Move browser/themes/shared/reader/readerMode.svg to the browser/themes...
[gecko.git] / netwerk / protocol / res / nsResProtocolHandler.h
blob2d672dfad60e95c1d8454317e4f36b1b795cf224
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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/. */
6 #ifndef nsResProtocolHandler_h___
7 #define nsResProtocolHandler_h___
9 #include "mozilla/net/SubstitutingProtocolHandler.h"
11 #include "nsIResProtocolHandler.h"
12 #include "nsInterfaceHashtable.h"
13 #include "nsWeakReference.h"
15 struct SubstitutionMapping;
16 class nsResProtocolHandler final
17 : public nsIResProtocolHandler,
18 public mozilla::net::SubstitutingProtocolHandler,
19 public nsSupportsWeakReference {
20 public:
21 NS_DECL_ISUPPORTS_INHERITED
22 NS_DECL_NSIRESPROTOCOLHANDLER
24 static already_AddRefed<nsResProtocolHandler> GetSingleton();
26 NS_FORWARD_NSIPROTOCOLHANDLER(mozilla::net::SubstitutingProtocolHandler::)
28 nsResProtocolHandler()
29 : mozilla::net::SubstitutingProtocolHandler(
30 "resource",
31 URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE |
32 URI_IS_POTENTIALLY_TRUSTWORTHY,
33 /* aEnforceFileOrJar = */ false) {}
35 NS_IMETHOD SetSubstitution(const nsACString& aRoot,
36 nsIURI* aBaseURI) override;
37 NS_IMETHOD SetSubstitutionWithFlags(const nsACString& aRoot, nsIURI* aBaseURI,
38 uint32_t aFlags) override;
39 NS_IMETHOD HasSubstitution(const nsACString& aRoot, bool* aResult) override;
41 NS_IMETHOD GetSubstitution(const nsACString& aRoot,
42 nsIURI** aResult) override {
43 return mozilla::net::SubstitutingProtocolHandler::GetSubstitution(aRoot,
44 aResult);
47 NS_IMETHOD ResolveURI(nsIURI* aResURI, nsACString& aResult) override {
48 return mozilla::net::SubstitutingProtocolHandler::ResolveURI(aResURI,
49 aResult);
52 protected:
53 [[nodiscard]] nsresult GetSubstitutionInternal(const nsACString& aRoot,
54 nsIURI** aResult,
55 uint32_t* aFlags) override;
56 virtual ~nsResProtocolHandler() = default;
58 [[nodiscard]] bool ResolveSpecialCases(const nsACString& aHost,
59 const nsACString& aPath,
60 const nsACString& aPathname,
61 nsACString& aResult) override;
63 [[nodiscard]] virtual bool MustResolveJAR(const nsACString& aRoot) override {
64 return aRoot.EqualsLiteral("android");
67 private:
68 [[nodiscard]] nsresult Init();
69 static mozilla::StaticRefPtr<nsResProtocolHandler> sSingleton;
71 nsCString mAppURI;
72 nsCString mGREURI;
73 #ifdef ANDROID
74 // Used for resource://android URIs
75 nsCString mApkURI;
76 nsresult GetApkURI(nsACString& aResult);
77 #endif
80 #endif /* nsResProtocolHandler_h___ */