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
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/
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
15
* The Original Code is mozilla.org code.
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.
23
* Original Author: David W. Hyatt (hyatt@netscape.com)
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.
37
* ***** END LICENSE BLOCK ***** */
40
class nsICSSStyleSheet;
42
class nsIRDFDataSource;
45
class nsISimpleEnumerator;
46
class nsSupportsHashtable;
47
class nsIRDFContainer;
48
class nsIRDFContainerUtils;
49
class nsIDOMWindowInternal;
52
#include "nsIChromeRegistry.h"
53
#include "nsIXULOverlayProvider.h"
54
#include "nsIRDFCompositeDataSource.h"
55
#include "nsIObserver.h"
56
#include "nsWeakReference.h"
58
#include "nsIZipReader.h"
59
#include "nsCOMArray.h"
60
#include "nsInterfaceHashtable.h"
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 } }
67
class nsChromeRegistry : public nsIXULChromeRegistry,
68
public nsIXULOverlayProvider,
70
public nsSupportsWeakReference
75
// nsIChromeRegistry methods:
76
NS_DECL_NSICHROMEREGISTRY
77
NS_DECL_NSIXULCHROMEREGISTRY
78
NS_DECL_NSIXULOVERLAYPROVIDER
82
// nsChromeRegistry methods:
84
virtual ~nsChromeRegistry();
89
static nsresult FollowArc(nsIRDFDataSource *aDataSource,
91
nsIRDFResource* aChromeResource,
92
nsIRDFResource* aProperty);
94
static nsresult UpdateArc(nsIRDFDataSource *aDataSource, nsIRDFResource* aSource, nsIRDFResource* aProperty,
95
nsIRDFNode *aTarget, PRBool aRemove);
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);
102
PRBool IsOverlayAllowed(nsIURI *aChromeURI);
104
nsresult GetResource(const nsACString& aChromeType, nsIRDFResource** aResult);
106
nsresult UpdateDynamicDataSource(nsIRDFDataSource *aDataSource,
107
nsIRDFResource *aResource,
108
PRBool aIsOverlay, PRBool
109
aUseProfile, PRBool aRemove);
110
nsresult UpdateDynamicDataSources(nsIRDFDataSource *aDataSource,
112
PRBool aUseProfile, PRBool
114
nsresult WriteInfoToDataSource(const char *aDocURI,
115
const PRUnichar *aOverlayURI,
116
PRBool aIsOverlay, PRBool
117
aUseProfile, PRBool aRemove);
119
nsresult LoadStyleSheetWithURL(nsIURI* aURL, nsICSSStyleSheet** aSheet);
121
nsresult LoadInstallDataSource();
122
nsresult LoadProfileDataSource();
124
void FlushSkinCaches();
125
void FlushAllCaches();
128
nsresult LoadDataSource(const nsACString &aFileName,
129
nsIRDFDataSource **aResult,
130
PRBool aUseProfileDirOnly = PR_FALSE,
131
const char *aProfilePath = nsnull);
133
static nsresult GetProfileRoot(nsACString& aFileURL);
134
static nsresult GetInstallRoot(nsIFile** aFileURL);
136
nsresult RefreshWindow(nsIDOMWindowInternal* aWindow);
138
nsresult GetArcs(nsIRDFDataSource* aDataSource,
139
const nsACString& aType,
140
nsISimpleEnumerator** aResult);
142
nsresult AddToCompositeDataSource(PRBool aUseProfile);
144
nsresult GetBaseURL(const nsACString& aPackage,
145
const nsACString& aProvider,
146
nsACString& aBaseURL);
148
nsresult FindProvider(const nsACString& aPackage,
149
const nsACString& aProvider,
150
nsCOMPtr<nsIRDFResource> &aProviderResource,
151
nsCOMPtr<nsIRDFResource> &aPackageResource);
153
nsresult TrySubProvider(const nsACString& aPackage,
154
nsIRDFResource* aProviderResource,
155
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
157
nsresult FindSubProvider(const nsACString& aPackage,
158
const nsACString& aProvider,
159
nsCOMPtr<nsIRDFResource> &aSelectedProvider);
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);
168
nsresult ProcessNewChromeBuffer(char *aBuffer, PRInt32 aLength);
170
PRBool GetProviderCount(const nsACString& aProviderType, nsIRDFDataSource* aDataSource);
173
nsCString mProfileRoot;
174
nsCString mInstallRoot;
176
nsCOMPtr<nsIRDFCompositeDataSource> mChromeDataSource;
177
nsCOMPtr<nsIRDFDataSource> mInstallDirChromeDataSource;
178
nsCOMPtr<nsIRDFDataSource> mUIDataSource;
180
nsSupportsHashtable* mDataSourceTable;
181
nsIRDFService* mRDFService;
182
nsIRDFContainerUtils* mRDFContainerUtils;
184
nsCString mSelectedLocale;
185
nsCString mSelectedSkin;
187
nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedLocales;
188
nsInterfaceHashtable<nsCStringHashKey, nsIRDFResource> mSelectedSkins;
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;
203
// useful atoms - these are static atoms, so don't use nsCOMPtr
204
static nsIAtom* sCPrefix; // "c"
206
PRPackedBool mInstallInitialized;
207
PRPackedBool mProfileInitialized;
209
// Boolean that indicates we should batch flushes of the main
211
PRPackedBool mBatchInstallFlushes;