nsChromeRegistryContent.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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/. */
  5. #ifndef nsChromeRegistryContent_h
  6. #define nsChromeRegistryContent_h
  7. #include "nsChromeRegistry.h"
  8. #include "nsClassHashtable.h"
  9. struct ChromePackage;
  10. struct SubstitutionMapping;
  11. struct OverrideMapping;
  12. class nsChromeRegistryContent : public nsChromeRegistry
  13. {
  14. public:
  15. nsChromeRegistryContent();
  16. void RegisterRemoteChrome(const InfallibleTArray<ChromePackage>& aPackages,
  17. const InfallibleTArray<SubstitutionMapping>& aResources,
  18. const InfallibleTArray<OverrideMapping>& aOverrides,
  19. const nsACString& aLocale,
  20. bool aReset);
  21. NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
  22. nsIUTF8StringEnumerator* *aResult) override;
  23. NS_IMETHOD CheckForNewChrome() override;
  24. NS_IMETHOD CheckForOSAccessibility() override;
  25. NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
  26. const char16_t* aData) override;
  27. NS_IMETHOD IsLocaleRTL(const nsACString& package,
  28. bool *aResult) override;
  29. NS_IMETHOD GetSelectedLocale(const nsACString& aPackage,
  30. bool aAsBCP47,
  31. nsACString& aLocale) override;
  32. NS_IMETHOD GetStyleOverlays(nsIURI *aChromeURL,
  33. nsISimpleEnumerator **aResult) override;
  34. NS_IMETHOD GetXULOverlays(nsIURI *aChromeURL,
  35. nsISimpleEnumerator **aResult) override;
  36. void RegisterPackage(const ChromePackage& aPackage);
  37. void RegisterOverride(const OverrideMapping& aOverride);
  38. void RegisterSubstitution(const SubstitutionMapping& aResource);
  39. private:
  40. struct PackageEntry
  41. {
  42. PackageEntry() : flags(0) { }
  43. ~PackageEntry() { }
  44. nsCOMPtr<nsIURI> contentBaseURI;
  45. nsCOMPtr<nsIURI> localeBaseURI;
  46. nsCOMPtr<nsIURI> skinBaseURI;
  47. uint32_t flags;
  48. };
  49. nsresult UpdateSelectedLocale() override;
  50. nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
  51. const nsCString& aProvider,
  52. const nsCString& aPath) override;
  53. nsresult GetFlagsFromPackage(const nsCString& aPackage, uint32_t* aFlags) override;
  54. nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
  55. nsCString mLocale;
  56. virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
  57. char *const * argv, int flags) override;
  58. virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
  59. char *const * argv, int flags) override;
  60. virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
  61. char *const * argv, int flags) override;
  62. virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
  63. char *const * argv, int flags) override;
  64. virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno,
  65. char *const * argv, int flags) override;
  66. virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
  67. char *const * argv, int flags) override;
  68. virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
  69. char *const * argv, int flags) override;
  70. };
  71. #endif // nsChromeRegistryContent_h