From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- chrome/nsChromeRegistryChrome.h | 121 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 chrome/nsChromeRegistryChrome.h (limited to 'chrome/nsChromeRegistryChrome.h') diff --git a/chrome/nsChromeRegistryChrome.h b/chrome/nsChromeRegistryChrome.h new file mode 100644 index 0000000000..df100bc3df --- /dev/null +++ b/chrome/nsChromeRegistryChrome.h @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsChromeRegistryChrome_h +#define nsChromeRegistryChrome_h + +#include + +#include "nsCOMArray.h" +#include "nsChromeRegistry.h" +#include "nsClassHashtable.h" +#include "nsTArray.h" + +namespace mozilla { +namespace dom { +class PContentParent; +} // namespace dom +} // namespace mozilla + +class nsIPrefBranch; +struct ChromePackage; + +class nsChromeRegistryChrome : public nsChromeRegistry { + public: + nsChromeRegistryChrome(); + ~nsChromeRegistryChrome(); + + nsresult Init() override; + + NS_IMETHOD CheckForNewChrome() override; + NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage, + nsIUTF8StringEnumerator** aResult) override; + NS_IMETHOD IsLocaleRTL(const nsACString& package, bool* aResult) override; + nsresult GetSelectedLocale(const nsACString& aPackage, nsACString& aLocale); + NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic, + const char16_t* someData) override; + + // If aChild is non-null then it is a new child to notify. If aChild is + // null, then we have installed new chrome and we are resetting all of our + // children's registered chrome. + void SendRegisteredChrome(mozilla::dom::PContentParent* aChild); + + private: + struct PackageEntry; + static void ChromePackageFromPackageEntry(const nsACString& aPackageName, + PackageEntry* aPackage, + ChromePackage* aChromePackage, + const nsCString& aSelectedSkin); + + nsresult OverrideLocalePackage(const nsACString& aPackage, + nsACString& aOverride); + nsIURI* GetBaseURIFromPackage(const nsCString& aPackage, + const nsCString& aProvider, + const nsCString& aPath) override; + nsresult GetFlagsFromPackage(const nsCString& aPackage, + uint32_t* aFlags) override; + + struct ProviderEntry { + ProviderEntry(const nsACString& aProvider, nsIURI* aBase) + : provider(aProvider), baseURI(aBase) {} + + nsCString provider; + nsCOMPtr baseURI; + }; + + class nsProviderArray { + public: + nsProviderArray() : mArray(1) {} + ~nsProviderArray() {} + + // When looking up locales and skins, the "selected" locale is not always + // available. This enum identifies what kind of match is desired/found. + enum MatchType { + EXACT = 0, + LOCALE = 1, // "en-GB" is selected, we found "en-US" + ANY = 2 + }; + + nsIURI* GetBase(const nsACString& aPreferred, MatchType aType); + const nsACString& GetSelected(const nsACString& aPreferred, + MatchType aType); + void SetBase(const nsACString& aProvider, nsIURI* base); + void EnumerateToArray(nsTArray* a); + + private: + ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType); + + nsTArray mArray; + }; + + struct PackageEntry : public PLDHashEntryHdr { + PackageEntry() : flags(0) {} + ~PackageEntry() {} + + nsCOMPtr baseURI; + uint32_t flags; + nsProviderArray locales; + nsProviderArray skins; + }; + + bool mProfileLoaded; + bool mDynamicRegistration; + + // Hash of package names ("global") to PackageEntry objects + nsClassHashtable mPackagesHash; + + virtual void ManifestContent(ManifestProcessingContext& cx, int lineno, + char* const* argv, int flags) override; + virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno, + char* const* argv, int flags) override; + virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno, + char* const* argv, int flags) override; + virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno, + char* const* argv, int flags) override; + virtual void ManifestResource(ManifestProcessingContext& cx, int lineno, + char* const* argv, int flags) override; +}; + +#endif // nsChromeRegistryChrome_h -- cgit v1.2.3