LCOV - code coverage report
Current view: directory - chrome/src - nsChromeRegistryChrome.h (source / functions) Found Hit Coverage
Test: app.info Lines: 16 16 100.0 %
Date: 2012-06-02 Functions: 12 12 100.0 %

       1                 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * the Mozilla Foundation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 2010
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *   Josh Matthews <josh@joshmatthews.net> (Initial Developer)
      24                 :  *
      25                 :  * Alternatively, the contents of this file may be used under the terms of
      26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
      27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      29                 :  * of those above. If you wish to allow use of your version of this file only
      30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      31                 :  * use your version of this file under the terms of the MPL, indicate your
      32                 :  * decision by deleting the provisions above and replace them with the notice
      33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      34                 :  * the provisions above, a recipient may use your version of this file under
      35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      36                 :  *
      37                 :  * ***** END LICENSE BLOCK ***** */
      38                 : 
      39                 : #ifndef nsChromeRegistryChrome_h
      40                 : #define nsChromeRegistryChrome_h
      41                 : 
      42                 : #include "nsChromeRegistry.h"
      43                 : 
      44                 : namespace mozilla {
      45                 : namespace dom {
      46                 : class PContentParent;
      47                 : }
      48                 : }
      49                 : 
      50                 : class nsIPrefBranch;
      51                 : 
      52                 : class nsChromeRegistryChrome : public nsChromeRegistry
      53                 : {
      54                 :  public:
      55                 :   nsChromeRegistryChrome();
      56                 :   ~nsChromeRegistryChrome();
      57                 : 
      58                 :   NS_OVERRIDE nsresult Init();
      59                 : 
      60                 :   NS_OVERRIDE NS_IMETHOD CheckForNewChrome();
      61                 :   NS_OVERRIDE NS_IMETHOD CheckForOSAccessibility();
      62                 :   NS_OVERRIDE NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
      63                 :                                               nsIUTF8StringEnumerator* *aResult);
      64                 :   NS_OVERRIDE NS_IMETHOD IsLocaleRTL(const nsACString& package,
      65                 :                                      bool *aResult);
      66                 :   NS_OVERRIDE NS_IMETHOD GetSelectedLocale(const nsACString& aPackage,
      67                 :                                            nsACString& aLocale);
      68                 :   NS_OVERRIDE NS_IMETHOD Observe(nsISupports *aSubject, const char *aTopic,
      69                 :                                  const PRUnichar *someData);
      70                 : 
      71                 : #ifdef MOZ_XUL
      72                 :   NS_OVERRIDE NS_IMETHOD GetXULOverlays(nsIURI *aURI,
      73                 :                                         nsISimpleEnumerator **_retval);
      74                 :   NS_OVERRIDE NS_IMETHOD GetStyleOverlays(nsIURI *aURI,
      75                 :                                           nsISimpleEnumerator **_retval);
      76                 : #endif
      77                 :   
      78                 :   void SendRegisteredChrome(mozilla::dom::PContentParent* aChild);
      79                 : 
      80                 :  private:
      81                 :   static PLDHashOperator CollectPackages(PLDHashTable *table,
      82                 :                                          PLDHashEntryHdr *entry,
      83                 :                                          PRUint32 number, void *arg);
      84                 : 
      85                 :   nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);
      86                 :   NS_OVERRIDE nsresult UpdateSelectedLocale();
      87                 :   NS_OVERRIDE nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
      88                 :                                              const nsCString& aProvider,
      89                 :                                              const nsCString& aPath);
      90                 :   NS_OVERRIDE nsresult GetFlagsFromPackage(const nsCString& aPackage,
      91                 :                                            PRUint32* aFlags);
      92                 : 
      93                 :   static const PLDHashTableOps kTableOps;
      94                 :   static PLDHashNumber HashKey(PLDHashTable *table, const void *key);
      95                 :   static bool          MatchKey(PLDHashTable *table, const PLDHashEntryHdr *entry,
      96                 :                                 const void *key);
      97                 :   static void          ClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry);
      98                 :   static bool          InitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
      99                 :                                  const void *key);
     100                 : 
     101                 :   struct ProviderEntry
     102           35747 :   {
     103           35747 :     ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
     104                 :     provider(aProvider),
     105           35747 :     baseURI(aBase) { }
     106                 : 
     107                 :     nsCString        provider;
     108                 :     nsCOMPtr<nsIURI> baseURI;
     109                 :   };
     110                 : 
     111                 :   class nsProviderArray
     112                 :   {
     113                 :    public:
     114           74788 :     nsProviderArray() :
     115           74788 :     mArray(1) { }
     116           74788 :     ~nsProviderArray()
     117           74788 :     { Clear(); }
     118                 : 
     119                 :     // When looking up locales and skins, the "selected" locale is not always
     120                 :     // available. This enum identifies what kind of match is desired/found.
     121                 :     enum MatchType {
     122                 :       EXACT = 0,
     123                 :       LOCALE = 1, // "en-GB" is selected, we found "en-US"
     124                 :       ANY = 2
     125                 :     };
     126                 : 
     127                 :     nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
     128                 :     const nsACString& GetSelected(const nsACString& aPreferred, MatchType aType);
     129                 :     void    SetBase(const nsACString& aProvider, nsIURI* base);
     130                 :     void    EnumerateToArray(nsTArray<nsCString> *a);
     131                 :     void    Clear();
     132                 : 
     133                 :    private:
     134                 :     ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
     135                 : 
     136                 :     nsVoidArray mArray;
     137                 :   };
     138                 : 
     139                 :   struct PackageEntry : public PLDHashEntryHdr
     140                 :   {
     141           37394 :     PackageEntry(const nsACString& package)
     142           37394 :     : package(package), flags(0) { }
     143           37394 :     ~PackageEntry() { }
     144                 : 
     145                 :     nsCString        package;
     146                 :     nsCOMPtr<nsIURI> baseURI;
     147                 :     PRUint32         flags;
     148                 :     nsProviderArray  locales;
     149                 :     nsProviderArray  skins;
     150                 :   };
     151                 : 
     152                 :   class OverlayListEntry : public nsURIHashKey
     153                 :   {
     154                 :    public:
     155                 :     typedef nsURIHashKey::KeyType        KeyType;
     156                 :     typedef nsURIHashKey::KeyTypePointer KeyTypePointer;
     157                 : 
     158            8120 :     OverlayListEntry(KeyTypePointer aKey) : nsURIHashKey(aKey) { }
     159                 :     OverlayListEntry(OverlayListEntry& toCopy) : nsURIHashKey(toCopy),
     160                 :                                                  mArray(toCopy.mArray) { }
     161            8120 :     ~OverlayListEntry() { }
     162                 : 
     163                 :     void AddURI(nsIURI* aURI);
     164                 : 
     165                 :     nsCOMArray<nsIURI> mArray;
     166                 :   };
     167                 : 
     168                 :   class OverlayListHash
     169                 :   {
     170                 :    public:
     171            2838 :     OverlayListHash() { }
     172            2838 :     ~OverlayListHash() { }
     173                 : 
     174            2838 :     bool Init() { return mTable.Init(); }
     175                 :     void Add(nsIURI* aBase, nsIURI* aOverlay);
     176             410 :     void Clear() { mTable.Clear(); }
     177                 :     const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
     178                 : 
     179                 :    private:
     180                 :     nsTHashtable<OverlayListEntry> mTable;
     181                 :   };
     182                 : 
     183                 :   // Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
     184                 :   // to a list of overlays/stylesheets
     185                 :   OverlayListHash mOverlayHash;
     186                 :   OverlayListHash mStyleHash;
     187                 : 
     188                 :   bool mProfileLoaded;
     189                 :   
     190                 :   nsCString mSelectedLocale;
     191                 :   nsCString mSelectedSkin;
     192                 : 
     193                 :   // Hash of package names ("global") to PackageEntry objects
     194                 :   PLDHashTable mPackagesHash;
     195                 : 
     196                 :   virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
     197                 :                                char *const * argv, bool platform,
     198                 :                                bool contentaccessible);
     199                 :   virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
     200                 :                               char *const * argv, bool platform,
     201                 :                               bool contentaccessible);
     202                 :   virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
     203                 :                             char *const * argv, bool platform,
     204                 :                             bool contentaccessible);
     205                 :   virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
     206                 :                                char *const * argv, bool platform,
     207                 :                                bool contentaccessible);
     208                 :   virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno,
     209                 :                              char *const * argv, bool platform,
     210                 :                              bool contentaccessible);
     211                 :   virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
     212                 :                                 char *const * argv, bool platform,
     213                 :                                 bool contentaccessible);
     214                 :   virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
     215                 :                                 char *const * argv, bool platform,
     216                 :                                 bool contentaccessible);
     217                 : };
     218                 : 
     219                 : #endif // nsChromeRegistryChrome_h

Generated by: LCOV version 1.7