2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-12-01 11:44:43 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
#ifndef nsChromeRegistry_h
|
|
|
|
#define nsChromeRegistry_h
|
|
|
|
|
2005-02-23 00:49:45 +03:00
|
|
|
#include "nsIToolkitChromeRegistry.h"
|
2005-02-20 04:47:13 +03:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2005-02-23 00:49:45 +03:00
|
|
|
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsURIHashKey.h"
|
2005-06-01 23:09:44 +04:00
|
|
|
#include "nsInterfaceHashtable.h"
|
2010-06-12 00:13:26 +04:00
|
|
|
#include "nsXULAppAPI.h"
|
2005-02-23 00:49:45 +03:00
|
|
|
|
2011-11-08 21:10:51 +04:00
|
|
|
#include "mozilla/FileLocation.h"
|
2019-11-26 19:41:55 +03:00
|
|
|
#include "mozilla/intl/LocaleService.h"
|
2010-07-02 17:53:19 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowOuter;
|
2013-09-23 21:26:47 +04:00
|
|
|
class nsIPrefBranch;
|
2005-02-23 00:49:45 +03:00
|
|
|
class nsIURL;
|
|
|
|
|
2010-03-11 08:33:00 +03: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.
|
|
|
|
|
2002-07-24 03:30:04 +04:00
|
|
|
// for component registration
|
2004-01-14 21:03:25 +03:00
|
|
|
// {47049e42-1d87-482a-984d-56ae185e367a}
|
2002-07-24 03:30:04 +04:00
|
|
|
#define NS_CHROMEREGISTRY_CID \
|
2004-01-14 21:03:25 +03:00
|
|
|
{ \
|
|
|
|
0x47049e42, 0x1d87, 0x482a, { \
|
|
|
|
0x98, 0x4d, 0x56, 0xae, 0x18, 0x5e, 0x36, 0x7a \
|
|
|
|
} \
|
|
|
|
}
|
2002-07-24 03:30:04 +04:00
|
|
|
|
2005-02-23 00:49:45 +03:00
|
|
|
class nsChromeRegistry : public nsIToolkitChromeRegistry,
|
2001-01-10 23:22:17 +03:00
|
|
|
public nsIObserver,
|
|
|
|
public nsSupportsWeakReference {
|
1999-12-01 11:44:43 +03:00
|
|
|
public:
|
2000-03-21 13:42:22 +03:00
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
// nsIXULChromeRegistry methods:
|
|
|
|
NS_IMETHOD AllowScriptsForPackage(nsIURI* url, bool* _retval) override;
|
|
|
|
NS_IMETHOD AllowContentToAccess(nsIURI* url, bool* _retval) override;
|
2015-02-05 19:09:15 +03:00
|
|
|
NS_IMETHOD CanLoadURLRemotely(nsIURI* url, bool* _retval) override;
|
|
|
|
NS_IMETHOD MustLoadURLRemotely(nsIURI* url, bool* _retval) override;
|
2000-03-21 13:42:22 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ConvertChromeURL(nsIURI* aChromeURI, nsIURI** aResult) override;
|
2001-01-10 23:22:17 +03:00
|
|
|
|
2000-03-21 13:42:22 +03:00
|
|
|
// nsChromeRegistry methods:
|
2011-10-17 18:59:28 +04:00
|
|
|
nsChromeRegistry() : mInitialized(false) {}
|
2010-03-11 08:33:00 +03:00
|
|
|
|
|
|
|
virtual nsresult Init();
|
1999-12-01 11:44:43 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
static already_AddRefed<nsIChromeRegistry> GetService();
|
2005-02-26 00:11:46 +03:00
|
|
|
|
|
|
|
static nsChromeRegistry* gChromeRegistry;
|
|
|
|
|
2018-02-26 22:43:45 +03:00
|
|
|
// This method can change its parameter, so due to thread safety issues
|
|
|
|
// it should only be called for nsCOMPtr<nsIURI> that is on the stack,
|
|
|
|
// unless you know what you are doing.
|
|
|
|
static nsresult Canonify(nsCOMPtr<nsIURI>& aChromeURL);
|
2000-05-19 00:27:37 +04:00
|
|
|
|
1999-12-01 11:44:43 +03:00
|
|
|
protected:
|
2014-06-24 02:40:03 +04:00
|
|
|
virtual ~nsChromeRegistry();
|
|
|
|
|
2004-03-09 22:59:09 +03:00
|
|
|
void FlushSkinCaches();
|
|
|
|
void FlushAllCaches();
|
1999-12-01 11:44:43 +03:00
|
|
|
|
2016-12-09 22:58:57 +03:00
|
|
|
static void LogMessage(const char* aMsg, ...) MOZ_FORMAT_PRINTF(1, 2);
|
2012-08-22 19:56:38 +04:00
|
|
|
static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber,
|
2016-12-09 22:58:57 +03:00
|
|
|
uint32_t flags, const char* aMsg, ...)
|
|
|
|
MOZ_FORMAT_PRINTF(4, 5);
|
2010-03-11 08:33:00 +03:00
|
|
|
|
2010-10-13 23:46:05 +04:00
|
|
|
virtual nsIURI* GetBaseURIFromPackage(const nsCString& aPackage,
|
|
|
|
const nsCString& aProvider,
|
|
|
|
const nsCString& aPath) = 0;
|
2010-03-11 08:33:00 +03:00
|
|
|
virtual nsresult GetFlagsFromPackage(const nsCString& aPackage,
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t* aFlags) = 0;
|
2009-11-02 21:04:45 +03:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static nsresult RefreshWindow(nsPIDOMWindowOuter* aWindow);
|
2018-02-26 22:43:45 +03:00
|
|
|
static nsresult GetProviderAndPath(nsIURI* aChromeURL, nsACString& aProvider,
|
2005-02-23 00:49:45 +03:00
|
|
|
nsACString& aPath);
|
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
public:
|
2010-07-01 19:55:57 +04:00
|
|
|
static already_AddRefed<nsChromeRegistry> GetSingleton();
|
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
struct ManifestProcessingContext {
|
2011-11-08 21:10:51 +04:00
|
|
|
ManifestProcessingContext(NSLocationType aType,
|
|
|
|
mozilla::FileLocation& aFile)
|
2010-06-12 00:13:26 +04:00
|
|
|
: mType(aType), mFile(aFile) {}
|
2010-07-02 17:53:19 +04:00
|
|
|
|
2010-06-12 00:13:26 +04:00
|
|
|
~ManifestProcessingContext() {}
|
|
|
|
|
|
|
|
nsIURI* GetManifestURI();
|
|
|
|
already_AddRefed<nsIURI> ResolveURI(const char* uri);
|
|
|
|
|
|
|
|
NSLocationType mType;
|
2011-11-08 21:10:51 +04:00
|
|
|
mozilla::FileLocation mFile;
|
2010-06-12 00:13:26 +04:00
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
|
|
|
};
|
2005-02-23 00:49:45 +03:00
|
|
|
|
2010-07-01 19:55:57 +04:00
|
|
|
virtual void ManifestContent(ManifestProcessingContext& cx, int lineno,
|
2015-02-05 19:09:15 +03:00
|
|
|
char* const* argv, int flags) = 0;
|
2010-07-01 19:55:57 +04:00
|
|
|
virtual void ManifestLocale(ManifestProcessingContext& cx, int lineno,
|
2015-02-05 19:09:15 +03:00
|
|
|
char* const* argv, int flags) = 0;
|
2010-07-01 19:55:57 +04:00
|
|
|
virtual void ManifestSkin(ManifestProcessingContext& cx, int lineno,
|
2015-02-05 19:09:15 +03:00
|
|
|
char* const* argv, int flags) = 0;
|
2010-07-01 19:55:57 +04:00
|
|
|
virtual void ManifestOverride(ManifestProcessingContext& cx, int lineno,
|
2015-02-05 19:09:15 +03:00
|
|
|
char* const* argv, int flags) = 0;
|
2010-07-01 19:55:57 +04:00
|
|
|
virtual void ManifestResource(ManifestProcessingContext& cx, int lineno,
|
2015-02-05 19:09:15 +03:00
|
|
|
char* const* argv, int flags) = 0;
|
2010-07-01 19:55:57 +04:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
// Available flags
|
|
|
|
enum {
|
|
|
|
// 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 19:09:15 +03:00
|
|
|
CONTENT_ACCESSIBLE = 1 << 2,
|
|
|
|
|
|
|
|
// Package may be loaded remotely
|
|
|
|
REMOTE_ALLOWED = 1 << 3,
|
|
|
|
|
|
|
|
// Package must be loaded remotely
|
|
|
|
REMOTE_REQUIRED = 1 << 4,
|
2005-02-23 00:49:45 +03:00
|
|
|
};
|
2005-02-19 18:35:36 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInitialized;
|
2000-03-21 13:42:22 +03:00
|
|
|
|
2005-06-01 23:09:44 +04:00
|
|
|
// "Override" table (chrome URI string -> real URI)
|
|
|
|
nsInterfaceHashtable<nsURIHashKey, nsIURI> mOverrideTable;
|
1999-12-01 11:44:43 +03:00
|
|
|
};
|
2010-03-11 08:33:00 +03:00
|
|
|
|
|
|
|
#endif // nsChromeRegistry_h
|