2015-07-08 03:53:15 +03:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
*
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "nsIURI.idl"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This interface allows the security manager to query custom per-addon security
|
|
|
|
* policy.
|
|
|
|
*/
|
2019-04-21 04:47:00 +03:00
|
|
|
[scriptable, uuid(8a034ef9-9d14-4c5d-8319-06c1ab574baa)]
|
2015-07-08 03:53:15 +03:00
|
|
|
interface nsIAddonPolicyService : nsISupports
|
|
|
|
{
|
2016-04-24 07:29:15 +03:00
|
|
|
/**
|
|
|
|
* Returns the default content security policy which applies to extension
|
|
|
|
* documents which do not specify any custom policies.
|
|
|
|
*/
|
|
|
|
readonly attribute AString defaultCSP;
|
|
|
|
|
|
|
|
/**
|
2021-01-07 17:53:18 +03:00
|
|
|
* Returns the base content security policy which applies to all extension resources.
|
2016-04-24 07:29:15 +03:00
|
|
|
*/
|
2021-01-07 17:53:18 +03:00
|
|
|
AString getBaseCSP(in AString aAddonId);
|
2016-04-24 07:29:15 +03:00
|
|
|
|
2019-11-01 09:02:45 +03:00
|
|
|
/**
|
2021-01-07 17:53:18 +03:00
|
|
|
* Returns the content security policy which applies to documents belonging
|
2019-11-01 09:02:45 +03:00
|
|
|
* to the extension with the given ID. This may be either a custom policy,
|
|
|
|
* if one was supplied, or the default policy if one was not.
|
|
|
|
*/
|
2021-01-07 17:53:18 +03:00
|
|
|
AString getExtensionPageCSP(in AString aAddonId);
|
2019-11-01 09:02:45 +03:00
|
|
|
|
2016-07-12 23:55:14 +03:00
|
|
|
/**
|
|
|
|
* Returns the generated background page as a data-URI, if any. If the addon
|
|
|
|
* does not have an auto-generated background page, an empty string is
|
|
|
|
* returned.
|
|
|
|
*/
|
|
|
|
ACString getGeneratedBackgroundPageUrl(in ACString aAddonId);
|
|
|
|
|
2016-07-09 03:19:17 +03:00
|
|
|
/**
|
|
|
|
* Returns true if the addon was granted the |aPerm| API permission.
|
|
|
|
*/
|
|
|
|
boolean addonHasPermission(in AString aAddonId, in AString aPerm);
|
|
|
|
|
2015-07-08 03:53:15 +03:00
|
|
|
/**
|
|
|
|
* Returns true if unprivileged code associated with the given addon may load
|
2017-02-10 08:08:06 +03:00
|
|
|
* data from |aURI|. If |aExplicit| is true, the <all_urls> permission and
|
|
|
|
* permissive host globs are ignored when checking for a match.
|
2015-07-08 03:53:15 +03:00
|
|
|
*/
|
2017-02-10 08:08:06 +03:00
|
|
|
boolean addonMayLoadURI(in AString aAddonId, in nsIURI aURI, [optional] in boolean aExplicit);
|
2015-07-20 04:42:16 +03:00
|
|
|
|
2017-08-12 07:22:18 +03:00
|
|
|
/**
|
|
|
|
* Returns the name of the WebExtension with the given ID, or the ID string
|
|
|
|
* if no matching add-on can be found.
|
|
|
|
*/
|
|
|
|
AString getExtensionName(in AString aAddonId);
|
|
|
|
|
2015-07-20 04:42:16 +03:00
|
|
|
/**
|
2021-05-14 06:15:15 +03:00
|
|
|
* Returns true if a given extension:// URI is web-accessible and loadable by the source.
|
|
|
|
* This should be called if the protocol flags for the extension URI has URI_WEB_ACCESSIBLE.
|
2015-07-20 04:42:16 +03:00
|
|
|
*/
|
2021-05-14 06:15:15 +03:00
|
|
|
boolean sourceMayLoadExtensionURI(in nsIURI aSourceURI, in nsIURI aExtensionURI);
|
2015-07-21 00:46:58 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps an extension URI to the ID of the addon it belongs to.
|
|
|
|
*/
|
|
|
|
AString extensionURIToAddonId(in nsIURI aURI);
|
2015-07-08 03:53:15 +03:00
|
|
|
};
|
2016-04-24 06:41:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This interface exposes functionality related to add-on content policy
|
|
|
|
* enforcement.
|
|
|
|
*/
|
2019-04-21 04:47:00 +03:00
|
|
|
[scriptable, uuid(7a4fe60b-9131-45f5-83f3-dc63b5d71a5d)]
|
2016-04-24 06:41:14 +03:00
|
|
|
interface nsIAddonContentPolicy : nsISupports
|
|
|
|
{
|
2021-01-19 22:42:41 +03:00
|
|
|
/* options to pass to validateAddonCSP
|
|
|
|
*
|
|
|
|
* Manifest V2 uses CSP_ALLOW_ANY.
|
|
|
|
* In Manifest V3, extension_pages would use CSP_ALLOW_LOCALHOST and
|
|
|
|
* sandbox would use CSP_ALLOW_EVAL.
|
|
|
|
*/
|
|
|
|
const unsigned long CSP_ALLOW_ANY = 0xFFFF;
|
|
|
|
const unsigned long CSP_ALLOW_LOCALHOST = (1<<0);
|
|
|
|
const unsigned long CSP_ALLOW_EVAL = (1<<1);
|
|
|
|
const unsigned long CSP_ALLOW_REMOTE = (1<<2);
|
|
|
|
|
2016-04-24 06:41:14 +03:00
|
|
|
/**
|
|
|
|
* Checks a custom content security policy string, to ensure that it meets
|
|
|
|
* minimum security requirements. Returns null for valid policies, or a
|
|
|
|
* string describing the error for invalid policies.
|
|
|
|
*/
|
2021-01-19 22:42:41 +03:00
|
|
|
AString validateAddonCSP(in AString aPolicyString, in unsigned long aPermittedPolicy);
|
2016-04-24 06:41:14 +03:00
|
|
|
};
|