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 nsChromeRegistryContent_h
40 : #define nsChromeRegistryContent_h
41 :
42 : #include "nsChromeRegistry.h"
43 : #include "nsTArray.h"
44 : #include "nsClassHashtable.h"
45 :
46 : class nsCString;
47 : struct ChromePackage;
48 : struct ResourceMapping;
49 : struct OverrideMapping;
50 :
51 : class nsChromeRegistryContent : public nsChromeRegistry
52 0 : {
53 : public:
54 : nsChromeRegistryContent();
55 :
56 : void RegisterRemoteChrome(const nsTArray<ChromePackage>& aPackages,
57 : const nsTArray<ResourceMapping>& aResources,
58 : const nsTArray<OverrideMapping>& aOverrides,
59 : const nsACString& aLocale);
60 :
61 : NS_OVERRIDE NS_IMETHOD GetLocalesForPackage(const nsACString& aPackage,
62 : nsIUTF8StringEnumerator* *aResult);
63 : NS_OVERRIDE NS_IMETHOD CheckForNewChrome();
64 : NS_OVERRIDE NS_IMETHOD CheckForOSAccessibility();
65 : NS_OVERRIDE NS_IMETHOD Observe(nsISupports* aSubject, const char* aTopic,
66 : const PRUnichar* aData);
67 : NS_OVERRIDE NS_IMETHOD IsLocaleRTL(const nsACString& package,
68 : bool *aResult);
69 : NS_OVERRIDE NS_IMETHOD GetSelectedLocale(const nsACString& aPackage,
70 : nsACString& aLocale);
71 : NS_OVERRIDE NS_IMETHOD GetStyleOverlays(nsIURI *aChromeURL,
72 : nsISimpleEnumerator **aResult);
73 : NS_OVERRIDE NS_IMETHOD GetXULOverlays(nsIURI *aChromeURL,
74 : nsISimpleEnumerator **aResult);
75 :
76 : private:
77 : struct PackageEntry
78 : {
79 0 : PackageEntry() : flags(0) { }
80 0 : ~PackageEntry() { }
81 :
82 : nsCOMPtr<nsIURI> contentBaseURI;
83 : nsCOMPtr<nsIURI> localeBaseURI;
84 : nsCOMPtr<nsIURI> skinBaseURI;
85 : PRUint32 flags;
86 : };
87 :
88 : void RegisterPackage(const ChromePackage& aPackage);
89 : void RegisterResource(const ResourceMapping& aResource);
90 : void RegisterOverride(const OverrideMapping& aOverride);
91 :
92 : NS_OVERRIDE nsresult UpdateSelectedLocale();
93 : NS_OVERRIDE nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
94 : const nsCString& aProvider,
95 : const nsCString& aPath);
96 : NS_OVERRIDE nsresult GetFlagsFromPackage(const nsCString& aPackage, PRUint32* aFlags);
97 :
98 : nsClassHashtable<nsCStringHashKey, PackageEntry> mPackagesHash;
99 : nsCString mLocale;
100 :
101 : virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
102 : char *const * argv, bool platform,
103 : bool contentaccessible);
104 : virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
105 : char *const * argv, bool platform,
106 : bool contentaccessible);
107 : virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
108 : char *const * argv, bool platform,
109 : bool contentaccessible);
110 : virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno,
111 : char *const * argv, bool platform,
112 : bool contentaccessible);
113 : virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno,
114 : char *const * argv, bool platform,
115 : bool contentaccessible);
116 : virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
117 : char *const * argv, bool platform,
118 : bool contentaccessible);
119 : virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
120 : char *const * argv, bool platform,
121 : bool contentaccessible);
122 : };
123 :
124 : #endif // nsChromeRegistryContent_h
|