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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 remoting.showOrHideIT2MeUi(); | 110 remoting.showOrHideIT2MeUi(); |
111 remoting.showOrHideMe2MeUi(); | 111 remoting.showOrHideMe2MeUi(); |
112 | 112 |
113 // The plugin's onFocus handler sends a paste command to |window|, because | 113 // The plugin's onFocus handler sends a paste command to |window|, because |
114 // it can't send one to the plugin element itself. | 114 // it can't send one to the plugin element itself. |
115 window.addEventListener('paste', pluginGotPaste_, false); | 115 window.addEventListener('paste', pluginGotPaste_, false); |
116 window.addEventListener('copy', pluginGotCopy_, false); | 116 window.addEventListener('copy', pluginGotCopy_, false); |
117 | 117 |
118 remoting.initModalDialogs(); | 118 remoting.initModalDialogs(); |
119 | 119 |
120 if (isHostModeSupported_()) { | 120 isHostModeSupported_().then( |
121 var noShare = document.getElementById('chrome-os-no-share'); | 121 /** @param {Boolean} supported */ |
122 noShare.parentNode.removeChild(noShare); | 122 function(supported){ |
123 } else { | 123 if (supported) { |
Jamie
2014/11/03 19:41:34
Part of the responsibility of the init method is t
Jamie
2014/11/03 23:15:11
Given the difficulty in fixing this, the relative
| |
124 var button = document.getElementById('share-button'); | 124 var noShare = document.getElementById('chrome-os-no-share'); |
125 button.disabled = true; | 125 noShare.parentNode.removeChild(noShare); |
126 } | 126 } else { |
127 var button = document.getElementById('share-button'); | |
128 button.disabled = true; | |
129 } | |
130 }); | |
127 | 131 |
128 /** | 132 /** |
129 * @return {Promise} A promise that resolves to the id of the current | 133 * @return {Promise} A promise that resolves to the id of the current |
130 * containing tab/window. | 134 * containing tab/window. |
131 */ | 135 */ |
132 var getCurrentId = function () { | 136 var getCurrentId = function () { |
133 if (base.isAppsV2()) { | 137 if (base.isAppsV2()) { |
134 return Promise.resolve(chrome.app.window.current().id); | 138 return Promise.resolve(chrome.app.window.current().id); |
135 } | 139 } |
136 | 140 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 /** @enum {string} */ | 201 /** @enum {string} */ |
198 remoting.testEvents.Names = { | 202 remoting.testEvents.Names = { |
199 uiModeChanged: 'uiModeChanged' | 203 uiModeChanged: 'uiModeChanged' |
200 }; | 204 }; |
201 remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names)); | 205 remoting.testEvents.defineEvents(base.values(remoting.testEvents.Names)); |
202 | 206 |
203 remoting.ClientPlugin.factory.preloadPlugin(); | 207 remoting.ClientPlugin.factory.preloadPlugin(); |
204 }; | 208 }; |
205 | 209 |
206 /** | 210 /** |
207 * Returns whether or not IT2Me is supported via the host NPAPI plugin. | |
208 * | |
209 * @return {boolean} | |
210 */ | |
211 function isIT2MeSupported_() { | |
212 // Currently, IT2Me on Chromebooks is not supported. | |
213 return !remoting.runningOnChromeOS(); | |
214 } | |
215 | |
216 /** | |
217 * Returns true if the current platform is fully supported. It's only used when | 211 * Returns true if the current platform is fully supported. It's only used when |
218 * we detect that host native messaging components are not installed. In that | 212 * we detect that host native messaging components are not installed. In that |
219 * case the result of this function determines if the webapp should show the | 213 * case the result of this function determines if the webapp should show the |
220 * controls that allow to install and enable Me2Me host. | 214 * controls that allow to install and enable Me2Me host. |
221 * | 215 * |
222 * @return {boolean} | 216 * @return {boolean} |
223 */ | 217 */ |
224 remoting.isMe2MeInstallable = function() { | 218 remoting.isMe2MeInstallable = function() { |
225 // The chromoting host is currently not installable on ChromeOS. | 219 // The chromoting host is currently not installable on ChromeOS. |
226 // For Linux, we have a install package for Ubuntu but not other distros. | 220 // For Linux, we have a install package for Ubuntu but not other distros. |
(...skipping 15 matching lines...) Expand all Loading... | |
242 document.getElementById('get-started-it2me').disabled = false; | 236 document.getElementById('get-started-it2me').disabled = false; |
243 document.getElementById('get-started-me2me').disabled = false; | 237 document.getElementById('get-started-me2me').disabled = false; |
244 }; | 238 }; |
245 | 239 |
246 /** | 240 /** |
247 * initHomeScreenUi is called if the app is not starting up in session mode, | 241 * initHomeScreenUi is called if the app is not starting up in session mode, |
248 * and also if the user cancels pin entry or the connection in session mode. | 242 * and also if the user cancels pin entry or the connection in session mode. |
249 */ | 243 */ |
250 remoting.initHomeScreenUi = function() { | 244 remoting.initHomeScreenUi = function() { |
251 remoting.hostController = new remoting.HostController(); | 245 remoting.hostController = new remoting.HostController(); |
252 document.getElementById('share-button').disabled = !isIT2MeSupported_(); | |
253 remoting.setMode(remoting.AppMode.HOME); | 246 remoting.setMode(remoting.AppMode.HOME); |
254 remoting.hostSetupDialog = | 247 remoting.hostSetupDialog = |
255 new remoting.HostSetupDialog(remoting.hostController); | 248 new remoting.HostSetupDialog(remoting.hostController); |
256 var dialog = document.getElementById('paired-clients-list'); | 249 var dialog = document.getElementById('paired-clients-list'); |
257 var message = document.getElementById('paired-client-manager-message'); | 250 var message = document.getElementById('paired-client-manager-message'); |
258 var deleteAll = document.getElementById('delete-all-paired-clients'); | 251 var deleteAll = document.getElementById('delete-all-paired-clients'); |
259 var close = document.getElementById('close-paired-client-manager-dialog'); | 252 var close = document.getElementById('close-paired-client-manager-dialog'); |
260 var working = document.getElementById('paired-client-manager-dialog-working'); | 253 var working = document.getElementById('paired-client-manager-dialog-working'); |
261 var error = document.getElementById('paired-client-manager-dialog-error'); | 254 var error = document.getElementById('paired-client-manager-dialog-error'); |
262 var noPairedClients = document.getElementById('no-paired-clients'); | 255 var noPairedClients = document.getElementById('no-paired-clients'); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 var event = /** @type {remoting.ClipboardEvent} */ eventUncast; | 387 var event = /** @type {remoting.ClipboardEvent} */ eventUncast; |
395 if (event && event.clipboardData) { | 388 if (event && event.clipboardData) { |
396 if (remoting.clipboard.toOs(event.clipboardData)) { | 389 if (remoting.clipboard.toOs(event.clipboardData)) { |
397 // The default action may overwrite items that we added to clipboardData. | 390 // The default action may overwrite items that we added to clipboardData. |
398 event.preventDefault(); | 391 event.preventDefault(); |
399 } | 392 } |
400 } | 393 } |
401 } | 394 } |
402 | 395 |
403 /** | 396 /** |
404 * Returns whether Host mode is supported on this platform. | 397 * Returns whether Host mode is supported on this platform for It2me. |
405 * | 398 * |
406 * @return {boolean} True if Host mode is supported. | 399 * @return {Promise} Resolves to true if Host mode is supported. |
407 */ | 400 */ |
408 function isHostModeSupported_() { | 401 function isHostModeSupported_() { |
409 // Currently, sharing on Chromebooks is not supported. | 402 if (!remoting.platformIsChromeOS()) { |
410 return !remoting.runningOnChromeOS(); | 403 return Promise.resolve(true); |
404 } | |
405 // Sharing on Chrome OS is currently behind a flag. | |
406 // isInstalled() will return false if the flag is disabled. | |
407 var hostInstaller = new remoting.HostInstaller(); | |
408 return hostInstaller.isInstalled(); | |
411 } | 409 } |
412 | 410 |
413 /** | 411 /** |
414 * @return {Object.<string, string>} The URL parameters. | 412 * @return {Object.<string, string>} The URL parameters. |
415 */ | 413 */ |
416 function getUrlParameters_() { | 414 function getUrlParameters_() { |
417 var result = {}; | 415 var result = {}; |
418 var parts = window.location.search.substring(1).split('&'); | 416 var parts = window.location.search.substring(1).split('&'); |
419 for (var i = 0; i < parts.length; i++) { | 417 for (var i = 0; i < parts.length; i++) { |
420 var pair = parts[i].split('='); | 418 var pair = parts[i].split('='); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 } | 543 } |
546 | 544 |
547 /** | 545 /** |
548 * Tests whether we are running on ChromeOS. | 546 * Tests whether we are running on ChromeOS. |
549 * | 547 * |
550 * @return {boolean} True if the platform is ChromeOS. | 548 * @return {boolean} True if the platform is ChromeOS. |
551 */ | 549 */ |
552 remoting.platformIsChromeOS = function() { | 550 remoting.platformIsChromeOS = function() { |
553 return navigator.userAgent.match(/\bCrOS\b/) != null; | 551 return navigator.userAgent.match(/\bCrOS\b/) != null; |
554 } | 552 } |
OLD | NEW |