~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

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: NPL 1.1/GPL 2.0/LGPL 2.1
 
4
 *
 
5
 * The contents of this file are subject to the Netscape Public License
 
6
 * Version 1.1 (the "License"); you may not use this file except in
 
7
 * compliance with the License. You may obtain a copy of the License at
 
8
 * http://www.mozilla.org/NPL/
 
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
 *
 
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 NPL, 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 NPL, the GPL or the LGPL.
 
36
 *
 
37
 * ***** END LICENSE BLOCK ***** */
 
38
 
 
39
class nsIAtom;
 
40
class nsICSSStyleSheet;
 
41
class nsIRDFService;
 
42
class nsIRDFDataSource;
 
43
class nsIRDFResource;
 
44
class nsIRDFNode;
 
45
class nsISimpleEnumerator;
 
46
class nsSupportsHashtable;
 
47
class nsIRDFContainer;
 
48
class nsIRDFContainerUtils;
 
49
class nsIDOMWindowInternal;
 
50
class nsIDocument;
 
51
 
 
52
#include "nsIChromeRegistry.h"
 
53
#include "nsIXULOverlayProvider.h"
 
54
#include "nsIRDFCompositeDataSource.h"
 
55
#include "nsIObserver.h"
 
56
#include "nsWeakReference.h"
 
57
#include "nsString.h"
 
58
#include "nsIZipReader.h"
 
59
#include "nsCOMArray.h"
 
60
#include "nsInterfaceHashtable.h"
 
61
     
 
62
// for component registration
 
63
// {47049e42-1d87-482a-984d-56ae185e367a}
 
64
#define NS_CHROMEREGISTRY_CID \
 
65
{ 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } }
 
66
 
 
67
class nsChromeRegistry : public nsIXULChromeRegistry,
 
68
                         public nsIXULOverlayProvider,
 
69
                         public nsIObserver,
 
70
                         public nsSupportsWeakReference
 
71
{
 
72
public:
 
73
  NS_DECL_ISUPPORTS
 
74
 
 
75
  // nsIChromeRegistry methods:
 
76
  NS_DECL_NSICHROMEREGISTRY
 
77
  NS_DECL_NSIXULCHROMEREGISTRY
 
78
  NS_DECL_NSIXULOVERLAYPROVIDER
 
79
 
 
80
  NS_DECL_NSIOBSERVER
 
81
 
 
82
  // nsChromeRegistry methods:
 
83
  nsChromeRegistry();
 
84
  virtual ~nsChromeRegistry();
 
85
 
 
86
  nsresult Init();
 
87
 
 
88
public:
 
89
  static nsresult FollowArc(nsIRDFDataSource *aDataSource,
 
90
                            nsACString& aResult,
 
91
                            nsIRDFResource* aChromeResource,
 
92
                            nsIRDFResource* aProperty);
 
93
 
 
94
  static nsresult UpdateArc(nsIRDFDataSource *aDataSource, nsIRDFResource* aSource, nsIRDFResource* aProperty, 
 
95
                            nsIRDFNode *aTarget, PRBool aRemove);
 
96
 
 
97
protected:
 
98
  nsresult GetDynamicDataSource(nsIURI *aChromeURL, PRBool aIsOverlay, PRBool aUseProfile, PRBool aCreateDS, nsIRDFDataSource **aResult);
 
99
  nsresult GetURIList(nsIRDFDataSource *aDS, nsIRDFResource *aResource, nsCOMArray<nsIURI>& aArray);
 
100
  nsresult GetDynamicInfo(nsIURI *aChromeURL, PRBool aIsOverlay, nsISimpleEnumerator **aResult);
 
101
 
 
102
  PRBool   IsOverlayAllowed(nsIURI *aChromeURI);
 
103
 
 
104
  nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult);
 
105
  
 
106
  nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource,
 
107
                                   nsIRDFResource *aResource,
 
108
                                   PRBool aIsOverlay, PRBool
 
109
                                   aUseProfile, PRBool aRemove);
 
110
  nsresult UpdateDynamicDataSources(nsIRDFDataSource *aDataSource,
 
111
                                    PRBool aIsOverlay,
 
112
                                    PRBool aUseProfile, PRBool
 
113
                                    aRemove);
 
114
  nsresult WriteInfoToDataSource(const char *aDocURI,
 
115
                                 const PRUnichar *aOverlayURI,
 
116
                                 PRBool aIsOverlay, PRBool
 
117
                                 aUseProfile, PRBool aRemove);
 
118
 
 
119
  nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
 
120
 
 
121
  nsresult LoadInstallDataSource();
 
122
  nsresult LoadProfileDataSource();
 
123
 
 
124
  void FlushSkinCaches();
 
