mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-10 21:28:04 +02:00
ExtensionContext in Extension.jsm has |extension| as an instance member, so use it instead of passing |extension| to registerSchemaAPI's callback. And to make sure that this pattern also works in content processes, move the |extension| member to BaseContext. MozReview-Commit-ID: BgsGGCPQxJR --HG-- extra : rebase_source : 7aa9fb7a53e057e8d3d8c477bd6821f8344c571a
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
extensions.registerSchemaAPI("extension", context => {
|
|
let {extension} = context;
|
|
return {
|
|
extension: {
|
|
getURL: function(url) {
|
|
return extension.baseURI.resolve(url);
|
|
},
|
|
|
|
getViews: function(fetchProperties) {
|
|
let result = Cu.cloneInto([], context.cloneScope);
|
|
|
|
for (let view of extension.views) {
|
|
if (!view.active) {
|
|
continue;
|
|
}
|
|
if (fetchProperties !== null) {
|
|
if (fetchProperties.type !== null && view.type != fetchProperties.type) {
|
|
continue;
|
|
}
|
|
|
|
if (fetchProperties.windowId !== null && view.windowId != fetchProperties.windowId) {
|
|
continue;
|
|
}
|
|
}
|
|
|
|
result.push(view.contentWindow);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
|
|
get lastError() {
|
|
return context.lastError;
|
|
},
|
|
|
|
get inIncognitoContext() {
|
|
return context.incognito;
|
|
},
|
|
|
|
isAllowedIncognitoAccess() {
|
|
return Promise.resolve(true);
|
|
},
|
|
|
|
isAllowedFileSchemeAccess() {
|
|
return Promise.resolve(false);
|
|
},
|
|
},
|
|
};
|
|
});
|
|
|