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 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
);
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
) {}
65 nsCOMPtr
<nsIURI
> baseURI
;
68 class nsProviderArray
{
70 nsProviderArray() : mArray(1) {}
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.
77 LOCALE
= 1, // "en-GB" is selected, we found "en-US"
81 nsIURI
* GetBase(const nsACString
& aPreferred
, MatchType aType
);
82 const nsACString
& GetSelected(const nsACString
& aPreferred
,
84 void SetBase(const nsACString
& aProvider
, nsIURI
* base
);
85 void EnumerateToArray(nsTArray
<nsCString
>* a
);
88 ProviderEntry
* GetProvider(const nsACString
& aPreferred
, MatchType aType
);
90 nsTArray
<ProviderEntry
> mArray
;
93 struct PackageEntry
: public PLDHashEntryHdr
{
94 PackageEntry() : flags(0) {}
97 nsCOMPtr
<nsIURI
> baseURI
;
99 nsProviderArray locales
;
100 nsProviderArray skins
;
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