Chromium Code Reviews| 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 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * | 7 * |
| 8 * HostInstaller allows the caller to download the host binary and monitor the | 8 * HostInstaller allows the caller to download the host binary and monitor the |
| 9 * install progress of the host by pinging the host periodically via native | 9 * install progress of the host by pinging the host periodically via native |
| 10 * messaging. | 10 * messaging. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 port.onMessage.removeListener(onMessage); | 71 port.onMessage.removeListener(onMessage); |
| 72 resolve(false); | 72 resolve(false); |
| 73 } | 73 } |
| 74 | 74 |
| 75 port.onDisconnect.addListener(onDisconnected); | 75 port.onDisconnect.addListener(onDisconnected); |
| 76 port.onMessage.addListener(onMessage); | 76 port.onMessage.addListener(onMessage); |
| 77 port.postMessage({type: 'hello'}); | 77 port.postMessage({type: 'hello'}); |
| 78 }); | 78 }); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 /** @type {Object.<string,string>} */ | |
| 82 remoting.HostInstaller.HOST_DOWNLOAD_URLS = { | |
|
kelvinp
2015/01/23 21:15:33
With the new JS Compiler, you can make this truly
Sergey Ulanov
2015/01/23 21:26:19
Done.
| |
| 83 'Win32': 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + | |
| 84 'chromeremotedesktophost.msi', | |
| 85 'Win64': 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + | |
| 86 'chromeremotedesktophost.msi', | |
| 87 'MacIntel': 'https://dl.google.com/chrome-remote-desktop/' + | |
| 88 'chromeremotedesktop.dmg', | |
| 89 'Linux x86_64': 'https://dl.google.com/linux/direct/' + | |
| 90 'chrome-remote-desktop_current_amd64.deb', | |
| 91 'Linux i386': 'https://dl.google.com/linux/direct/' + | |
| 92 'chrome-remote-desktop_current_i386.deb', | |
| 93 'Linux i686': 'https://dl.google.com/linux/direct/' + | |
| 94 'chrome-remote-desktop_current_i386.deb' | |
| 95 }; | |
| 96 | |
| 97 /** | |
| 98 * Returns true if the host is installable on the current platform. | |
| 99 * @returns {boolean} | |
| 100 */ | |
| 101 remoting.HostInstaller.canInstall = function() { | |
| 102 return !!remoting.HostInstaller.HOST_DOWNLOAD_URLS[navigator.platform]; | |
| 103 }; | |
| 104 | |
| 81 /** | 105 /** |
| 82 * @throws {Error} Throws if there is no matching host binary for the current | 106 * @throws {Error} Throws if there is no matching host binary for the current |
| 83 * platform. | 107 * platform. |
| 84 */ | 108 */ |
| 85 remoting.HostInstaller.prototype.download = function() { | 109 remoting.HostInstaller.prototype.download = function() { |
| 86 /** @type {Object.<string,string>} */ | 110 var hostPackageUrl = |
| 87 var hostDownloadUrls = { | 111 remoting.HostInstaller.HOST_DOWNLOAD_URLS[navigator.platform]; |
| 88 'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + | |
| 89 'chromeremotedesktophost.msi', | |
| 90 'Win64' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' + | |
| 91 'chromeremotedesktophost.msi', | |
| 92 'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' + | |
| 93 'chromeremotedesktop.dmg', | |
| 94 'Linux x86_64' : 'https://dl.google.com/linux/direct/' + | |
| 95 'chrome-remote-desktop_current_amd64.deb', | |
| 96 'Linux i386' : 'https://dl.google.com/linux/direct/' + | |
| 97 'chrome-remote-desktop_current_i386.deb' | |
| 98 }; | |
| 99 | |
| 100 var hostPackageUrl = hostDownloadUrls[navigator.platform]; | |
| 101 if (hostPackageUrl === undefined) { | 112 if (hostPackageUrl === undefined) { |
| 102 throw new Error(remoting.Error.CANCELLED); | 113 console.error("Tried to install host on " + navigator.platform); |
| 114 throw new Error(remoting.Error.UNEXPECTED); | |
| 103 } | 115 } |
| 104 | 116 |
| 105 // Start downloading the package. | 117 // Start downloading the package. |
| 106 if (base.isAppsV2()) { | 118 if (base.isAppsV2()) { |
| 107 // TODO(jamiewalch): Use chrome.downloads when it is available to | 119 // TODO(jamiewalch): Use chrome.downloads when it is available to |
| 108 // apps v2 (http://crbug.com/174046) | 120 // apps v2 (http://crbug.com/174046) |
| 109 window.open(hostPackageUrl); | 121 window.open(hostPackageUrl); |
| 110 } else { | 122 } else { |
| 111 window.location = hostPackageUrl; | 123 window.location = hostPackageUrl; |
| 112 } | 124 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 * var promise = hostInstaller.downloadAndWaitForInstall(); | 168 * var promise = hostInstaller.downloadAndWaitForInstall(); |
| 157 * hostInstaller.cancel(); // This will prevent |promise| from fulfilling. | 169 * hostInstaller.cancel(); // This will prevent |promise| from fulfilling. |
| 158 */ | 170 */ |
| 159 remoting.HostInstaller.prototype.cancel = function() { | 171 remoting.HostInstaller.prototype.cancel = function() { |
| 160 if (this.checkInstallIntervalId_ !== null) { | 172 if (this.checkInstallIntervalId_ !== null) { |
| 161 window.clearInterval(this.checkInstallIntervalId_); | 173 window.clearInterval(this.checkInstallIntervalId_); |
| 162 this.checkInstallIntervalId_ = null; | 174 this.checkInstallIntervalId_ = null; |
| 163 } | 175 } |
| 164 this.downloadAndWaitForInstallPromise_ = null; | 176 this.downloadAndWaitForInstallPromise_ = null; |
| 165 }; | 177 }; |
| OLD | NEW |