| Index: remoting/webapp/remoting.js
|
| diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
|
| index c02a48bda37e80a47f5c4802eaf72827dd565435..f5691c11575651e023fbb41a1e934e8af62e2738 100644
|
| --- a/remoting/webapp/remoting.js
|
| +++ b/remoting/webapp/remoting.js
|
| @@ -133,23 +133,52 @@ remoting.init = function() {
|
| button.disabled = true;
|
| }
|
|
|
| + /**
|
| + * @return {Promise} A promise that resolves to the id of the current
|
| + * containing tab/window.
|
| + */
|
| + var getCurrentId = function () {
|
| + if (remoting.isAppsV2) {
|
| + return Promise.resolve(chrome.app.window.current().id);
|
| + }
|
| +
|
| + /**
|
| + * @param {function(*=):void} resolve
|
| + * @param {function(*=):void} reject
|
| + */
|
| + return new Promise(function(resolve, reject) {
|
| + /** @param {chrome.Tab} tab */
|
| + chrome.tabs.getCurrent(function(tab){
|
| + if (tab) {
|
| + resolve(String(tab.id));
|
| + }
|
| + reject('Cannot retrieve the current tab.');
|
| + });
|
| + });
|
| + };
|
| +
|
| var onLoad = function() {
|
| // Parse URL parameters.
|
| var urlParams = getUrlParameters_();
|
| if ('mode' in urlParams) {
|
| - if (urlParams['mode'] == 'me2me') {
|
| + if (urlParams['mode'] === 'me2me') {
|
| var hostId = urlParams['hostId'];
|
| remoting.connectMe2Me(hostId);
|
| return;
|
| - } else if (urlParams['mode'] == 'hangout') {
|
| - var accessCode = urlParams['accessCode'];
|
| - remoting.ensureSessionConnector_();
|
| - remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| - remoting.connector.connectIT2Me(accessCode);
|
| -
|
| - document.body.classList.add('hangout-remote-desktop');
|
| - var hangoutSession = new remoting.HangoutSession();
|
| - hangoutSession.init();
|
| + } else if (urlParams['mode'] === 'hangout') {
|
| + /** @param {*} id */
|
| + getCurrentId().then(function(id) {
|
| + /** @type {string} */
|
| + var accessCode = urlParams['accessCode'];
|
| + remoting.ensureSessionConnector_();
|
| + remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
|
| + remoting.connector.connectIT2Me(accessCode);
|
| +
|
| + document.body.classList.add('hangout-remote-desktop');
|
| + var senderId = /** @type {string} */ String(id);
|
| + var hangoutSession = new remoting.HangoutSession(senderId);
|
| + hangoutSession.init();
|
| + });
|
| return;
|
| }
|
| }
|
|
|