@@ -82,13 +82,6 @@ class ExtensionManager {
8282 */
8383 this . pendingWorkers = [ ] ;
8484
85- /**
86- * Map of loaded extension URLs/IDs to sanitized extension info.
87- * @type {Map.<string, ExtensionInfo> }
88- * @private
89- */
90- this . _loadedExtensions = new Map ( ) ;
91-
9285 /**
9386 * Keep a reference to the runtime so we can construct internal extension objects.
9487 * TODO: remove this in favor of extensions accessing the runtime as a service.
@@ -107,19 +100,10 @@ class ExtensionManager {
107100 * `loadExtensionURL` if you need to wait until the extension is truly ready.
108101 * @param {string } extensionID - the ID of the extension.
109102 * @returns {boolean } - true if loaded, false otherwise.
103+ * @deprecated Please use `isExtensionLoaded` on the Runtime instead.
110104 */
111105 isExtensionLoaded ( extensionID ) {
112- return this . _loadedExtensions . has ( extensionID ) ;
113- }
114-
115- /**
116- * Fetch the cached information about an extension. Does not call `getInfo` on the extension
117- * @see {@link isExtensionLoaded } for details about registration timing.
118- * @param {string } extensionID - the ID of the extension.
119- * @return {ExtensionInfo } - cached information about the extension, or `undefined` if the extension is not loaded.
120- */
121- getExtensionInfo ( extensionID ) {
122- return this . _loadedExtensions . get ( extensionID ) ;
106+ return this . runtime . isExtensionLoaded ( extensionID ) ;
123107 }
124108
125109 /**
@@ -133,7 +117,7 @@ class ExtensionManager {
133117 return ;
134118 }
135119
136- if ( this . isExtensionLoaded ( extensionId ) ) {
120+ if ( this . runtime . isExtensionLoaded ( extensionId ) ) {
137121 const message = `Rejecting attempt to load a second extension with ID ${ extensionId } ` ;
138122 log . warn ( message ) ;
139123 return ;
@@ -171,16 +155,17 @@ class ExtensionManager {
171155 * @returns {Promise } resolved once all the extensions have been reinitialized
172156 */
173157 refreshBlocks ( ) {
158+ const loadedExtensions = this . runtime . getLoadedExtensions ( ) ;
174159 const allPromises = [ ] ;
175- this . _loadedExtensions . forEach ( ( extensionInfo , oldId ) => {
160+ loadedExtensions . forEach ( ( extensionInfo , oldId ) => {
176161 const serviceName = extensionInfo . serviceName ;
177162 allPromises . push ( dispatch . call ( serviceName , 'getInfo' )
178163 . then ( info => {
179164 info = this . _prepareExtensionInfo ( serviceName , info ) ;
180- this . _loadedExtensions . set ( info . id , info ) ;
165+ loadedExtensions . set ( info . id , info ) ;
181166 if ( oldId !== info . id ) {
182167 log . warn ( `Extension changed ID from ${ oldId } to ${ info . id } !` ) ;
183- this . _loadedExtensions . delete ( oldId ) ;
168+ loadedExtensions . delete ( oldId ) ;
184169 }
185170 dispatch . call ( 'runtime' , '_refreshExtensionPrimitives' , info ) ;
186171 } )
@@ -244,7 +229,7 @@ class ExtensionManager {
244229 dispatch . setServiceSync ( serviceName , extensionObject ) ;
245230 this . registerExtensionServiceSync ( serviceName ) ;
246231 const extensionInfo = this . _prepareExtensionInfo ( serviceName , rawExtensionInfo ) ;
247- this . _loadedExtensions . set ( extensionInfo . id , extensionInfo ) ;
232+ this . runtime . getLoadedExtensions ( ) . set ( extensionInfo . id , extensionInfo ) ;
248233 }
249234
250235 /**
0 commit comments