Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsChromeRegistry_h |
michael@0 | 7 | #define nsChromeRegistry_h |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIToolkitChromeRegistry.h" |
michael@0 | 10 | #include "nsIObserver.h" |
michael@0 | 11 | #include "nsWeakReference.h" |
michael@0 | 12 | |
michael@0 | 13 | #ifdef MOZ_XUL |
michael@0 | 14 | #include "nsIXULOverlayProvider.h" |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | #include "nsString.h" |
michael@0 | 18 | #include "nsURIHashKey.h" |
michael@0 | 19 | #include "nsInterfaceHashtable.h" |
michael@0 | 20 | #include "nsXULAppAPI.h" |
michael@0 | 21 | #include "nsIXPConnect.h" |
michael@0 | 22 | |
michael@0 | 23 | #include "mozilla/FileLocation.h" |
michael@0 | 24 | |
michael@0 | 25 | class nsIDOMWindow; |
michael@0 | 26 | class nsIPrefBranch; |
michael@0 | 27 | class nsIURL; |
michael@0 | 28 | |
michael@0 | 29 | // The chrome registry is actually split between nsChromeRegistryChrome and |
michael@0 | 30 | // nsChromeRegistryContent. The work/data that is common to both resides in |
michael@0 | 31 | // the shared nsChromeRegistry implementation, with operations that only make |
michael@0 | 32 | // sense for one side erroring out in the other. |
michael@0 | 33 | |
michael@0 | 34 | // for component registration |
michael@0 | 35 | // {47049e42-1d87-482a-984d-56ae185e367a} |
michael@0 | 36 | #define NS_CHROMEREGISTRY_CID \ |
michael@0 | 37 | { 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } } |
michael@0 | 38 | |
michael@0 | 39 | class nsChromeRegistry : public nsIToolkitChromeRegistry, |
michael@0 | 40 | #ifdef MOZ_XUL |
michael@0 | 41 | public nsIXULOverlayProvider, |
michael@0 | 42 | #endif |
michael@0 | 43 | public nsIObserver, |
michael@0 | 44 | public nsSupportsWeakReference |
michael@0 | 45 | { |
michael@0 | 46 | public: |
michael@0 | 47 | NS_DECL_ISUPPORTS |
michael@0 | 48 | |
michael@0 | 49 | // nsIXULChromeRegistry methods: |
michael@0 | 50 | NS_IMETHOD ReloadChrome(); |
michael@0 | 51 | NS_IMETHOD RefreshSkins(); |
michael@0 | 52 | NS_IMETHOD AllowScriptsForPackage(nsIURI* url, |
michael@0 | 53 | bool* _retval); |
michael@0 | 54 | NS_IMETHOD AllowContentToAccess(nsIURI* url, |
michael@0 | 55 | bool* _retval); |
michael@0 | 56 | |
michael@0 | 57 | // nsIChromeRegistry methods: |
michael@0 | 58 | NS_IMETHOD_(bool) WrappersEnabled(nsIURI *aURI); |
michael@0 | 59 | NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult); |
michael@0 | 60 | |
michael@0 | 61 | // nsChromeRegistry methods: |
michael@0 | 62 | nsChromeRegistry() : mInitialized(false) { } |
michael@0 | 63 | virtual ~nsChromeRegistry(); |
michael@0 | 64 | |
michael@0 | 65 | virtual nsresult Init(); |
michael@0 | 66 | |
michael@0 | 67 | static already_AddRefed<nsIChromeRegistry> GetService(); |
michael@0 | 68 | |
michael@0 | 69 | static nsChromeRegistry* gChromeRegistry; |
michael@0 | 70 | |
michael@0 | 71 | static nsresult Canonify(nsIURL* aChromeURL); |
michael@0 | 72 | |
michael@0 | 73 | protected: |
michael@0 | 74 | void FlushSkinCaches(); |
michael@0 | 75 | void FlushAllCaches(); |
michael@0 | 76 | |
michael@0 | 77 | // Update the selected locale used by the chrome registry, and fire a |
michael@0 | 78 | // notification about this change |
michael@0 | 79 | virtual nsresult UpdateSelectedLocale() = 0; |
michael@0 | 80 | |
michael@0 | 81 | static void LogMessage(const char* aMsg, ...); |
michael@0 | 82 | static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags, |
michael@0 | 83 | const char* aMsg, ...); |
michael@0 | 84 | |
michael@0 | 85 | virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage, |
michael@0 | 86 | const nsCString& aProvider, |
michael@0 | 87 | const nsCString& aPath) = 0; |
michael@0 | 88 | virtual nsresult GetFlagsFromPackage(const nsCString& aPackage, |
michael@0 | 89 | uint32_t* aFlags) = 0; |
michael@0 | 90 | |
michael@0 | 91 | nsresult SelectLocaleFromPref(nsIPrefBranch* prefs); |
michael@0 | 92 | |
michael@0 | 93 | static nsresult RefreshWindow(nsIDOMWindow* aWindow); |
michael@0 | 94 | static nsresult GetProviderAndPath(nsIURL* aChromeURL, |
michael@0 | 95 | nsACString& aProvider, nsACString& aPath); |
michael@0 | 96 | |
michael@0 | 97 | public: |
michael@0 | 98 | static already_AddRefed<nsChromeRegistry> GetSingleton(); |
michael@0 | 99 | |
michael@0 | 100 | struct ManifestProcessingContext |
michael@0 | 101 | { |
michael@0 | 102 | ManifestProcessingContext(NSLocationType aType, mozilla::FileLocation &aFile) |
michael@0 | 103 | : mType(aType) |
michael@0 | 104 | , mFile(aFile) |
michael@0 | 105 | { } |
michael@0 | 106 | |
michael@0 | 107 | ~ManifestProcessingContext() |
michael@0 | 108 | { } |
michael@0 | 109 | |
michael@0 | 110 | nsIURI* GetManifestURI(); |
michael@0 | 111 | nsIXPConnect* GetXPConnect(); |
michael@0 | 112 | |
michael@0 | 113 | already_AddRefed<nsIURI> ResolveURI(const char* uri); |
michael@0 | 114 | |
michael@0 | 115 | NSLocationType mType; |
michael@0 | 116 | mozilla::FileLocation mFile; |
michael@0 | 117 | nsCOMPtr<nsIURI> mManifestURI; |
michael@0 | 118 | nsCOMPtr<nsIXPConnect> mXPConnect; |
michael@0 | 119 | }; |
michael@0 | 120 | |
michael@0 | 121 | virtual void ManifestContent(ManifestProcessingContext& cx, int lineno, |
michael@0 | 122 | char *const * argv, bool platform, |
michael@0 | 123 | bool contentaccessible) = 0; |
michael@0 | 124 | virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno, |
michael@0 | 125 | char *const * argv, bool platform, |
michael@0 | 126 | bool contentaccessible) = 0; |
michael@0 | 127 | virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno, |
michael@0 | 128 | char *const * argv, bool platform, |
michael@0 | 129 | bool contentaccessible) = 0; |
michael@0 | 130 | virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno, |
michael@0 | 131 | char *const * argv, bool platform, |
michael@0 | 132 | bool contentaccessible) = 0; |
michael@0 | 133 | virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno, |
michael@0 | 134 | char *const * argv, bool platform, |
michael@0 | 135 | bool contentaccessible) = 0; |
michael@0 | 136 | virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno, |
michael@0 | 137 | char *const * argv, bool platform, |
michael@0 | 138 | bool contentaccessible) = 0; |
michael@0 | 139 | virtual void ManifestResource(ManifestProcessingContext& cx, int lineno, |
michael@0 | 140 | char *const * argv, bool platform, |
michael@0 | 141 | bool contentaccessible) = 0; |
michael@0 | 142 | |
michael@0 | 143 | // Available flags |
michael@0 | 144 | enum { |
michael@0 | 145 | // This is a "platform" package (e.g. chrome://global-platform/). |
michael@0 | 146 | // Appends one of win/ unix/ mac/ to the base URI. |
michael@0 | 147 | PLATFORM_PACKAGE = 1 << 0, |
michael@0 | 148 | |
michael@0 | 149 | // This package should use the new XPCNativeWrappers to separate |
michael@0 | 150 | // content from chrome. This flag is currently unused (because we call |
michael@0 | 151 | // into xpconnect at registration time). |
michael@0 | 152 | XPCNATIVEWRAPPERS = 1 << 1, |
michael@0 | 153 | |
michael@0 | 154 | // Content script may access files in this package |
michael@0 | 155 | CONTENT_ACCESSIBLE = 1 << 2 |
michael@0 | 156 | }; |
michael@0 | 157 | |
michael@0 | 158 | bool mInitialized; |
michael@0 | 159 | |
michael@0 | 160 | // "Override" table (chrome URI string -> real URI) |
michael@0 | 161 | nsInterfaceHashtable<nsURIHashKey, nsIURI> mOverrideTable; |
michael@0 | 162 | }; |
michael@0 | 163 | |
michael@0 | 164 | #endif // nsChromeRegistry_h |