Bug 1876295 - Update symbol scrapping for firefox archlinux packages r=gsvelto
[gecko.git] / chrome / nsChromeRegistryChrome.h
blobdf100bc3dfdd6092b9601583bdf82df102d92417
1 /* -*- Mode: C++; tab-width: 8; 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 nsChromeRegistryChrome_h
7 #define nsChromeRegistryChrome_h
9 #include <utility>
11 #include "nsCOMArray.h"
12 #include "nsChromeRegistry.h"
13 #include "nsClassHashtable.h"
14 #include "nsTArray.h"
16 namespace mozilla {
17 namespace dom {
18 class PContentParent;
19 } // namespace dom
20 } // namespace mozilla
22 class nsIPrefBranch;
23 struct ChromePackage;
25 class nsChromeRegistryChrome : public nsChromeRegistry {
26 public:
27 nsChromeRegistryChrome();
28 ~nsChromeRegistryChrome();
30 nsresult Init() override;
32 NS_IMETHOD CheckForNewChrome() override;
33 NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
34 nsIUTF8StringEnumerator** aResult) override;
35 NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
36 nsresult GetSelectedLocale(const nsACString& aPackage, nsACString& aLocale);
37 NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
38 const char16_t* someData) override;
40 // If aChild is non-null then it is a new child to notify. If aChild is
41 // null, then we have installed new chrome and we are resetting all of our
42 // children's registered chrome.
43 void SendRegisteredChrome(mozilla::dom::PContentParent* aChild);
45 private:
46 struct PackageEntry;
47 static void ChromePackageFromPackageEntry(const nsACString& aPackageName,
48 PackageEntry* aPackage,
49 ChromePackage* aChromePackage,
50 const nsCString& aSelectedSkin);
52 nsresult OverrideLocalePackage(const nsACString& aPackage,
53 nsACString& aOverride);
54 nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
55 const nsCString& aProvider,
56 const nsCString& aPath) override;
57 nsresult GetFlagsFromPackage(const nsCString& aPackage,
58 uint32_t* aFlags) override;
60 struct ProviderEntry {
61 ProviderEntry(const nsACString& aProvider, nsIURI* aBase)
62 : provider(aProvider), baseURI(aBase) {}
64 nsCString provider;
65 nsCOMPtr<nsIURI> baseURI;
68 class nsProviderArray {
69 public:
70 nsProviderArray() : mArray(1) {}
71 ~nsProviderArray() {}
73 // When looking up locales and skins, the "selected" locale is not always
74 // available. This enum identifies what kind of match is desired/found.
75 enum MatchType {
76 EXACT = 0,
77 LOCALE = 1, // "en-GB" is selected, we found "en-US"
78 ANY = 2
81 nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
82 const nsACString& GetSelected(const nsACString& aPreferred,
83 MatchType aType);
84 void SetBase(const nsACString& aProvider, nsIURI* base);
85 void EnumerateToArray(nsTArray<nsCString>* a);
87 private:
88 ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
90 nsTArray<ProviderEntry> mArray;
93 struct PackageEntry : public PLDHashEntryHdr {
94 PackageEntry() : flags(0) {}
95 ~PackageEntry() {}
97 nsCOMPtr<nsIURI> baseURI;
98 uint32_t flags;
99 nsProviderArray locales;
100 nsProviderArray skins;
103 bool mProfileLoaded;
104 bool mDynamicRegistration;
106 // Hash of package names ("global") to PackageEntry objects
107 nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
109 virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
110 char* const* argv, int flags) override;
111 virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
112 char* const* argv, int flags) override;
113 virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
114 char* const* argv, int flags) override;
115 virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
116 char* const* argv, int flags) override;
117 virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
118 char* const* argv, int flags) override;
121 #endif // nsChromeRegistryChrome_h