Commit 3cf7e0eb authored by sergeyu's avatar sergeyu Committed by Commit bot

Fix host installation on i686 Linux.

HostInstaller uses navigator.platform to figure out which package
needs to be downloaded to install host on the curren machine. Problem
was that on linux navigator.platform may be set to "Linux i686" and
HostIntaller wasn't handling it properly. With this change:
  1. "Linux i686" is properly recognized as ia32 Linux.
  2. Unsupported platforms are properly handled by disabling the
     "Share" button.

BUG=442943

Review URL: https://codereview.chromium.org/874683002

Cr-Commit-Position: refs/heads/master@{#313030}
parent 433d44af
......@@ -807,8 +807,8 @@ For information about privacy, please see the Google Privacy Policy (http://goo.
<message desc="Description of the 'share' or 'host' functionality, displayed next to a button that instigates a share operation." name="IDS_HOME_SHARE_DESCRIPTION">
Share this computer for another user to see and control.
</message>
<message desc="Text displayed below the description of the 'share' or 'host' functionality on ChromeOS devices, where it is not yet supported." name="IDS_HOME_SHARE_DESCRIPTION_CHROME_OS">
(this feature is not yet available for Chromebooks… stay tuned)
<message desc="Text displayed below the description of the 'share' or 'host' functionality on an unsupported platform." name="IDS_HOME_SHARE_DESCRIPTION_UNSUPPORTED">
(this feature is not yet available for your computer)
</message>
<message desc="In the connection history dialog, clicking this button shows only recent connections to this computer." name="IDS_INCOMING_CONNECTIONS">
To this computer
......
......@@ -28,8 +28,8 @@ found in the LICENSE file.
<div class="section-row">
<div class="box-spacer">
<div i18n-content="HOME_SHARE_DESCRIPTION"></div>
<div id="chrome-os-no-share"
i18n-content="HOME_SHARE_DESCRIPTION_CHROME_OS"
<div id="unsupported-platform-message"
i18n-content="HOME_SHARE_DESCRIPTION_UNSUPPORTED"
class="small-print"></div>
</div>
<div>
......
......@@ -19,16 +19,16 @@ remoting.initHostlist_ = function() {
document.getElementById('host-list-loading-indicator'));
isHostModeSupported_().then(
/** @param {Boolean} supported */
function(supported){
if (supported) {
var noShare = document.getElementById('chrome-os-no-share');
noShare.parentNode.removeChild(noShare);
} else {
var button = document.getElementById('share-button');
button.disabled = true;
}
});
/** @param {Boolean} supported */
function(supported) {
if (supported) {
var noShare = document.getElementById('unsupported-platform-message');
noShare.parentNode.removeChild(noShare);
} else {
var button = document.getElementById('share-button');
button.disabled = true;
}
});
/**
* @return {Promise} A promise that resolves to the id of the current
......@@ -87,20 +87,16 @@ remoting.initHostlist_ = function() {
}
/**
* Returns whether Host mode is supported on this platform for It2me.
* TODO(kelvinp): Remove this function once It2me is enabled on Chrome OS (See
* crbug.com/429860).
* Returns whether Host mode is supported on this platform for It2Me.
*
* @return {Promise} Resolves to true if Host mode is supported.
*/
function isHostModeSupported_() {
if (!remoting.platformIsChromeOS()) {
if (remoting.HostInstaller.canInstall()) {
return Promise.resolve(true);
}
// Sharing on Chrome OS is currently behind a flag.
// isInstalled() will return false if the flag is disabled.
var hostInstaller = new remoting.HostInstaller();
return hostInstaller.isInstalled();
return remoting.HostInstaller.isInstalled();
}
/**
......
......@@ -26,6 +26,8 @@
/** @suppress {duplicate} */
var remoting = remoting || {};
(function() {
/**
* @constructor
*/
......@@ -47,7 +49,7 @@ remoting.HostInstaller = function() {
* @return {Promise} The promise will resolve to a boolean value indicating
* whether the host is installed or not.
*/
remoting.HostInstaller.prototype.isInstalled = function() {
remoting.HostInstaller.isInstalled = function() {
// Always do a fresh check as we don't get notified when the host is
// uninstalled.
......@@ -78,28 +80,39 @@ remoting.HostInstaller.prototype.isInstalled = function() {
});
};
/** @type {Object.<string,string>} */
var HOST_DOWNLOAD_URLS = {
'Win32': 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
'chromeremotedesktophost.msi',
'Win64': 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
'chromeremotedesktophost.msi',
'MacIntel': 'https://dl.google.com/chrome-remote-desktop/' +
'chromeremotedesktop.dmg',
'Linux x86_64': 'https://dl.google.com/linux/direct/' +
'chrome-remote-desktop_current_amd64.deb',
'Linux i386': 'https://dl.google.com/linux/direct/' +
'chrome-remote-desktop_current_i386.deb',
'Linux i686': 'https://dl.google.com/linux/direct/' +
'chrome-remote-desktop_current_i386.deb'
};
/**
* Returns true if the host is installable on the current platform.
* @returns {boolean}
*/
remoting.HostInstaller.canInstall = function() {
return !!HOST_DOWNLOAD_URLS[navigator.platform];
};
/**
* @throws {Error} Throws if there is no matching host binary for the current
* platform.
*/
remoting.HostInstaller.prototype.download = function() {
/** @type {Object.<string,string>} */
var hostDownloadUrls = {
'Win32' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
'chromeremotedesktophost.msi',
'Win64' : 'http://dl.google.com/dl/edgedl/chrome-remote-desktop/' +
'chromeremotedesktophost.msi',
'MacIntel' : 'https://dl.google.com/chrome-remote-desktop/' +
'chromeremotedesktop.dmg',
'Linux x86_64' : 'https://dl.google.com/linux/direct/' +
'chrome-remote-desktop_current_amd64.deb',
'Linux i386' : 'https://dl.google.com/linux/direct/' +
'chrome-remote-desktop_current_i386.deb'
};
var hostPackageUrl = hostDownloadUrls[navigator.platform];
var hostPackageUrl = HOST_DOWNLOAD_URLS[navigator.platform];
if (hostPackageUrl === undefined) {
throw new Error(remoting.Error.CANCELLED);
console.error("Tried to install host on " + navigator.platform);
throw new Error(remoting.Error.UNEXPECTED);
}
// Start downloading the package.
......@@ -122,7 +135,7 @@ remoting.HostInstaller.prototype.downloadAndWaitForInstall = function() {
*/
var CHECK_INSTALL_INTERVAL_IN_MILLISECONDS = 1000;
return this.isInstalled().then(
return remoting.HostInstaller.isInstalled().then(
/** @param {boolean} installed */
function(installed){
if (installed) {
......@@ -135,7 +148,7 @@ remoting.HostInstaller.prototype.downloadAndWaitForInstall = function() {
function(resolve){
that.download();
that.checkInstallIntervalId_ = window.setInterval(function() {
that.isInstalled().then(
remoting.HostInstaller.isInstalled().then(
/** @param {boolean} installed */
function(installed) {
if (installed) {
......@@ -163,3 +176,5 @@ remoting.HostInstaller.prototype.cancel = function() {
}
this.downloadAndWaitForInstallPromise_ = null;
};
})();
......@@ -214,7 +214,7 @@ remoting.It2MeHelpeeChannel.prototype.handleIsHostInstalled_ =
});
}
this.hostInstaller_.isInstalled().then(
remoting.HostInstaller.isInstalled().then(
sendResponse,
/** @type {function(*):void} */(this.sendErrorResponse_.bind(this, message))
);
......
......@@ -34,7 +34,6 @@ module('It2MeHelpeeChannel', {
// HostInstaller
hostInstaller = {
isInstalled: function() {},
download: function() {}
};
......@@ -64,7 +63,8 @@ test('hello() should return supportedFeatures', function() {
QUnit.asyncTest(
'isHostInstalled() should return false if host is not installed',
function() {
sinon.stub(hostInstaller, 'isInstalled').returns(Promise.resolve(false));
sinon.stub(remoting.HostInstaller, 'isInstalled')
.returns(Promise.resolve(false));
var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
hangoutPort.onMessage.mock$fire({
......@@ -72,6 +72,7 @@ QUnit.asyncTest(
});
window.requestAnimationFrame(function() {
remoting.HostInstaller.isInstalled.restore();
sinon.assert.calledWith(hangoutPort.postMessage, {
method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
result: false
......@@ -82,7 +83,8 @@ QUnit.asyncTest(
QUnit.asyncTest('isHostInstalled() should return true if host is installed',
function() {
sinon.stub(hostInstaller, 'isInstalled').returns(Promise.resolve(true));
sinon.stub(remoting.HostInstaller, 'isInstalled')
.returns(Promise.resolve(true));
var MessageTypes = remoting.It2MeHelpeeChannel.HangoutMessageTypes;
hangoutPort.onMessage.mock$fire({
......@@ -90,6 +92,7 @@ QUnit.asyncTest('isHostInstalled() should return true if host is installed',
});
window.requestAnimationFrame(function() {
remoting.HostInstaller.isInstalled.restore();
sinon.assert.calledWith(hangoutPort.postMessage, {
method: MessageTypes.IS_HOST_INSTALLED_RESPONSE,
result: true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment