Index: remoting/webapp/remoting.js |
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js |
index c02a48bda37e80a47f5c4802eaf72827dd565435..560a28f9a8e6a83cde377420a704e7855f2516a8 100644 |
--- a/remoting/webapp/remoting.js |
+++ b/remoting/webapp/remoting.js |
@@ -133,6 +133,27 @@ remoting.init = function() { |
button.disabled = true; |
} |
+ /** @return {Promise} */ |
+ var getSenderId = 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(tab.id); |
+ } |
+ reject(); |
+ }); |
+ }); |
+ }; |
+ |
var onLoad = function() { |
// Parse URL parameters. |
var urlParams = getUrlParameters_(); |
@@ -142,14 +163,19 @@ remoting.init = function() { |
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(); |
+ /** @param {*} id */ |
+ getSenderId().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} */ id; |
+ var hangoutSession = new remoting.HangoutSession(senderId); |
+ hangoutSession.init(); |
+ }); |
return; |
} |
} |