extensions/amp-web-push/0.1/amp-web-push-permission-dialog.js
/**
   * Requests notification permissions and reports the result back to the AMP
   * page.
   *
   * If this dialog was redirected instead of opened as a pop up, the page is
   * redirected back.
   */
Requests notification permissions and reports the result back to the AMP
page.

If this dialog was redirected instead of opened as a pop up, the page is
redirected back.
Requests notification permissions and reports the result back to the AMP page . If this dialog was redirected instead of opened as a pop up the page is redirected back .
run() {
    if (this.isCurrentDialogPopup()) {
      this.ampMessenger_.connect(opener, '*');
      return this.requestNotificationPermission().then(permission => {
        return this.ampMessenger_.send(
            WindowMessenger.Topics.NOTIFICATION_PERMISSION_STATE,
            permission
        );
      }).then(result => {
        const message = result[0];
        if (message && message.closeFrame) {
          this.window_.close();
        }
      });
    } else {
      const winLocation = this.window_.fakeLocation || this.window_.location;
      const queryParams = parseQueryString(winLocation.search);
      if (!queryParams['return']) {
        throw new Error(
          'Expecting return URL query parameter to redirect back.');
      }
      const redirectLocation = tryDecodeUriComponent(queryParams['return']);
      return this.requestNotificationPermission().then(() => {
        this.redirectToUrl(redirectLocation);
      });
    }
  }
run ( ) { if ( this . isCurrentDialogPopup ( ) ) { this . ampMessenger_ . connect ( opener , '*' ) ; return this . requestNotificationPermission ( ) . then ( permission => { return this . ampMessenger_ . send ( WindowMessenger . Topics . NOTIFICATION_PERMISSION_STATE , permission ) ; } ) . then ( result => { const message = result [ 0 ] ; if ( message && message . closeFrame ) { this . window_ . close ( ) ; } } ) ; } else { const winLocation = this . window_ . fakeLocation || this . window_ . location ; const queryParams = parseQueryString ( winLocation . search ) ; if ( ! queryParams [ 'return' ] ) { throw new Error ( 'Expecting return URL query parameter to redirect back.' ) ; } const redirectLocation = tryDecodeUriComponent ( queryParams [ 'return' ] ) ; return this . requestNotificationPermission ( ) . then ( ( ) => { this . redirectToUrl ( redirectLocation ) ; } ) ; } }
Requests notification permissions and reports the result back to the AMP
 page.
Requests notification permissions and reports the result back to the AMP page .