125
  void FlushAllCaches();
 
126
 
 
127
private:
 
128
  nsresult LoadDataSource(const nsACString &aFileName,
 
129
                          nsIRDFDataSource **aResult,
 
130
                          PRBool aUseProfileDirOnly = PR_FALSE,
 
131
                          const char *aProfilePath = nsnull);
 
132
 
 
133
  static nsresult GetProfileRoot(nsACString& aFileURL);
 
134
  static nsresult GetInstallRoot(nsIFile** aFileURL);
 
135
 
 
136
  nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
 
137
 
 
138
  nsresult GetArcs(nsIRDFDataSource* aDataSource,
 
139
                   const nsACString& aType,
 
140
                   nsISimpleEnumerator** aResult);
 
141
 
 
142
  nsresult AddToCompositeDataSource(PRBool aUseProfile);
 
143
  
 
144
  nsresult GetBaseURL(const nsACString& aPackage,
 
145
                      const nsACString& aProvider, 
 
146
                      nsACString& aBaseURL);
 
147
 
 
148
  nsresult FindProvider(const nsACString& aPackage,
 
149
                        const nsACString& aProvider,
 
150
                        nsCOMPtr<nsIRDFResource> &aProviderResource,
 
151
                        nsCOMPtr<nsIRDFResource> &aPackageResource);
 
152
 
 
153
  nsresult TrySubProvider(const nsACString& aPackage,
 
154
                          nsIRDFResource* aProviderResource,
 
155
                          nsCOMPtr<nsIRDFResource> &aSelectedProvider);
 
156
 
 
157
  nsresult FindSubProvider(const nsACString& aPackage,
 
158
                           const nsACString& aProvider,
 
159
                           nsCOMPtr<nsIRDFResource> &aSelectedProvider);
 
160
 
 
161
  nsresult InstallProvider(const nsACString& aProviderType,
 
162
                             const nsACString& aBaseURL,
 
163
                             PRBool aUseProfile, PRBool aAllowScripts, PRBool aRemove);
 
164
  nsresult UninstallProvider(const nsACString& aProviderType, const nsACString& aProviderName, PRBool aUseProfile);
 
165
  nsresult UninstallFromDynamicDataSource(const nsACString& aPackageName,
 
166
                                          PRBool aIsOverlay, PRBool aUseProfile);
 
167
 
 
168
  nsresult ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength);
 
169
 
 
170
  PRBool GetProviderCount(const nsACString& aProviderType, nsIRDFDataSource* aDataSource);
 
171
 
 
172
protected:
 
173
  nsCString mProfileRoot;
 
174
  nsCString mInstallRoot;
 
175
 
 
176
  nsCOMPtr<nsIRDFCompositeDataSource> mChromeDataSource;
 
177
  nsCOMPtr<nsIRDFDataSource> mInstallDirChromeDataSource;
 
178
  nsCOMPtr<nsIRDFDataSource> mUIDataSource;
 
179
 
 
180
  nsSupportsHashtable* mDataSourceTable;
 
181
  nsIRDFService* mRDFService;
 
182
  nsIRDFContainerUtils* mRDFContainerUtils;
 
183
 
 
184
  nsCString mSelectedLocale;
 
185
  nsCString mSelectedSkin;
 
186
 
 
187
  nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedLocales;
 
188
  nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedSkins;
 
189
 
 
190
  // Resources
 
191
  nsCOMPtr<nsIRDFResource> mBaseURL;
 
192
  nsCOMPtr<nsIRDFResource> mPackages;
 
193
  nsCOMPtr<nsIRDFResource> mPackage;
 
194
  nsCOMPtr<nsIRDFResource> mName;
 
195
  nsCOMPtr<nsIRDFResource> mImage;
 
196
  nsCOMPtr<nsIRDFResource> mLocType;
 
197
  nsCOMPtr<nsIRDFResource> mAllowScripts;
 
198
  nsCOMPtr<nsIRDFResource> mHasOverlays;
 
199
  nsCOMPtr<nsIRDFResource> mHasStylesheets;
 
200
  nsCOMPtr<nsIRDFResource> mDisabled;
 
201
  nsCOMPtr<nsIRDFResource> mPlatformPackage;
 
202
 
 
203
  // useful atoms - these are static atoms, so don't use nsCOMPtr
 
204
  static nsIAtom* sCPrefix;            // "c"
 
205
  
 
206
  PRPackedBool mInstallInitialized;
 
207
  PRPackedBool mProfileInitialized;
 
208
  
 
209
  // Boolean that indicates we should batch flushes of the main
 
210
  // chrome.rdf file.
 
211
  PRPackedBool mBatchInstallFlushes;
 
212
};