LCOV - code coverage report
Current view: top level - chrome - nsChromeRegistryChrome.h (source / functions) Hit Total Coverage
Test: output.info Lines: 9 14 64.3 %
Date: 2017-07-14 16:53:18 Functions: 7 12 58.3 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
       6             : #ifndef nsChromeRegistryChrome_h
       7             : #define nsChromeRegistryChrome_h
       8             : 
       9             : #include "nsCOMArray.h"
      10             : #include "nsChromeRegistry.h"
      11             : #include "nsTArray.h"
      12             : #include "mozilla/Move.h"
      13             : #include "nsClassHashtable.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : class PContentParent;
      18             : } // namespace dom
      19             : } // namespace mozilla
      20             : 
      21             : class nsIPrefBranch;
      22             : struct ChromePackage;
      23             : 
      24             : class nsChromeRegistryChrome : public nsChromeRegistry
      25             : {
      26             :  public:
      27             :   nsChromeRegistryChrome();
      28             :   ~nsChromeRegistryChrome();
      29             : 
      30             :   nsresult Init() override;
      31             : 
      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;
      43             : 
      44             : #ifdef MOZ_XUL
      45             :   NS_IMETHOD GetXULOverlays(nsIURI *aURI,
      46             :                             nsISimpleEnumerator **_retval) override;
      47             :   NS_IMETHOD GetStyleOverlays(nsIURI *aURI,
      48             :                               nsISimpleEnumerator **_retval) override;
      49             : #endif
      50             : 
      51             :   // If aChild is non-null then it is a new child to notify. If aChild is
      52             :   // null, then we have installed new chrome and we are resetting all of our
      53             :   // children's registered chrome.
      54             :   void SendRegisteredChrome(mozilla::dom::PContentParent* aChild);
      55             : 
      56             :  private:
      57             :   struct PackageEntry;
      58             :   static void ChromePackageFromPackageEntry(const nsACString& aPackageName,
      59             :                                             PackageEntry* aPackage,
      60             :                                             ChromePackage* aChromePackage,
      61             :                                             const nsCString& aSelectedSkin);
      62             : 
      63             :   nsresult OverrideLocalePackage(const nsACString& aPackage,
      64             :                                  nsACString& aOverride);
      65             :   nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
      66             :                                  const nsCString& aProvider,
      67             :                                  const nsCString& aPath) override;
      68             :   nsresult GetFlagsFromPackage(const nsCString& aPackage,
      69             :                                uint32_t* aFlags) override;
      70             : 
      71          78 :   struct ProviderEntry
      72             :   {
      73          39 :     ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
      74             :     provider(aProvider),
      75          39 :     baseURI(aBase) { }
      76             : 
      77             :     nsCString        provider;
      78             :     nsCOMPtr<nsIURI> baseURI;
      79             :   };
      80             : 
      81             :   class nsProviderArray
      82             :   {
      83             :    public:
      84          88 :     nsProviderArray() :
      85          88 :     mArray(1) { }
      86           0 :     ~nsProviderArray() { }
      87             : 
      88             :     // When looking up locales and skins, the "selected" locale is not always
      89             :     // available. This enum identifies what kind of match is desired/found.
      90             :     enum MatchType {
      91             :       EXACT = 0,
      92             :       LOCALE = 1, // "en-GB" is selected, we found "en-US"
      93             :       ANY = 2
      94             :     };
      95             : 
      96             :     nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
      97             :     const nsACString& GetSelected(const nsACString& aPreferred, MatchType aType);
      98             :     void    SetBase(const nsACString& aProvider, nsIURI* base);
      99             :     void    EnumerateToArray(nsTArray<nsCString> *a);
     100             : 
     101             :    private:
     102             :     ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
     103             : 
     104             :     nsTArray<ProviderEntry> mArray;
     105             :   };
     106             : 
     107             :   struct PackageEntry : public PLDHashEntryHdr
     108             :   {
     109          44 :     PackageEntry()
     110          44 :     : flags(0) { }
     111           0 :     ~PackageEntry() { }
     112             : 
     113             :     nsCOMPtr<nsIURI> baseURI;
     114             :     uint32_t         flags;
     115             :     nsProviderArray  locales;
     116             :     nsProviderArray  skins;
     117             :   };
     118             : 
     119             :   class OverlayListEntry : public nsURIHashKey
     120             :   {
     121             :    public:
     122             :     typedef nsURIHashKey::KeyType        KeyType;
     123             :     typedef nsURIHashKey::KeyTypePointer KeyTypePointer;
     124             : 
     125           5 :     explicit OverlayListEntry(KeyTypePointer aKey) : nsURIHashKey(aKey) { }
     126             :     OverlayListEntry(OverlayListEntry&& toMove) : nsURIHashKey(mozilla::Move(toMove)),
     127             :                                                   mArray(mozilla::Move(toMove.mArray)) { }
     128           0 :     ~OverlayListEntry() { }
     129             : 
     130             :     void AddURI(nsIURI* aURI);
     131             : 
     132             :     nsCOMArray<nsIURI> mArray;
     133             :   };
     134             : 
     135             :   class OverlayListHash
     136             :   {
     137             :    public:
     138           2 :     OverlayListHash() { }
     139           0 :     ~OverlayListHash() { }
     140             : 
     141             :     void Add(nsIURI* aBase, nsIURI* aOverlay);
     142           0 :     void Clear() { mTable.Clear(); }
     143             :     const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
     144             : 
     145             :    private:
     146             :     nsTHashtable<OverlayListEntry> mTable;
     147             :   };
     148             : 
     149             :   // Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
     150             :   // to a list of overlays/stylesheets
     151             :   OverlayListHash mOverlayHash;
     152             :   OverlayListHash mStyleHash;
     153             : 
     154             :   bool mProfileLoaded;
     155             :   bool mDynamicRegistration;
     156             : 
     157             :   nsCString mSelectedSkin;
     158             : 
     159             :   // Hash of package names ("global") to PackageEntry objects
     160             :   nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
     161             : 
     162             :   virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
     163             :                                char *const * argv, int flags) override;
     164             :   virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
     165             :                               char *const * argv, int flags) override;
     166             :   virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
     167             :                             char *const * argv, int flags) override;
     168             :   virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
     169             :                                char *const * argv, int flags) override;
     170             :   virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno,
     171             :                              char *const * argv, int flags) override;
     172             :   virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
     173             :                                 char *const * argv, int flags) override;
     174             :   virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
     175             :                                 char *const * argv, int flags) override;
     176             : };
     177             : 
     178             : #endif // nsChromeRegistryChrome_h

Generated by: LCOV version 1.13