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
11 #include "nsCOMArray.h"
12 #include "nsChromeRegistry.h"
13 #include "nsClassHashtable.h"
20 } // namespace mozilla
25 class nsChromeRegistryChrome
: public nsChromeRegistry
{
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 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
);
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
) {}
66 nsCOMPtr
<nsIURI
> baseURI
;
69 class nsProviderArray
{
71 nsProviderArray() : mArray(1) {}
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.
78 LOCALE
= 1, // "en-GB" is selected, we found "en-US"
82 nsIURI
* GetBase(const nsACString
& aPreferred
, MatchType aType
);
83 const nsACString
& GetSelected(const nsACString
& aPreferred
,
85 void SetBase(const nsACString
& aProvider
, nsIURI
* base
);
86 void EnumerateToArray(nsTArray
<nsCString
>* a
);
89 ProviderEntry
* GetProvider(const nsACString
& aPreferred
, MatchType aType
);
91 nsTArray
<ProviderEntry
> mArray
;
94 struct PackageEntry
: public PLDHashEntryHdr
{
95 PackageEntry() : flags(0) {}
98 nsCOMPtr
<nsIURI
> baseURI
;
100 nsProviderArray locales
;
101 nsProviderArray skins
;
105 bool mDynamicRegistration
;
107 // Hash of package names ("global") to PackageEntry objects
108 nsClassHashtable
<nsCStringHashKey
, PackageEntry
> mPackagesHash
;
110 virtual void ManifestContent(ManifestProcessingContext
& cx
, int lineno
,
111 char* const* argv
, int flags
) override
;
112 virtual void ManifestLocale(ManifestProcessingContext
& cx
, int lineno
,
113 char* const* argv
, int flags
) override
;
114 virtual void ManifestSkin(ManifestProcessingContext
& cx
, int lineno
,
115 char* const* argv
, int flags
) override
;
116 virtual void ManifestOverride(ManifestProcessingContext
& cx
, int lineno
,
117 char* const* argv
, int flags
) override
;
118 virtual void ManifestResource(ManifestProcessingContext
& cx
, int lineno
,
119 char* const* argv
, int flags
) override
;
122 #endif // nsChromeRegistryChrome_h