Bug 1529726 [wpt PR 15414] - HTML: window.length and named access, a=testonly
[gecko.git] / chrome / nsChromeRegistryChrome.h
blobf87ef22fda50bc63815750c98554c5119b50dc84
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 "nsCOMArray.h"
10 #include "nsChromeRegistry.h"
11 #include "nsTArray.h"
12 #include "mozilla/Move.h"
13 #include "nsClassHashtable.h"
15 namespace mozilla {
16 namespace dom {
17 class PContentParent;
18 } // namespace dom
19 } // namespace mozilla
21 class nsIPrefBranch;
22 struct ChromePackage;
24 class nsChromeRegistryChrome : public nsChromeRegistry {
25 public:
26 nsChromeRegistryChrome();
27 ~nsChromeRegistryChrome();
29 nsresult Init() override;
31 NS_IMETHOD CheckForNewChrome() override;
32 NS_IMETHOD CheckForOSAccessibility() override;
33 NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
34 nsIUTF8StringEnumerator** aResult) override;
35 NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override;
36 NS_IMETHOD GetSelectedLocale(const nsACString& aPackage, bool aAsBCP47,
37 nsACString& aLocale) override;
38 NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
39 const char16_t* someData) override;
41 // If aChild is non-null then it is a new child to notify. If aChild is
42 // null, then we have installed new chrome and we are resetting all of our
43 // children's registered chrome.
44 void SendRegisteredChrome(mozilla::dom::PContentParent* aChild);
46 private:
47 struct PackageEntry;
48 static void ChromePackageFromPackageEntry(const nsACString& aPackageName,
49 PackageEntry* aPackage,
50 ChromePackage* aChromePackage,
51 const nsCString& aSelectedSkin);
53 nsresult OverrideLocalePackage(const nsACString& aPackage,
54 nsACString& aOverride);
55 nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
56 const nsCString& aProvider,
57 const nsCString& aPath) override;
58 nsresult GetFlagsFromPackage(const nsCString& aPackage,
59 uint32_t* aFlags) override;
61 struct ProviderEntry {
62 ProviderEntry(const nsACString& aProvider, nsIURI* aBase)
63 : provider(aProvider), baseURI(aBase) {}
65 nsCString provider;
66 nsCOMPtr<nsIURI> baseURI;
69 class nsProviderArray {
70 public:
71 nsProviderArray() : mArray(1) {}
72 ~nsProviderArray() {}
74 // When looking up locales and skins, the "selected" locale is not always
75 // available. This enum identifies what kind of match is desired/found.
76 enum MatchType {
77 EXACT = 0,
78 LOCALE = 1, // "en-GB" is selected, we found "en-US"
79 ANY = 2
82 nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
83 const nsACString& GetSelected(const nsACString& aPreferred,
84 MatchType aType);
85 void SetBase(const nsACString& aProvider, nsIURI* base);
86 void EnumerateToArray(nsTArray<nsCString>* a);
88 private:
89 ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
91 nsTArray<ProviderEntry> mArray;
94 struct PackageEntry : public PLDHashEntryHdr {
95 PackageEntry() : flags(0) {}
96 ~PackageEntry() {}
98 nsCOMPtr<nsIURI> baseURI;
99 uint32_t flags;
100 nsProviderArray locales;
101 nsProviderArray skins;
104 bool mProfileLoaded;
105 bool mDynamicRegistration;
107 nsCString mSelectedSkin;
109 // Hash of package names ("global") to PackageEntry objects
110 nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
112 virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
113 char* const* argv, int flags) override;
114 virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
115 char* const* argv, int flags) override;
116 virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
117 char* const* argv, int flags) override;
118 virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
119 char* const* argv, int flags) override;
120 virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
121 char* const* argv, int flags) override;
124 #endif // nsChromeRegistryChrome_h