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
|
|
|
|
2006-01-25 23:23:24 +03:00
|
|
|
#ifdef MOZ_XUL
|
|
|
|
#include "nsIXULOverlayProvider.h"
|
|
|
|
#endif
|
|
|
|
|
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"
|
|
|
|
#include "nsIXPConnect.h"
|
2005-02-23 00:49:45 +03:00
|
|
|
|
2011-11-08 21:10:51 +04:00
|
|
|
#include "mozilla/FileLocation.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,
|
2006-01-25 23:23:24 +03:00
|
|
|
#ifdef MOZ_XUL
|
2004-01-14 21:03:25 +03:00
|
|
|
public nsIXULOverlayProvider,
|
2006-01-25 23:23:24 +03:00
|
|
|
#endif
|
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:
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ReloadChrome() override;
|
|
|
|
NS_IMETHOD RefreshSkins() override;
|
2010-03-11 08:33:00 +03:00
|
|
|
NS_IMETHOD AllowScriptsForPackage(nsIURI* url,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* _retval) override;
|
2010-03-11 08:33:00 +03:00
|
|
|
NS_IMETHOD AllowContentToAccess(nsIURI* url,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* _retval) override;
|
2015-02-05 19:09:15 +03:00
|
|
|
NS_IMETHOD CanLoadURLRemotely(nsIURI* url,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* _retval) override;
|
2015-02-05 19:09:15 +03:00
|
|
|
NS_IMETHOD MustLoadURLRemotely(nsIURI* url,
|
2015-03-21 19:28:04 +03:00
|
|
|
bool* _retval) override;
|
2000-03-21 13:42:22 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
// nsIChromeRegistry methods:
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) WrappersEnabled(nsIURI *aURI) override;
|
|
|
|
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;
|
|
|
|
|
2005-02-23 00:49:45 +03:00
|
|
|
static nsresult Canonify(nsIURL* 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
|
|
|
|
2010-11-30 17:02:23 +03:00
|
|
|
// Update the selected locale used by the chrome registry, and fire a
|
|
|
|
// notification about this change
|
2011-06-07 23:11:35 +04:00
|
|
|
virtual nsresult UpdateSelectedLocale() = 0;
|
2010-11-30 17:02:23 +03:00
|
|
|
|
2010-03-11 08:33:00 +03:00
|
|
|
static void LogMessage(const char* aMsg, ...);
|
2012-08-22 19:56:38 +04:00
|
|
|
static void LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
|
2010-03-11 08:33:00 +03:00
|
|
|
const char* aMsg, ...);
|
|
|
|
|
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
|
|
|
|
|
|
|
nsresult SelectLocaleFromPref(nsIPrefBranch* prefs);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static nsresult RefreshWindow(nsPIDOMWindowOuter* aWindow);
|
2005-02-23 00:49:45 +03:00
|
|
|
static nsresult GetProviderAndPath(nsIURL* aChromeURL,
|
|
|
|
nsACString& aProvider, nsACString& aPath);
|
|
|
|
|
2015-08-28 10:13:06 +03:00
|
|
|
bool GetDirectionForLocale(const nsACString& aLocale);
|
|
|
|
|
2016-10-28 14:04:06 +03:00
|
|
|
void SanitizeForBCP47(nsACString& aLocale);
|
|
|
|
|
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();
|
|
|
|
nsIXPConnect* GetXPConnect();
|
|
|
|
|
|
|
|
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;
|
|
|
|
nsCOMPtr<nsIXPConnect> mXPConnect;
|
|
|
|
};
|
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 ManifestOverlay(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 ManifestStyle(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 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 19:55:57 +04:00
|
|
|
|
2010-03-11 08:33:00 +03: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 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
|