Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Popup/redirect modes #4

Merged
merged 3 commits into from
Dec 15, 2017
Merged

Popup/redirect modes #4

merged 3 commits into from
Dec 15, 2017

Conversation

dvoytenko
Copy link
Contributor

@dvoytenko dvoytenko commented Dec 15, 2017

The popup/redirect are handled by the same API and distinction is mostly managed automatically. It looks like this:

// Should always be called in anticipation of redirect.
activities.onResult('request1', function(port) {
  // Check if activity origin/channel are acceptable.
  // The check depends on the actual activity. In some cases,
  // the payload is not sensitive and origin/verified/secure flags are
  // not relevant. In other cases, origin/verified/secure are very
  // strict. Yet, in some other case, origin is important, but the payload
  // itself can be independently verified and thus verified/secure
  // do not matter.
  if (port.getTargetOrigin() != expectedOrigin ||
      !port.isTargetOriginVerified() ||
      !port.isSecureChannel()) {
    return;
  }
  port.acceptResult().then(function(result) {
    // Handle the result.
  });
});

// Start the activity.
activities.open('request1', 'https://a.com/activity', '_blank', {args: 1});

src/utils.js Outdated

import {ActivityRequestDef} from './activity-types';

let aResolver;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/** @type {Element} ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

src/utils.js Outdated

/**
* @param {string} queryString
* @return {?string}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSDOC for param

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@dvoytenko dvoytenko merged commit df2c827 into google:master Dec 15, 2017
@dvoytenko dvoytenko deleted the popup1 branch December 15, 2017 18:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants