src/service/extensions-impl.js
/**
   * Install extensions in the child window (friendly iframe). The pre-install
   * callback, if specified, is executed after polyfills have been configured
   * but before the first extension is installed.
   * @param {!Window} childWin
   * @param {!Array<string>} extensionIds
   * @param {function(!Window)=} opt_preinstallCallback
   * @return {!Promise}
   * @restricted
   */
Install extensions in the child window (friendly iframe). The pre-install
callback, if specified, is executed after polyfills have been configured
but before the first extension is installed.
Install extensions in the child window ( friendly iframe ) . The pre - install callback if specified is executed after polyfills have been configured but before the first extension is installed .
installExtensionsInChildWindow(childWin, extensionIds,
      opt_preinstallCallback) {
    const topWin = this.win;
    const parentWin = childWin.frameElement.ownerDocument.defaultView;
    setParentWindow(childWin, parentWin);
    installPolyfillsInChildWindow(childWin);
    installStylesLegacy(childWin.document, cssText,  null,
         true,  'amp-runtime');
    if (opt_preinstallCallback) {
      opt_preinstallCallback(childWin);
    }
    adoptStandardServicesForEmbed(childWin);
    copyBuiltinElementsToChildWindow(topWin, childWin);
    stubLegacyElements(childWin);
    const promises = [];
    extensionIds.forEach(extensionId => {
      if (!LEGACY_ELEMENTS.includes(extensionId)) {
        stubElementIfNotKnown(childWin, extensionId);
      }
      const promise = this.preloadExtension(extensionId).then(extension => {
        extension.services.forEach(service => {
          adoptServiceForEmbedIfEmbeddable(childWin, service);
        });
        let elementPromises = null;
        for (const elementName in extension.elements) {
          const elementDef = extension.elements[elementName];
          const elementPromise = new Promise(resolve => {
            if (elementDef.css) {
              installStylesLegacy(
                  childWin.document,
                  elementDef.css,
                   resolve,
                   false,
                  extensionId);
            } else {
              resolve();
            }
          }).then(() => {
            upgradeOrRegisterElement(
                childWin,
                elementName,
                elementDef.implementationClass);
          });
          if (elementPromises) {
            elementPromises.push(elementPromise);
          } else {
            elementPromises = [elementPromise];
          }
        }
        if (elementPromises) {
          return Promise.all(elementPromises).then(() => extension);
        }
        return extension;
      });
      promises.push(promise);
    });
    return Promise.all(promises);
  }
installExtensionsInChildWindow ( childWin , extensionIds , opt_preinstallCallback ) { const topWin = this . win ; const parentWin = childWin . frameElement . ownerDocument . defaultView ; setParentWindow ( childWin , parentWin ) ; installPolyfillsInChildWindow ( childWin ) ; installStylesLegacy ( childWin . document , cssText , null , true , 'amp-runtime' ) ; if ( opt_preinstallCallback ) { opt_preinstallCallback ( childWin ) ; } adoptStandardServicesForEmbed ( childWin ) ; copyBuiltinElementsToChildWindow ( topWin , childWin ) ; stubLegacyElements ( childWin ) ; const promises = [ ] ; extensionIds . forEach ( extensionId => { if ( ! LEGACY_ELEMENTS . includes ( extensionId ) ) { stubElementIfNotKnown ( childWin , extensionId ) ; } const promise = this . preloadExtension ( extensionId ) . then ( extension => { extension . services . forEach ( service => { adoptServiceForEmbedIfEmbeddable ( childWin , service ) ; } ) ; let elementPromises = null ; for ( const elementName in extension . elements ) { const elementDef = extension . elements [ elementName ] ; const elementPromise = new Promise ( resolve => { if ( elementDef . css ) { installStylesLegacy ( childWin . document , elementDef . css , resolve , false , extensionId ) ; } else { resolve ( ) ; } } ) . then ( ( ) => { upgradeOrRegisterElement ( childWin , elementName , elementDef . implementationClass ) ; } ) ; if ( elementPromises ) { elementPromises . push ( elementPromise ) ; } else { elementPromises = [ elementPromise ] ; } } if ( elementPromises ) { return Promise . all ( elementPromises ) . then ( ( ) => extension ) ; } return extension ; } ) ; promises . push ( promise ) ; } ) ; return Promise . all ( promises ) ; }
Install extensions in the child window (friendly iframe).
Install extensions in the child window ( friendly iframe ) .
// Install necessary polyfills. // Install runtime styles. /* callback */ /* opt_isRuntimeCss */ /* opt_ext */ // Run pre-install callback. // Adopt embeddable services. // Install built-ins and legacy elements. // This will extend automatic upgrade of custom elements from top // window to the child window. // Install CSS. // Adopt embeddable extension services. // Adopt the custom elements. /* completeCallback */ /* isRuntime */