зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1356334: Part 4 - Add a helper to synchronously get an extension's name from its ID. r=billm
MozReview-Commit-ID: 8nuvM4PR7XR --HG-- extra : rebase_source : fecadb38ca64afeb83f1b7b999295586e9c55944
This commit is contained in:
Родитель
b23753e90d
Коммит
03b92c5149
|
@ -52,6 +52,12 @@ interface nsIAddonPolicyService : nsISupports
|
|||
*/
|
||||
boolean addonMayLoadURI(in AString aAddonId, in nsIURI aURI, [optional] in boolean aExplicit);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Returns true if a given extension:// URI is web-accessible.
|
||||
*/
|
||||
|
|
|
@ -34,6 +34,12 @@ interface WebExtensionPolicy {
|
|||
[Constant]
|
||||
readonly attribute ByteString baseURL;
|
||||
|
||||
/**
|
||||
* The extension's user-visible name.
|
||||
*/
|
||||
[Constant]
|
||||
readonly attribute DOMString name;
|
||||
|
||||
/**
|
||||
* The content security policy string to apply to all pages loaded from the
|
||||
* extension's moz-extension: protocol.
|
||||
|
@ -142,6 +148,8 @@ dictionary WebExtensionInit {
|
|||
|
||||
required DOMString baseURL;
|
||||
|
||||
DOMString name = "";
|
||||
|
||||
required WebExtensionLocalizeCallback localizeCallback;
|
||||
|
||||
required MatchPatternSet allowedOrigins;
|
||||
|
|
|
@ -993,6 +993,7 @@ this.Extension = class extends ExtensionData {
|
|||
return {
|
||||
id: this.id,
|
||||
uuid: this.uuid,
|
||||
name: this.name,
|
||||
instanceId: this.instanceId,
|
||||
manifest: this.manifest,
|
||||
resourceURL: this.resourceURL,
|
||||
|
|
|
@ -377,6 +377,17 @@ ExtensionPolicyService::AddonMayLoadURI(const nsAString& aAddonId,
|
|||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ExtensionPolicyService::GetExtensionName(const nsAString& aAddonId,
|
||||
nsAString& aName)
|
||||
{
|
||||
if (WebExtensionPolicy* policy = GetByID(aAddonId)) {
|
||||
aName.Assign(policy->Name());
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ExtensionPolicyService::ExtensionURILoadableByAnyone(nsIURI* aURI, bool* aResult)
|
||||
{
|
||||
|
|
|
@ -89,6 +89,7 @@ WebExtensionPolicy::WebExtensionPolicy(GlobalObject& aGlobal,
|
|||
ErrorResult& aRv)
|
||||
: mId(NS_AtomizeMainThread(aInit.mId))
|
||||
, mHostname(aInit.mMozExtensionHostname)
|
||||
, mName(aInit.mName)
|
||||
, mContentSecurityPolicy(aInit.mContentSecurityPolicy)
|
||||
, mLocalizeCallback(aInit.mLocalizeCallback)
|
||||
, mPermissions(new AtomSet(aInit.mPermissions))
|
||||
|
|
|
@ -82,6 +82,15 @@ public:
|
|||
|
||||
void Localize(const nsAString& aInput, nsString& aResult) const;
|
||||
|
||||
const nsString& Name() const
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
void GetName(nsAString& aName) const
|
||||
{
|
||||
aName = mName;
|
||||
}
|
||||
|
||||
const nsString& ContentSecurityPolicy() const
|
||||
{
|
||||
return mContentSecurityPolicy;
|
||||
|
@ -153,6 +162,7 @@ private:
|
|||
nsCString mHostname;
|
||||
nsCOMPtr<nsIURI> mBaseURI;
|
||||
|
||||
nsString mName;
|
||||
nsString mContentSecurityPolicy;
|
||||
|
||||
bool mActive = false;
|
||||
|
|
|
@ -317,6 +317,7 @@ ExtensionManager = {
|
|||
policy = new WebExtensionPolicy({
|
||||
id: extension.id,
|
||||
mozExtensionHostname: extension.uuid,
|
||||
name: extension.name,
|
||||
baseURL: extension.resourceURL,
|
||||
|
||||
permissions: Array.from(extension.permissions),
|
||||
|
|
Загрузка…
Ссылка в новой задаче