~ubuntu-branches/ubuntu/intrepid/xulrunner-1.9/intrepid

« back to all changes in this revision

Viewing changes to mozilla/chrome/src/nsChromeRegistry.h

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack, Alexander Sack, Fabien Tassin
  • Date: 2008-02-13 11:47:21 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080213114721-7om0mgzngvuk9czv
Tags: 1.9~b3+nobinonly-0ubuntu1
* release FIREFOX_3_0b3_RELEASE

[ Alexander Sack ]
* submit patch that ships xpcshell to bugzilla
  - rename debian/patches/ship_xpcshell.patch =>
           debian/patches/bz410617_att295212_ship_xpcshell.patch
  - update debian/patches/series
* fix tooltip in epiphany: previously displayed out of screen bounds
  (LP: #37507)
  - add debian/patches/bz233371_att297343_fix_outofscreen_embed_tooltip.patch
  - update debian/patches/series
* use default upstream gcc tweaks for improved performance - especially of the
  javascript engine
  - update debian/rules
* update global extension/plugin patch to apply cleanly against latest code
  - update debian/patches/bzXXX_gre_extension_plugin_support.patch
* fix pyxpcom build failure introduced by recent commit
  - add debian/patches/bzXXX_fix_pyxpcom_build_failure.patch
  - update debian/patches/series
* add distro independent global install locations for extensions,
  /usr/lib/mozilla/extensions and /usr/share/mozilla/extensions
  - update debian/xulrunner-1.9.dirs
* support embedded tarball layout when either there is a *.tar.bz2 in orig tarball
  or if DEBIAN_MOZCLIENT_EMBEDDED is not unset (you will need this to produce embedded
  tarballs during |get-orig-source|
  - update debian/rules
* bump minimum libnss3-dev build requirements to >= 3.12.0~1.9b3
  - update debian/control
* bump minimum libnspr4-dev build requirements to >= 4.7.0~1.9b3
  - update debian/control

[ Fabien Tassin ]
* Drop patches applied upstream
  - drop debian/patches/bz410617_att295212_ship_xpcshell.patch
  - drop debian/patches/bz404634_att294921.patch
  - drop debian/patches/bz386610_python2.5_ftbfs_amd64.patch
  - drop debian/patches/bz373918_att295042.patch
  - drop debian/patches/bz408062_unstable_pc.patch
  - drop debian/patches/bz384304_fix_recursive_symlinks.patch
  - update debian/patches/series
* Refresh diverged patches:
  - update debian/patches/bzXXX_pc_honour_system_nspr_nss.patch
  - update debian/patches/rename_venkman_addon.patch
  - update debian/patches/bz344818_cairo_xrender.patch
* Install links for all .so libs in the -dev package
  - update debian/patches/dont_install_so_in_dev.patch
* Bump gtk requirement to 2.12 as per Mozilla bug 412432
  - update debian/control
* Add #DEBHELPER# token to postinst/prerm scripts
  - update debian/xulrunner-1.9.{postinst,prerm}
* Install previously missed libdbusservice.so
  - update debian/xulrunner-1.9.install
* Update venkman patch to also rename locales
  - update debian/patches/rename_venkman_addon.patch
* Bump requirement for system cairo to >= 1.5.8 as we now need
  the newly added cairo_path_extents()
  - update debian/rules
* Include mozilla-devscripts file using -include so ifneq could be omitted
  - update debian/rules
* Fix missing .so symlinks regression
  - update debian/patches/dont_install_so_in_dev.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C++; tab-width: 2; 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
 
 * Netscape Communications Corporation.
19
 
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 
 * the Initial Developer. All Rights Reserved.
21
 
 *
22
 
 * Contributor(s):
23
 
 *   Original Author: David W. Hyatt (hyatt@netscape.com)
24
 
 *   Benjamin Smedberg <benjamin@smedbergs.us>
25
 
 *
26
 
 * Alternatively, the contents of this file may be used under the terms of
27
 
 * either the GNU General Public License Version 2 or later (the "GPL"), or
28
 
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
 
 * in which case the provisions of the GPL or the LGPL are applicable instead
30
 
 * of those above. If you wish to allow use of your version of this file only
31
 
 * under the terms of either the GPL or the LGPL, and not to allow others to
32
 
 * use your version of this file under the terms of the MPL, indicate your
33
 
 * decision by deleting the provisions above and replace them with the notice
34
 
 * and other provisions required by the GPL or the LGPL. If you do not delete
35
 
 * the provisions above, a recipient may use your version of this file under
36
 
 * the terms of any one of the MPL, the GPL or the LGPL.
37
 
 *
38
 
 * ***** END LICENSE BLOCK ***** */
39
 
 
40
 
#include "nsIChromeRegistry.h"
41
 
#include "nsIToolkitChromeRegistry.h"
42
 
#include "nsIObserver.h"
43
 
#include "nsWeakReference.h"
44
 
 
45
 
#ifdef MOZ_XUL
46
 
#include "nsIXULOverlayProvider.h"
47
 
#endif
48
 
 
49
 
#include "pldhash.h"
50
 
 
51
 
#include "nsCOMArray.h"
52
 
#include "nsString.h"
53
 
#include "nsTHashtable.h"
54
 
#include "nsURIHashKey.h"
55
 
#include "nsVoidArray.h"
56
 
#include "nsInterfaceHashtable.h"
57
 
 
58
 
struct PRFileDesc;
59
 
class nsIAtom;
60
 
class nsICSSLoader;
61
 
class nsICSSStyleSheet;
62
 
class nsIDOMWindowInternal;
63
 
class nsILocalFile;
64
 
class nsIRDFDataSource;
65
 
class nsIRDFResource;
66
 
class nsIRDFService;
67
 
class nsISimpleEnumerator;
68
 
class nsIURL;
69
 
 
70
 
// for component registration
71
 
// {47049e42-1d87-482a-984d-56ae185e367a}
72
 
#define NS_CHROMEREGISTRY_CID \
73
 
{ 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
74
 
 
75
 
class nsChromeRegistry : public nsIToolkitChromeRegistry,
76
 
#ifdef MOZ_XUL
77
 
                         public nsIXULOverlayProvider,
78
 
#endif
79
 
                         public nsIObserver,
80
 
                         public nsSupportsWeakReference
81
 
{
82
 
public:
83
 
  NS_DECL_ISUPPORTS
84
 
 
85
 
  // nsIChromeRegistry methods:
86
 
  NS_DECL_NSICHROMEREGISTRY
87
 
  NS_DECL_NSIXULCHROMEREGISTRY
88
 
  NS_DECL_NSITOOLKITCHROMEREGISTRY
89
 
 
90
 
#ifdef MOZ_XUL
91
 
  NS_DECL_NSIXULOVERLAYPROVIDER
92
 
#endif
93
 
 
94
 
  NS_DECL_NSIOBSERVER
95
 
 
96
 
  // nsChromeRegistry methods:
97
 
  nsChromeRegistry() : mInitialized(PR_FALSE) { }
98
 
  ~nsChromeRegistry();
99
 
 
100
 
  nsresult Init();
101
 
 
102
 
  static nsChromeRegistry* gChromeRegistry;
103
 
 
104
 
  static nsresult Canonify(nsIURL* aChromeURL);
105
 
 
106
 
protected:
107
 
  nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult);
108
 
 
109
 
  nsresult LoadInstallDataSource();
110
 
  nsresult LoadProfileDataSource();
111
 
 
112
 
  void FlushSkinCaches();
113
 
  void FlushAllCaches();
114
 
 
115
 
private:
116
 
  static nsresult RefreshWindow(nsIDOMWindowInternal* aWindow,
117
 
                                nsICSSLoader* aCSSLoader);
118
 
  static nsresult GetProviderAndPath(nsIURL* aChromeURL,
119
 
                                     nsACString& aProvider, nsACString& aPath);
120
 
 
121
 
#ifdef MOZ_XUL
122
 
  NS_HIDDEN_(void) ProcessProvider(PRFileDesc *fd, nsIRDFService* aRDFs,
123
 
                                   nsIRDFDataSource* ds, nsIRDFResource* aRoot,
124
 
                                   PRBool aIsLocale, const nsACString& aBaseURL);
125
 
  NS_HIDDEN_(void) ProcessOverlays(PRFileDesc *fd, nsIRDFDataSource* ds,
126
 
                                   nsIRDFResource* aRoot,
127
 
                                   const nsCSubstring& aType);
128
 
#endif
129
 
 
130
 
  NS_HIDDEN_(nsresult) ProcessManifest(nsILocalFile* aManifest, PRBool aSkinOnly);
131
 
  NS_HIDDEN_(nsresult) ProcessManifestBuffer(char *aBuffer, PRInt32 aLength, nsILocalFile* aManifest, PRBool aSkinOnly);
132
 
  NS_HIDDEN_(nsresult) ProcessNewChromeFile(nsILocalFile *aListFile, nsIURI* aManifest);
133
 
  NS_HIDDEN_(nsresult) ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength, nsIURI* aManifest);
134
 
 
135
 
public:
136
 
  struct ProviderEntry
137
 
  {
138
 
    ProviderEntry(const nsACString& aProvider, nsIURI* aBase) :
139
 
      provider(aProvider),
140
 
      baseURI(aBase) { }
141
 
 
142
 
    nsCString        provider;
143
 
    nsCOMPtr<nsIURI> baseURI;
144
 
  };
145
 
 
146
 
  class nsProviderArray
147
 
  {
148
 
  public:
149
 
    nsProviderArray() :
150
 
      mArray(1) { }
151
 
    ~nsProviderArray()
152
 
      { Clear(); }
153
 
 
154
 
    // When looking up locales and skins, the "selected" locale is not always
155
 
    // available. This enum identifies what kind of match is desired/found.
156
 
    enum MatchType {
157
 
      EXACT = 0,
158
 
      LOCALE = 1, // "en-GB" is selected, we found "en-US"
159
 
      ANY = 2
160
 
    };
161
 
 
162
 
    nsIURI* GetBase(const nsACString& aPreferred, MatchType aType);
163
 
    const nsACString& GetSelected(const nsACString& aPreferred, MatchType aType);
164
 
    void    SetBase(const nsACString& aProvider, nsIURI* base);
165
 
    void    EnumerateToArray(nsCStringArray *a);
166
 
    void    Clear();
167
 
 
168
 
  private:
169
 
    ProviderEntry* GetProvider(const nsACString& aPreferred, MatchType aType);
170
 
 
171
 
    nsVoidArray mArray;
172
 
  };
173
 
 
174
 
  struct PackageEntry : public PLDHashEntryHdr
175
 
  {
176
 
    PackageEntry(const nsACString& package);
177
 
    ~PackageEntry() { }
178
 
 
179
 
    // Available flags
180
 
    enum {
181
 
      // This is a "platform" package (e.g. chrome://global-platform/).
182
 
      // Appends one of win/ unix/ mac/ to the base URI.
183
 
      PLATFORM_PACKAGE = 1 << 0,
184
 
 
185
 
      // This package should use the new XPCNativeWrappers to separate
186
 
      // content from chrome. This flag is currently unused (because we call
187
 
      // into xpconnect at registration time).
188
 
      XPCNATIVEWRAPPERS = 1 << 1
189
 
    };
190
 
 
191
 
    nsCString        package;
192
 
    nsCOMPtr<nsIURI> baseURI;
193
 
    PRUint32         flags;
194
 
    nsProviderArray  locales;
195
 
    nsProviderArray  skins;
196
 
  };
197
 
 
198
 
private:
199
 
  static PLDHashNumber HashKey(PLDHashTable *table, const void *key);
200
 
  static PRBool        MatchKey(PLDHashTable *table, const PLDHashEntryHdr *entry,
201
 
                                const void *key);
202
 
  static void          ClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry);
203
 
  static PRBool        InitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
204
 
                                 const void *key);
