michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsChromeRegistry_h michael@0: #define nsChromeRegistry_h michael@0: michael@0: #include "nsIToolkitChromeRegistry.h" michael@0: #include "nsIObserver.h" michael@0: #include "nsWeakReference.h" michael@0: michael@0: #ifdef MOZ_XUL michael@0: #include "nsIXULOverlayProvider.h" michael@0: #endif michael@0: michael@0: #include "nsString.h" michael@0: #include "nsURIHashKey.h" michael@0: #include "nsInterfaceHashtable.h" michael@0: #include "nsXULAppAPI.h" michael@0: #include "nsIXPConnect.h" michael@0: michael@0: #include "mozilla/FileLocation.h" michael@0: michael@0: class nsIDOMWindow; michael@0: class nsIPrefBranch; michael@0: class nsIURL; michael@0: michael@0: // The chrome registry is actually split between nsChromeRegistryChrome and michael@0: // nsChromeRegistryContent. The work/data that is common to both resides in michael@0: // the shared nsChromeRegistry implementation, with operations that only make michael@0: // sense for one side erroring out in the other. michael@0: michael@0: // for component registration michael@0: // {47049e42-1d87-482a-984d-56ae185e367a} michael@0: #define NS_CHROMEREGISTRY_CID \ michael@0: { 0x47049e42, 0x1d87, 0x482a, { 0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a } } michael@0: michael@0: class nsChromeRegistry : public nsIToolkitChromeRegistry, michael@0: #ifdef MOZ_XUL michael@0: public nsIXULOverlayProvider, michael@0: #endif michael@0: public nsIObserver, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: michael@0: // nsIXULChromeRegistry methods: michael@0: NS_IMETHOD ReloadChrome(); michael@0: NS_IMETHOD RefreshSkins(); michael@0: NS_IMETHOD AllowScriptsForPackage(nsIURI* url, michael@0: bool* _retval); michael@0: NS_IMETHOD AllowContentToAccess(nsIURI* url, michael@0: bool* _retval); michael@0: michael@0: // nsIChromeRegistry methods: michael@0: NS_IMETHOD_(bool) WrappersEnabled(nsIURI *aURI); michael@0: NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult); michael@0: michael@0: // nsChromeRegistry methods: michael@0: nsChromeRegistry() : mInitialized(false) { } michael@0: virtual ~nsChromeRegistry(); michael@0: michael@0: virtual nsresult Init(); michael@0: michael@0: static already_AddRefed GetService(); michael@0: michael@0: static nsChromeRegistry* gChromeRegistry; michael@0: michael@0: static nsresult Canonify(nsIURL* aChromeURL); michael@0: michael@0: protected: michael@0: void FlushSkinCaches(); michael@0: void FlushAllCaches(); michael@0: michael@0: // Update the selected locale used by the chrome registry, and fire a michael@0: // notification about this change michael@0: virtual nsresult UpdateSelectedLocale() = 0; michael@0: michael@0: static void LogMessage(const char* aMsg, ...); michael@0: static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags, michael@0: const char* aMsg, ...); michael@0: michael@0: virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage, michael@0: const nsCString& aProvider, michael@0: const nsCString& aPath) = 0; michael@0: virtual nsresult GetFlagsFromPackage(const nsCString& aPackage, michael@0: uint32_t* aFlags) = 0; michael@0: michael@0: nsresult SelectLocaleFromPref(nsIPrefBranch* prefs); michael@0: michael@0: static nsresult RefreshWindow(nsIDOMWindow* aWindow); michael@0: static nsresult GetProviderAndPath(nsIURL* aChromeURL, michael@0: nsACString& aProvider, nsACString& aPath); michael@0: michael@0: public: michael@0: static already_AddRefed GetSingleton(); michael@0: michael@0: struct ManifestProcessingContext michael@0: { michael@0: ManifestProcessingContext(NSLocationType aType, mozilla::FileLocation &aFile) michael@0: : mType(aType) michael@0: , mFile(aFile) michael@0: { } michael@0: michael@0: ~ManifestProcessingContext() michael@0: { } michael@0: michael@0: nsIURI* GetManifestURI(); michael@0: nsIXPConnect* GetXPConnect(); michael@0: michael@0: already_AddRefed ResolveURI(const char* uri); michael@0: michael@0: NSLocationType mType; michael@0: mozilla::FileLocation mFile; michael@0: nsCOMPtr mManifestURI; michael@0: nsCOMPtr mXPConnect; michael@0: }; michael@0: michael@0: virtual void ManifestContent(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestOverlay(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestStyle(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: virtual void ManifestResource(ManifestProcessingContext& cx, int lineno, michael@0: char *const * argv, bool platform, michael@0: bool contentaccessible) = 0; michael@0: michael@0: // Available flags michael@0: enum { michael@0: // This is a "platform" package (e.g. chrome://global-platform/). michael@0: // Appends one of win/ unix/ mac/ to the base URI. michael@0: PLATFORM_PACKAGE = 1 << 0, michael@0: michael@0: // This package should use the new XPCNativeWrappers to separate michael@0: // content from chrome. This flag is currently unused (because we call michael@0: // into xpconnect at registration time). michael@0: XPCNATIVEWRAPPERS = 1 << 1, michael@0: michael@0: // Content script may access files in this package michael@0: CONTENT_ACCESSIBLE = 1 << 2 michael@0: }; michael@0: michael@0: bool mInitialized; michael@0: michael@0: // "Override" table (chrome URI string -> real URI) michael@0: nsInterfaceHashtable mOverrideTable; michael@0: }; michael@0: michael@0: #endif // nsChromeRegistry_h