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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** @suppress {duplicate} */ 7 /** @suppress {duplicate} */
8 var remoting = remoting || {}; 8 var remoting = remoting || {};
9 9
10 /** @type {remoting.HostSession} */ remoting.hostSession = null; 10 /** @type {remoting.HostSession} */ remoting.hostSession = null;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 remoting.initModalDialogs(); 126 remoting.initModalDialogs();
127 127
128 if (isHostModeSupported_()) { 128 if (isHostModeSupported_()) {
129 var noShare = document.getElementById('chrome-os-no-share'); 129 var noShare = document.getElementById('chrome-os-no-share');
130 noShare.parentNode.removeChild(noShare); 130 noShare.parentNode.removeChild(noShare);
131 } else { 131 } else {
132 var button = document.getElementById('share-button'); 132 var button = document.getElementById('share-button');
133 button.disabled = true; 133 button.disabled = true;
134 } 134 }
135 135
136 /**
137 * @return {Promise} A promise that resolves to the id of the current
138 * containing tab/window.
139 */
140 var getCurrentId = function () {
141 if (remoting.isAppsV2) {
142 return Promise.resolve(chrome.app.window.current().id);
143 }
144
145 /**
146 * @param {function(*=):void} resolve
147 * @param {function(*=):void} reject
148 */
149 return new Promise(function(resolve, reject) {
150 /** @param {chrome.Tab} tab */
151 chrome.tabs.getCurrent(function(tab){
152 if (tab) {
153 resolve(String(tab.id));
154 }
155 reject('Cannot retrieve the current tab.');
Jamie 2014/08/14 00:25:06 new Error?
156 });
157 });
158 };
159
136 var onLoad = function() { 160 var onLoad = function() {
137 // Parse URL parameters. 161 // Parse URL parameters.
138 var urlParams = getUrlParameters_(); 162 var urlParams = getUrlParameters_();
139 if ('mode' in urlParams) { 163 if ('mode' in urlParams) {
140 if (urlParams['mode'] == 'me2me') { 164 if (urlParams['mode'] === 'me2me') {
141 var hostId = urlParams['hostId']; 165 var hostId = urlParams['hostId'];
142 remoting.connectMe2Me(hostId); 166 remoting.connectMe2Me(hostId);
143 return; 167 return;
144 } else if (urlParams['mode'] == 'hangout') { 168 } else if (urlParams['mode'] === 'hangout') {
145 var accessCode = urlParams['accessCode']; 169 /** @param {*} id */
146 remoting.ensureSessionConnector_(); 170 getCurrentId().then(function(id) {
147 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); 171 /** @type {string} */
148 remoting.connector.connectIT2Me(accessCode); 172 var accessCode = urlParams['accessCode'];
173 remoting.ensureSessionConnector_();
174 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING);
175 remoting.connector.connectIT2Me(accessCode);
149 176
150 document.body.classList.add('hangout-remote-desktop'); 177 document.body.classList.add('hangout-remote-desktop');
151 var hangoutSession = new remoting.HangoutSession(); 178 var senderId = /** @type {string} */ String(id);
152 hangoutSession.init(); 179 var hangoutSession = new remoting.HangoutSession(senderId);
180 hangoutSession.init();
181 });
153 return; 182 return;
154 } 183 }
155 } 184 }
156 // No valid URL parameters, start up normally. 185 // No valid URL parameters, start up normally.
157 remoting.initHomeScreenUi(); 186 remoting.initHomeScreenUi();
158 } 187 }
159 remoting.hostList.load(onLoad); 188 remoting.hostList.load(onLoad);
160 189
161 // For Apps v1, check the tab type to warn the user if they are not getting 190 // For Apps v1, check the tab type to warn the user if they are not getting
162 // the best keyboard experience. 191 // the best keyboard experience.
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 } 594 }
566 595
567 /** 596 /**
568 * Tests whether we are running on ChromeOS. 597 * Tests whether we are running on ChromeOS.
569 * 598 *
570 * @return {boolean} True if the platform is ChromeOS. 599 * @return {boolean} True if the platform is ChromeOS.
571 */ 600 */
572 remoting.platformIsChromeOS = function() { 601 remoting.platformIsChromeOS = function() {
573 return navigator.userAgent.match(/\bCrOS\b/) != null; 602 return navigator.userAgent.match(/\bCrOS\b/) != null;
574 } 603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698