205
 
 
206
 
  static const PLDHashTableOps kTableOps;
207
 
 
208
 
public:
209
 
  class OverlayListEntry : public nsURIHashKey
210
 
  {
211
 
  public:
212
 
    typedef nsURIHashKey::KeyType        KeyType;
213
 
    typedef nsURIHashKey::KeyTypePointer KeyTypePointer;
214
 
 
215
 
    OverlayListEntry(KeyTypePointer aKey) : nsURIHashKey(aKey) { }
216
 
    OverlayListEntry(OverlayListEntry& toCopy) : nsURIHashKey(toCopy),
217
 
                                                 mArray(toCopy.mArray) { }
218
 
    ~OverlayListEntry() { }
219
 
 
220
 
    void AddURI(nsIURI* aURI);
221
 
 
222
 
    nsCOMArray<nsIURI> mArray;
223
 
  };
224
 
 
225
 
  class OverlayListHash
226
 
  {
227
 
  public:
228
 
    OverlayListHash() { }
229
 
    ~OverlayListHash() { }
230
 
 
231
 
    PRBool Init() { return mTable.Init(); }
232
 
    void Add(nsIURI* aBase, nsIURI* aOverlay);
233
 
    void Clear() { mTable.Clear(); }
234
 
    const nsCOMArray<nsIURI>* GetArray(nsIURI* aBase);
235
 
 
236
 
  private:
237
 
    nsTHashtable<OverlayListEntry> mTable;
238
 
  };
239
 
 
240
 
private:
241
 
  PRBool mInitialized;
242
 
 
243
 
  // Hash of package names ("global") to PackageEntry objects
244
 
  PLDHashTable mPackagesHash;
245
 
 
246
 
  // Hashes on the file to be overlaid (chrome://browser/content/browser.xul)
247
 
  // to a list of overlays/stylesheets
248
 
  OverlayListHash mOverlayHash;
249
 
  OverlayListHash mStyleHash;
250
 
 
251
 
  // "Override" table (chrome URI string -> real URI)
252
 
  nsInterfaceHashtable<nsURIHashKey, nsIURI> mOverrideTable;
253
 
 
254
 
  nsCString mSelectedLocale;
255
 
  nsCString mSelectedSkin;
256
 
};