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"
12 #include "mozilla/Move.h"
13 #include "nsClassHashtable.h"
19 } // namespace mozilla
24 class nsChromeRegistryChrome
: public nsChromeRegistry
27 nsChromeRegistryChrome();
28 ~nsChromeRegistryChrome();
30 nsresult
Init() override
;
32 NS_IMETHOD
CheckForNewChrome() override
;
33 NS_IMETHOD
CheckForOSAccessibility() override
;
34 NS_IMETHOD
GetLocalesForPackage(const nsACString
& aPackage
,
35 nsIUTF8StringEnumerator
* *aResult
) override
;
36 NS_IMETHOD
IsLocaleRTL(const nsACString
& package
,
37 bool *aResult
) override
;
38 NS_IMETHOD
GetSelectedLocale(const nsACString
& aPackage
,
40 nsACString
& aLocale
) override
;
41 NS_IMETHOD
Observe(nsISupports
*aSubject
, const char *aTopic
,
42 const char16_t
*someData
) override
;
44 // If aChild is non-null then it is a new child to notify. If aChild is
45 // null, then we have installed new chrome and we are resetting all of our
46 // children's registered chrome.
47 void SendRegisteredChrome(mozilla::dom::PContentParent
* aChild
);
51 static void ChromePackageFromPackageEntry(const nsACString
& aPackageName
,
52 PackageEntry
* aPackage
,
53 ChromePackage
* aChromePackage
,
54 const nsCString
& aSelectedSkin
);
56 nsresult
OverrideLocalePackage(const nsACString
& aPackage
,
57 nsACString
& aOverride
);
58 nsIURI
* GetBaseURIFromPackage(const nsCString
& aPackage
,
59 const nsCString
& aProvider
,
60 const nsCString
& aPath
) override
;
61 nsresult
GetFlagsFromPackage(const nsCString
& aPackage
,
62 uint32_t* aFlags
) override
;
66 ProviderEntry(const nsACString
& aProvider
, nsIURI
* aBase
) :
71 nsCOMPtr
<nsIURI
> baseURI
;
79 ~nsProviderArray() { }
81 // When looking up locales and skins, the "selected" locale is not always
82 // available. This enum identifies what kind of match is desired/found.
85 LOCALE
= 1, // "en-GB" is selected, we found "en-US"
89 nsIURI
* GetBase(const nsACString
& aPreferred
, MatchType aType
);
90 const nsACString
& GetSelected(const nsACString
& aPreferred
, MatchType aType
);
91 void SetBase(const nsACString
& aProvider
, nsIURI
* base
);
92 void EnumerateToArray(nsTArray
<nsCString
> *a
);
95 ProviderEntry
* GetProvider(const nsACString
& aPreferred
, MatchType aType
);
97 nsTArray
<ProviderEntry
> mArray
;
100 struct PackageEntry
: public PLDHashEntryHdr
106 nsCOMPtr
<nsIURI
> baseURI
;
108 nsProviderArray locales
;
109 nsProviderArray skins
;
113 bool mDynamicRegistration
;
115 nsCString mSelectedSkin
;
117 // Hash of package names ("global") to PackageEntry objects
118 nsClassHashtable
<nsCStringHashKey
, PackageEntry
> mPackagesHash
;
120 virtual void ManifestContent(ManifestProcessingContext
& cx
, int lineno
,
121 char *const * argv
, int flags
) override
;
122 virtual void ManifestLocale(ManifestProcessingContext
& cx
, int lineno
,
123 char *const * argv
, int flags
) override
;
124 virtual void ManifestSkin(ManifestProcessingContext
& cx
, int lineno
,
125 char *const * argv
, int flags
) override
;
126 virtual void ManifestOverride(ManifestProcessingContext
& cx
, int lineno
,
127 char *const * argv
, int flags
) override
;
128 virtual void ManifestResource(ManifestProcessingContext
& cx
, int lineno
,
129 char *const * argv
, int flags
) override
;
132 #endif // nsChromeRegistryChrome_h