Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: remoting/webapp/remoting.js

Issue 468693002: Hangouts remote desktop part III - It2MeService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.');
Jamie 2014/08/14 00:25:06 new Error?
+ });
+ });
+ };
+
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698