Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwG release 0.1.22.151 #33045

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion third_party/subscriptions-project/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.150 */
/** Version: 0.1.22.151 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down
49 changes: 37 additions & 12 deletions third_party/subscriptions-project/swg-gaa.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.150 */
/** Version: 0.1.22.151 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -651,6 +651,9 @@ const POST_MESSAGE_COMMAND_INTRODUCTION = 'introduction';
/** User command for post messages. */
const POST_MESSAGE_COMMAND_USER = 'user';

/** Error command for post messages. */
const POST_MESSAGE_COMMAND_ERROR = 'error';

/** ID for the Google Sign-In iframe element. */
const GOOGLE_SIGN_IN_IFRAME_ID = 'swg-google-sign-in-iframe';

Expand Down Expand Up @@ -942,10 +945,18 @@ class GaaMeteringRegwall {

GaaMeteringRegwall.render_({iframeUrl});
GaaMeteringRegwall.sendIntroMessageToGsiIframe_({iframeUrl});
return GaaMeteringRegwall.getGaaUser_().then((gaaUser) => {
GaaMeteringRegwall.remove_();
return gaaUser;
});
return GaaMeteringRegwall.getGaaUser_()
.then((gaaUser) => {
GaaMeteringRegwall.remove_();
return gaaUser;
})
.catch((err) => {
// Close the Regwall, since the flow failed.
GaaMeteringRegwall.remove_();

// Rethrow error.
throw err;
});
}

/**
Expand Down Expand Up @@ -1080,13 +1091,18 @@ class GaaMeteringRegwall {
*/
static getGaaUser_() {
// Listen for GAA user.
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
self.addEventListener('message', (e) => {
if (
e.data.stamp === POST_MESSAGE_STAMP &&
e.data.command === POST_MESSAGE_COMMAND_USER
) {
resolve(e.data.gaaUser);
if (e.data.stamp === POST_MESSAGE_STAMP) {
if (e.data.command === POST_MESSAGE_COMMAND_USER) {
// Pass along GAA user.
resolve(e.data.gaaUser);
}

if (e.data.command === POST_MESSAGE_COMMAND_ERROR) {
// Reject promise due to Google Sign-In error.
reject('Google Sign-In failed to initialize');
}
}
});
});
Expand Down Expand Up @@ -1145,7 +1161,7 @@ class GaaGoogleSignInButton {
const styleEl = self.document.createElement('style');
styleEl./*OK*/ innerText = GOOGLE_SIGN_IN_IFRAME_STYLES.replace(
'$SHOWCASE_REGWALL_GOOGLE_SIGN_IN_BUTTON$',
I18N_STRINGS['SHOWCASE_REGWALL_GOOGLE_SIGN_IN_BUTTON'][languageCode]
msg(I18N_STRINGS['SHOWCASE_REGWALL_GOOGLE_SIGN_IN_BUTTON'], languageCode)
);
self.document.head.appendChild(styleEl);

Expand Down Expand Up @@ -1210,6 +1226,15 @@ class GaaGoogleSignInButton {
gaaUser,
});
});
})
.catch(() => {
// Report error to parent frame.
sendMessageToParentFnPromise.then((sendMessageToParent) => {
sendMessageToParent({
stamp: POST_MESSAGE_STAMP,
command: POST_MESSAGE_COMMAND_ERROR,
});
});
});
}
}
Expand Down
Loading