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

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; 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 nsChromeRegistry_h
       7             : #define nsChromeRegistry_h
       8             : 
       9             : #include "nsIToolkitChromeRegistry.h"
      10             : #include "nsIObserver.h"
      11             : #include "nsWeakReference.h"
      12             : 
      13             : #ifdef MOZ_XUL
      14             : #include "nsIXULOverlayProvider.h"
      15             : #endif
      16             : 
      17             : #include "nsString.h"
      18             : #include "nsURIHashKey.h"
      19             : #include "nsInterfaceHashtable.h"
      20             : #include "nsXULAppAPI.h"
      21             : 
      22             : #include "mozilla/FileLocation.h"
      23             : 
      24             : class nsPIDOMWindowOuter;
      25             : class nsIPrefBranch;
      26             : class nsIURL;
      27             : 
      28             : // The chrome registry is actually split between nsChromeRegistryChrome and
      29             : // nsChromeRegistryContent. The work/data that is common to both resides in
      30             : // the shared nsChromeRegistry implementation, with operations that only make
      31             : // sense for one side erroring out in the other.
      32             : 
      33             : // for component registration
      34             : // {47049e42-1d87-482a-984d-56ae185e367a}
      35             : #define NS_CHROMEREGISTRY_CID \
      36             : { 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
      37             : 
      38             : class nsChromeRegistry : public nsIToolkitChromeRegistry,
      39             : #ifdef MOZ_XUL
      40             :                          public nsIXULOverlayProvider,
      41             : #endif
      42             :                          public nsIObserver,
      43             :                          public nsSupportsWeakReference
      44             : {
      45             : public:
      46             :   NS_DECL_ISUPPORTS
      47             : 
      48             :   // nsIXULChromeRegistry methods:
      49             :   NS_IMETHOD ReloadChrome() override;
      50             :   NS_IMETHOD RefreshSkins() override;
      51             :   NS_IMETHOD AllowScriptsForPackage(nsIURI* url,
      52             :                                     bool* _retval) override;
      53             :   NS_IMETHOD AllowContentToAccess(nsIURI* url,
      54             :                                   bool* _retval) override;
      55             :   NS_IMETHOD CanLoadURLRemotely(nsIURI* url,
      56             :                                 bool* _retval) override;
      57             :   NS_IMETHOD MustLoadURLRemotely(nsIURI* url,
      58             :                                  bool* _retval) override;
      59             : 
      60             :   // nsIChromeRegistry methods:
      61             :   NS_IMETHOD_(bool) WrappersEnabled(nsIURI *aURI) override;
      62             :   NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult) override;
      63             : 
      64             :   // nsChromeRegistry methods:
      65           3 :   nsChromeRegistry() : mInitialized(false) { }
      66             : 
      67             :   virtual nsresult Init();
      68             : 
      69             :   static already_AddRefed<nsIChromeRegistry> GetService();
      70             : 
      71             :   static nsChromeRegistry* gChromeRegistry;
      72             : 
      73             :   static nsresult Canonify(nsIURL* aChromeURL);
      74             : 
      75             : protected:
      76             :   virtual ~nsChromeRegistry();
      77             : 
      78             :   void FlushSkinCaches();
      79             :   void FlushAllCaches();
      80             : 
      81             :   static void LogMessage(const char* aMsg, ...)
      82             :     MOZ_FORMAT_PRINTF(1, 2);
      83             :   static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
      84             :                                     const char* aMsg, ...)
      85             :     MOZ_FORMAT_PRINTF(4, 5);
      86             : 
      87             :   virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
      88             :                                         const nsCString& aProvider,
      89             :                                         const nsCString& aPath) = 0;
      90             :   virtual nsresult GetFlagsFromPackage(const nsCString& aPackage,
      91             :                                        uint32_t* aFlags) = 0;
      92             : 
      93             :   static nsresult RefreshWindow(nsPIDOMWindowOuter* aWindow);
      94             :   static nsresult GetProviderAndPath(nsIURL* aChromeURL,
      95             :                                      nsACString& aProvider, nsACString& aPath);
      96             : 
      97             :   bool GetDirectionForLocale(const nsACString& aLocale);
      98             : 
      99             :   void SanitizeForBCP47(nsACString& aLocale);
     100             : 
     101             : public:
     102             :   static already_AddRefed<nsChromeRegistry> GetSingleton();
     103             : 
     104             :   struct ManifestProcessingContext
     105             :   {
     106         311 :     ManifestProcessingContext(NSLocationType aType, mozilla::FileLocation &aFile)
     107         311 :       : mType(aType)
     108         311 :       , mFile(aFile)
     109         311 :     { }
     110             : 
     111         311 :     ~ManifestProcessingContext()
     112         311 :     { }
     113             : 
     114             :     nsIURI* GetManifestURI();
     115             :     already_AddRefed<nsIURI> ResolveURI(const char* uri);
     116             : 
     117             :     NSLocationType mType;
     118             :     mozilla::FileLocation mFile;
     119             :     nsCOMPtr<nsIURI> mManifestURI;
     120             :   };
     121             : 
     122             :   virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
     123             :                                char *const * argv, int flags) = 0;
     124             :   virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
     125             :                               char *const * argv, int flags) = 0;
     126             :   virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
     127             :                             char *const * argv, int flags) = 0;
     128             :   virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
     129             :                                char *const * argv, int flags) = 0;
     130             :   virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno,
     131             :                              char *const * argv, int flags) = 0;
     132             :   virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
     133             :                                 char *const * argv, int flags) = 0;
     134             :   virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
     135             :                                 char *const * argv, int flags) = 0;
     136             : 
     137             :   // Available flags
     138             :   enum {
     139             :     // This package should use the new XPCNativeWrappers to separate
     140             :     // content from chrome. This flag is currently unused (because we call
     141             :     // into xpconnect at registration time).
     142             :     XPCNATIVEWRAPPERS = 1 << 1,
     143             : 
     144             :     // Content script may access files in this package
     145             :     CONTENT_ACCESSIBLE = 1 << 2,
     146             : 
     147             :     // Package may be loaded remotely
     148             :     REMOTE_ALLOWED = 1 << 3,
     149             : 
     150             :     // Package must be loaded remotely
     151             :     REMOTE_REQUIRED = 1 << 4,
     152             :   };
     153             : 
     154             :   bool mInitialized;
     155             : 
     156             :   // "Override" table (chrome URI string -> real URI)
     157             :   nsInterfaceHashtable<nsURIHashKey, nsIURI> mOverrideTable;
     158             : };
     159             : 
     160             : #endif // nsChromeRegistry_h

Generated by: LCOV version 1.13