Bug 1486801 - Clicking on the [...] should expand the markup container. r=jdescottes
[gecko.git] / chrome / nsChromeRegistryChrome.h
blob57c3fa1dd10b84c6cdb7616b3c46b249179a6575
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
26 public:
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,
39 bool aAsBCP47,
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);
49 private:
50 struct PackageEntry;
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;
64 struct ProviderEntry
66 ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
67 provider(aProvider),
68 baseURI(aBase) { }
70 nsCString provider;
71 nsCOMPtr<nsIURI> baseURI;
74 class nsProviderArray
76 public:
77 nsProviderArray() :
78 mArray(1) { }
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.
83 enum MatchType {
84 EXACT = 0,
85 LOCALE = 1, // "en-GB" is selected, we found "en-US"
86 ANY = 2
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);
94 private:
95 ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
97 nsTArray<ProviderEntry> mArray;
100 struct PackageEntry : public PLDHashEntryHdr
102 PackageEntry()
103 : flags(0) { }
104 ~PackageEntry() { }
106 nsCOMPtr<nsIURI> baseURI;
107 uint32_t flags;
108 nsProviderArray locales;
109 nsProviderArray skins;
112 bool mProfileLoaded;
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