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