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"
24 class nsChromeRegistryChrome
: public nsChromeRegistry
27 nsChromeRegistryChrome();
28 ~nsChromeRegistryChrome();
30 nsresult
Init() MOZ_OVERRIDE
;
32 NS_IMETHOD
CheckForNewChrome() MOZ_OVERRIDE
;
33 NS_IMETHOD
CheckForOSAccessibility() MOZ_OVERRIDE
;
34 NS_IMETHOD
GetLocalesForPackage(const nsACString
& aPackage
,
35 nsIUTF8StringEnumerator
* *aResult
) MOZ_OVERRIDE
;
36 NS_IMETHOD
IsLocaleRTL(const nsACString
& package
,
37 bool *aResult
) MOZ_OVERRIDE
;
38 NS_IMETHOD
GetSelectedLocale(const nsACString
& aPackage
,
39 nsACString
& aLocale
) MOZ_OVERRIDE
;
40 NS_IMETHOD
Observe(nsISupports
*aSubject
, const char *aTopic
,
41 const char16_t
*someData
) MOZ_OVERRIDE
;
44 NS_IMETHOD
GetXULOverlays(nsIURI
*aURI
,
45 nsISimpleEnumerator
**_retval
) MOZ_OVERRIDE
;
46 NS_IMETHOD
GetStyleOverlays(nsIURI
*aURI
,
47 nsISimpleEnumerator
**_retval
) MOZ_OVERRIDE
;
50 // If aChild is non-null then it is a new child to notify. If aChild is
51 // null, then we have installed new chrome and we are resetting all of our
52 // children's registered chrome.
53 void SendRegisteredChrome(mozilla::dom::PContentParent
* aChild
);
57 static void ChromePackageFromPackageEntry(const nsACString
& aPackageName
,
58 PackageEntry
* aPackage
,
59 ChromePackage
* aChromePackage
,
60 const nsCString
& aSelectedLocale
,
61 const nsCString
& aSelectedSkin
);
62 static PLDHashOperator
CollectPackages(const nsACString
&aKey
,
63 PackageEntry
*package
,
66 nsresult
OverrideLocalePackage(const nsACString
& aPackage
,
67 nsACString
& aOverride
);
68 nsresult
SelectLocaleFromPref(nsIPrefBranch
* prefs
);
69 nsresult
UpdateSelectedLocale() MOZ_OVERRIDE
;
70 nsIURI
* GetBaseURIFromPackage(const nsCString
& aPackage
,
71 const nsCString
& aProvider
,
72 const nsCString
& aPath
) MOZ_OVERRIDE
;
73 nsresult
GetFlagsFromPackage(const nsCString
& aPackage
,
74 uint32_t* aFlags
) MOZ_OVERRIDE
;
78 ProviderEntry(const nsACString
& aProvider
, nsIURI
* aBase
) :
83 nsCOMPtr
<nsIURI
> baseURI
;
91 ~nsProviderArray() { }
93 // When looking up locales and skins, the "selected" locale is not always
94 // available. This enum identifies what kind of match is desired/found.
97 LOCALE
= 1, // "en-GB" is selected, we found "en-US"
101 nsIURI
* GetBase(const nsACString
& aPreferred
, MatchType aType
);
102 const nsACString
& GetSelected(const nsACString
& aPreferred
, MatchType aType
);
103 void SetBase(const nsACString
& aProvider
, nsIURI
* base
);
104 void EnumerateToArray(nsTArray
<nsCString
> *a
);
107 ProviderEntry
* GetProvider(const nsACString
& aPreferred
, MatchType aType
);
109 nsTArray
<ProviderEntry
> mArray
;
112 struct PackageEntry
: public PLDHashEntryHdr
118 nsCOMPtr
<nsIURI
> baseURI
;
120 nsProviderArray locales
;
121 nsProviderArray skins
;
124 class OverlayListEntry
: public nsURIHashKey
127 typedef nsURIHashKey::KeyType KeyType
;
128 typedef nsURIHashKey::KeyTypePointer KeyTypePointer
;
130 OverlayListEntry(KeyTypePointer aKey
) : nsURIHashKey(aKey
) { }
131 OverlayListEntry(OverlayListEntry
&& toMove
) : nsURIHashKey(mozilla::Move(toMove
)),
132 mArray(mozilla::Move(toMove
.mArray
)) { }
133 ~OverlayListEntry() { }
135 void AddURI(nsIURI
* aURI
);
137 nsCOMArray
<nsIURI
> mArray
;
140 class OverlayListHash
143 OverlayListHash() { }
144 ~OverlayListHash() { }
146 void Add(nsIURI
* aBase
, nsIURI
* aOverlay
);
147 void Clear() { mTable
.Clear(); }
148 const nsCOMArray
<nsIURI
>* GetArray(nsIURI
* aBase
);
151 nsTHashtable
<OverlayListEntry
> mTable
;
154 // Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
155 // to a list of overlays/stylesheets
156 OverlayListHash mOverlayHash
;
157 OverlayListHash mStyleHash
;
160 bool mDynamicRegistration
;
162 nsCString mSelectedLocale
;
163 nsCString mSelectedSkin
;
165 // Hash of package names ("global") to PackageEntry objects
166 nsClassHashtable
<nsCStringHashKey
, PackageEntry
> mPackagesHash
;
168 virtual void ManifestContent(ManifestProcessingContext
& cx
, int lineno
,
169 char *const * argv
, bool platform
,
170 bool contentaccessible
);
171 virtual void ManifestLocale(ManifestProcessingContext
& cx
, int lineno
,
172 char *const * argv
, bool platform
,
173 bool contentaccessible
);
174 virtual void ManifestSkin(ManifestProcessingContext
& cx
, int lineno
,
175 char *const * argv
, bool platform
,
176 bool contentaccessible
);
177 virtual void ManifestOverlay(ManifestProcessingContext
& cx
, int lineno
,
178 char *const * argv
, bool platform
,
179 bool contentaccessible
);
180 virtual void ManifestStyle(ManifestProcessingContext
& cx
, int lineno
,
181 char *const * argv
, bool platform
,
182 bool contentaccessible
);
183 virtual void ManifestOverride(ManifestProcessingContext
& cx
, int lineno
,
184 char *const * argv
, bool platform
,
185 bool contentaccessible
);
186 virtual void ManifestResource(ManifestProcessingContext
& cx
, int lineno
,
187 char *const * argv
, bool platform
,
188 bool contentaccessible
);
191 #endif // nsChromeRegistryChrome_h