refactor: move extension APIs to session.extensions (#45597)
refactor: move extensions to session.extensions
This commit is contained in:
parent
a63f6143ea
commit
e3f61b465d
14 changed files with 508 additions and 205 deletions
|
@ -24,6 +24,21 @@ Object.freeze(systemPickerVideoSource);
|
|||
|
||||
Session.prototype._init = function () {
|
||||
addIpcDispatchListeners(this);
|
||||
|
||||
if (this.extensions) {
|
||||
const rerouteExtensionEvent = (eventName: string) => {
|
||||
const warn = deprecate.warnOnce(`${eventName} event`, `session.extensions ${eventName} event`);
|
||||
this.extensions.on(eventName as any, (...args: any[]) => {
|
||||
if (this.listenerCount(eventName) !== 0) {
|
||||
warn();
|
||||
this.emit(eventName, ...args);
|
||||
}
|
||||
});
|
||||
};
|
||||
rerouteExtensionEvent('extension-loaded');
|
||||
rerouteExtensionEvent('extension-unloaded');
|
||||
rerouteExtensionEvent('extension-ready');
|
||||
}
|
||||
};
|
||||
|
||||
Session.prototype.fetch = function (input: RequestInfo, init?: RequestInit) {
|
||||
|
@ -67,6 +82,35 @@ Session.prototype.setPreloads = function (preloads) {
|
|||
});
|
||||
};
|
||||
|
||||
Session.prototype.getAllExtensions = deprecate.moveAPI(
|
||||
function (this: Electron.Session) {
|
||||
return this.extensions.getAllExtensions();
|
||||
},
|
||||
'session.getAllExtensions',
|
||||
'session.extensions.getAllExtensions'
|
||||
);
|
||||
Session.prototype.getExtension = deprecate.moveAPI(
|
||||
function (this: Electron.Session, extensionId) {
|
||||
return this.extensions.getExtension(extensionId);
|
||||
},
|
||||
'session.getExtension',
|
||||
'session.extensions.getExtension'
|
||||
);
|
||||
Session.prototype.loadExtension = deprecate.moveAPI(
|
||||
function (this: Electron.Session, path, options) {
|
||||
return this.extensions.loadExtension(path, options);
|
||||
},
|
||||
'session.loadExtension',
|
||||
'session.extensions.loadExtension'
|
||||
);
|
||||
Session.prototype.removeExtension = deprecate.moveAPI(
|
||||
function (this: Electron.Session, extensionId) {
|
||||
return this.extensions.removeExtension(extensionId);
|
||||
},
|
||||
'session.removeExtension',
|
||||
'session.extensions.removeExtension'
|
||||
);
|
||||
|
||||
export default {
|
||||
fromPartition,
|
||||
fromPath,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue