| OLD | NEW |
| 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 Loading... |
| 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 /** @return {Promise} */ |
| 137 var getSenderId = function () { |
| 138 if (remoting.isAppsV2) { |
| 139 return Promise.resolve(chrome.app.window.current().id); |
| 140 } |
| 141 |
| 142 /** |
| 143 * @param {function(*=):void} resolve |
| 144 * @param {function(*=):void} reject |
| 145 */ |
| 146 return new Promise(function(resolve, reject) { |
| 147 /** @param {chrome.Tab} tab */ |
| 148 chrome.tabs.getCurrent(function(tab){ |
| 149 if (tab) { |
| 150 resolve(tab.id); |
| 151 } |
| 152 reject(); |
| 153 }); |
| 154 }); |
| 155 }; |
| 156 |
| 136 var onLoad = function() { | 157 var onLoad = function() { |
| 137 // Parse URL parameters. | 158 // Parse URL parameters. |
| 138 var urlParams = getUrlParameters_(); | 159 var urlParams = getUrlParameters_(); |
| 139 if ('mode' in urlParams) { | 160 if ('mode' in urlParams) { |
| 140 if (urlParams['mode'] == 'me2me') { | 161 if (urlParams['mode'] == 'me2me') { |
| 141 var hostId = urlParams['hostId']; | 162 var hostId = urlParams['hostId']; |
| 142 remoting.connectMe2Me(hostId); | 163 remoting.connectMe2Me(hostId); |
| 143 return; | 164 return; |
| 144 } else if (urlParams['mode'] == 'hangout') { | 165 } else if (urlParams['mode'] == 'hangout') { |
| 145 var accessCode = urlParams['accessCode']; | 166 /** @param {*} id */ |
| 146 remoting.ensureSessionConnector_(); | 167 getSenderId().then(function(id) { |
| 147 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); | 168 /** @type {string} */ |
| 148 remoting.connector.connectIT2Me(accessCode); | 169 var accessCode = urlParams['accessCode']; |
| 170 remoting.ensureSessionConnector_(); |
| 171 remoting.setMode(remoting.AppMode.CLIENT_CONNECTING); |
| 172 remoting.connector.connectIT2Me(accessCode); |
| 149 | 173 |
| 150 document.body.classList.add('hangout-remote-desktop'); | 174 document.body.classList.add('hangout-remote-desktop'); |
| 151 var hangoutSession = new remoting.HangoutSession(); | 175 var senderId = /** @type {string} */ id; |
| 152 hangoutSession.init(); | 176 var hangoutSession = new remoting.HangoutSession(senderId); |
| 177 hangoutSession.init(); |
| 178 }); |
| 153 return; | 179 return; |
| 154 } | 180 } |
| 155 } | 181 } |
| 156 // No valid URL parameters, start up normally. | 182 // No valid URL parameters, start up normally. |
| 157 remoting.initHomeScreenUi(); | 183 remoting.initHomeScreenUi(); |
| 158 } | 184 } |
| 159 remoting.hostList.load(onLoad); | 185 remoting.hostList.load(onLoad); |
| 160 | 186 |
| 161 // For Apps v1, check the tab type to warn the user if they are not getting | 187 // For Apps v1, check the tab type to warn the user if they are not getting |
| 162 // the best keyboard experience. | 188 // the best keyboard experience. |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 591 } |
| 566 | 592 |
| 567 /** | 593 /** |
| 568 * Tests whether we are running on ChromeOS. | 594 * Tests whether we are running on ChromeOS. |
| 569 * | 595 * |
| 570 * @return {boolean} True if the platform is ChromeOS. | 596 * @return {boolean} True if the platform is ChromeOS. |
| 571 */ | 597 */ |
| 572 remoting.platformIsChromeOS = function() { | 598 remoting.platformIsChromeOS = function() { |
| 573 return navigator.userAgent.match(/\bCrOS\b/) != null; | 599 return navigator.userAgent.match(/\bCrOS\b/) != null; |
| 574 } | 600 } |
| OLD | NEW |