third_party/subscriptions-project/swg.js
/**
   * Use WebActivitiy to open iframe that's in given container.
   *
   * @param {!Element} container
   * @param {!HTMLIFrameElement} iframe
   * @param {!PaymentDataRequest} paymentDataRequest
   * @return {!Promise<!PaymentData>}
   * @private
   */
Use WebActivitiy to open iframe that's in given container.
Use WebActivitiy to open iframe that ' s in given container .
openIframe_(container, iframe, paymentDataRequest) {
    if (!paymentDataRequest.swg) {
      if (!paymentDataRequest.apiVersion) {
        paymentDataRequest.apiVersion = 1;
      }
    }
    paymentDataRequest.environment = this.environment_;
    let iframeLoadStartTime;
    const trustedUrl = this.getIframeUrl(
      this.environment_,
      window.location.origin
    );
    return this.activities
      .openIframe(iframe, trustedUrl, paymentDataRequest)
      .then((port) => {
        this.port_ = port;
        port.onMessage((payload) => {
          if (payload['type'] !== 'resize' || !this.shouldHandleResizing_) {
            this.savedResizePayload_ = {
              'height': payload['height'],
              'transition': payload['transition'],
            };
            return;
          }
          if (!iframeLoadStartTime) {
            iframeLoadStartTime = Date.now();
          }
          if (
            Date.now() <
            iframeLoadStartTime + IFRAME_SHOW_UP_DURATION_IN_MS
          ) {
            this.setTransition_(
              iframe,
              payload['transition'] + ', ' + IFRAME_SMOOTH_HEIGHT_TRANSITION
            );
          } else {
            this.setTransition_(iframe, payload['transition']);
          }
          iframe.height = payload['height'];
        });
        return  (port.acceptResult());
      })
      .then(
        (result) => {
          this.removeIframeAndContainer_(container, iframe);
          history.back();
          const data =  (result['data']);
          return data;
        },
        (error) => {
          this.removeIframeAndContainer_(container, iframe);
          history.back();
          return Promise.reject(error);
        }
      );
  }
openIframe_ ( container , iframe , paymentDataRequest ) { if ( ! paymentDataRequest . swg ) { if ( ! paymentDataRequest . apiVersion ) { paymentDataRequest . apiVersion = 1 ; } } paymentDataRequest . environment = this . environment_ ; let iframeLoadStartTime ; const trustedUrl = this . getIframeUrl ( this . environment_ , window . location . origin ) ; return this . activities . openIframe ( iframe , trustedUrl , paymentDataRequest ) . then ( ( port ) => { this . port_ = port ; port . onMessage ( ( payload ) => { if ( payload [ 'type' ] !== 'resize' || ! this . shouldHandleResizing_ ) { this . savedResizePayload_ = { 'height' : payload [ 'height' ] , 'transition' : payload [ 'transition' ] , } ; return ; } if ( ! iframeLoadStartTime ) { iframeLoadStartTime = Date . now ( ) ; } if ( Date . now ( ) < iframeLoadStartTime + IFRAME_SHOW_UP_DURATION_IN_MS ) { this . setTransition_ ( iframe , payload [ 'transition' ] + ', ' + IFRAME_SMOOTH_HEIGHT_TRANSITION ) ; } else { this . setTransition_ ( iframe , payload [ 'transition' ] ) ; } iframe . height = payload [ 'height' ] ; } ) ; return ( port . acceptResult ( ) ) ; } ) . then ( ( result ) => { this . removeIframeAndContainer_ ( container , iframe ) ; history . back ( ) ; const data = ( result [ 'data' ] ) ; return data ; } , ( error ) => { this . removeIframeAndContainer_ ( container , iframe ) ; history . back ( ) ; return Promise . reject ( error ) ; } ) ; }
Use WebActivitiy to open iframe that's in given container.
Use WebActivitiy to open iframe that ' s in given container .
// Handle custom resize message. // Save the resize event later after initial animation is finished // b/111310899: Smooth out initial iFrame loading /** @type {!Promise<!Object>} */ /**
         * @param {!Object} result
         * @return {!PaymentData}
         */ // This is only for popping the state we pushed earlier. /** @type {!PaymentData} */ // This is only for popping the state we pushed earlier.