| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /** | 10 /** |
| 11 * Initialize the host list. | 11 * Initialize the host list. |
| 12 */ | 12 */ |
| 13 remoting.initHostlist_ = function() { | 13 remoting.initHostlist_ = function() { |
| 14 remoting.hostList = new remoting.HostList( | 14 remoting.hostList = new remoting.HostList( |
| 15 document.getElementById('host-list'), | 15 document.getElementById('host-list'), |
| 16 document.getElementById('host-list-empty'), | 16 document.getElementById('host-list-empty'), |
| 17 document.getElementById('host-list-error-message'), | 17 document.getElementById('host-list-error-message'), |
| 18 document.getElementById('host-list-refresh-failed-button'), | 18 document.getElementById('host-list-refresh-failed-button'), |
| 19 document.getElementById('host-list-loading-indicator')); | 19 document.getElementById('host-list-loading-indicator')); |
| 20 | 20 |
| 21 isHostModeSupported_().then( | 21 isHostModeSupported_().then( |
| 22 /** @param {Boolean} supported */ | 22 /** @param {Boolean} supported */ |
| 23 function(supported){ | 23 function(supported) { |
| 24 if (supported) { | 24 if (supported) { |
| 25 var noShare = document.getElementById('chrome-os-no-share'); | 25 var noShare = document.getElementById('unsupported-platform-message'); |
| 26 noShare.parentNode.removeChild(noShare); | 26 noShare.parentNode.removeChild(noShare); |
| 27 } else { | 27 } else { |
| 28 var button = document.getElementById('share-button'); | 28 var button = document.getElementById('share-button'); |
| 29 button.disabled = true; | 29 button.disabled = true; |
| 30 } | 30 } |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @return {Promise} A promise that resolves to the id of the current | 34 * @return {Promise} A promise that resolves to the id of the current |
| 35 * containing tab/window. | 35 * containing tab/window. |
| 36 */ | 36 */ |
| 37 var getCurrentId = function () { | 37 var getCurrentId = function () { |
| 38 if (base.isAppsV2()) { | 38 if (base.isAppsV2()) { |
| 39 return Promise.resolve(chrome.app.window.current().id); | 39 return Promise.resolve(chrome.app.window.current().id); |
| 40 } | 40 } |
| 41 | 41 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 // No valid URL parameters, start up normally. | 83 // No valid URL parameters, start up normally. |
| 84 remoting.initHomeScreenUi(); | 84 remoting.initHomeScreenUi(); |
| 85 } | 85 } |
| 86 remoting.hostList.load(onLoad); | 86 remoting.hostList.load(onLoad); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * Returns whether Host mode is supported on this platform for It2me. | 90 * Returns whether Host mode is supported on this platform for It2Me. |
| 91 * TODO(kelvinp): Remove this function once It2me is enabled on Chrome OS (See | |
| 92 * crbug.com/429860). | |
| 93 * | 91 * |
| 94 * @return {Promise} Resolves to true if Host mode is supported. | 92 * @return {Promise} Resolves to true if Host mode is supported. |
| 95 */ | 93 */ |
| 96 function isHostModeSupported_() { | 94 function isHostModeSupported_() { |
| 97 if (!remoting.platformIsChromeOS()) { | 95 if (remoting.HostInstaller.canInstall()) { |
| 98 return Promise.resolve(true); | 96 return Promise.resolve(true); |
| 99 } | 97 } |
| 100 // Sharing on Chrome OS is currently behind a flag. | 98 |
| 101 // isInstalled() will return false if the flag is disabled. | 99 return remoting.HostInstaller.isInstalled(); |
| 102 var hostInstaller = new remoting.HostInstaller(); | |
| 103 return hostInstaller.isInstalled(); | |
| 104 } | 100 } |
| 105 | 101 |
| 106 /** | 102 /** |
| 107 * initHomeScreenUi is called if the app is not starting up in session mode, | 103 * initHomeScreenUi is called if the app is not starting up in session mode, |
| 108 * and also if the user cancels pin entry or the connection in session mode. | 104 * and also if the user cancels pin entry or the connection in session mode. |
| 109 */ | 105 */ |
| 110 remoting.initHomeScreenUi = function() { | 106 remoting.initHomeScreenUi = function() { |
| 111 remoting.hostController = new remoting.HostController(); | 107 remoting.hostController = new remoting.HostController(); |
| 112 remoting.setMode(remoting.AppMode.HOME); | 108 remoting.setMode(remoting.AppMode.HOME); |
| 113 remoting.hostSetupDialog = | 109 remoting.hostSetupDialog = |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 } | 199 } |
| 204 | 200 |
| 205 | 201 |
| 206 remoting.startDesktopRemoting = function() { | 202 remoting.startDesktopRemoting = function() { |
| 207 remoting.app = new remoting.Application(); | 203 remoting.app = new remoting.Application(); |
| 208 var desktop_remoting = new remoting.DesktopRemoting(remoting.app); | 204 var desktop_remoting = new remoting.DesktopRemoting(remoting.app); |
| 209 remoting.app.start(); | 205 remoting.app.start(); |
| 210 }; | 206 }; |
| 211 | 207 |
| 212 window.addEventListener('load', remoting.startDesktopRemotingForTesting, false); | 208 window.addEventListener('load', remoting.startDesktopRemotingForTesting, false); |
| OLD | NEW |