Commit 6ed253dc authored by sergeyu@chromium.org's avatar sergeyu@chromium.org

Minor cleanups in UI code that gets host state when webapp is stared

- Previously the UI was getting local host ID before getting state,
but it doesn't make sense when host is not started.
- 2 minor changes in HostList and HostController around host state
initialization.

BUG=149744
R=jamiewalch@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250908 0039d316-1c4b-4281-b951-d872f2087c98
parent 310d7775
...@@ -428,8 +428,10 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone, ...@@ -428,8 +428,10 @@ remoting.HostController.prototype.updatePin = function(newPin, onDone,
* callback. * callback.
*/ */
remoting.HostController.prototype.getLocalHostState = function(onDone) { remoting.HostController.prototype.getLocalHostState = function(onDone) {
this.hostDispatcher_.getDaemonState(onDone, function() { this.hostDispatcher_.getDaemonState(onDone, function(error) {
onDone(remoting.HostController.State.NOT_IMPLEMENTED); onDone(remoting.isMe2MeInstallable()
? remoting.HostController.State.NOT_INSTALLED
: remoting.HostController.State.NOT_IMPLEMENTED);
}); });
}; };
......
...@@ -80,9 +80,8 @@ remoting.HostList = function(table, noHosts, errorMsg, errorButton, ...@@ -80,9 +80,8 @@ remoting.HostList = function(table, noHosts, errorMsg, errorButton,
* @type {remoting.HostController.State} * @type {remoting.HostController.State}
* @private * @private
*/ */
this.localHostState_ = remoting.isMe2MeSupported() this.localHostState_ = remoting.HostController.State.UNKNOWN;
? remoting.HostController.State.NOT_INSTALLED
: remoting.HostController.State.NOT_IMPLEMENTED;
/** /**
* @type {number} * @type {number}
* @private * @private
......
...@@ -173,24 +173,18 @@ remoting.createNpapiPlugin = function(container) { ...@@ -173,24 +173,18 @@ remoting.createNpapiPlugin = function(container) {
return /** @type {remoting.HostPlugin} */ (plugin); return /** @type {remoting.HostPlugin} */ (plugin);
}; };
// TODO(sergeyu): We want to show Me2Me host controls only on some Linux
// distributions that we know work properly with the chromoting host. Implement
// dome detection mechanism and apply it here.
/** @type {boolean} */
remoting.supportedLinuxDistibutionDetected_ = false;
/** /**
* Returns true if the current platform is fully supported. It's only used when
* we detect that host native messaging components are not installed. In that
* case the result of this function determines if the webapp should show the
* controls that allow to install and enable Me2Me host.
*
* @return {boolean} * @return {boolean}
*/ */
remoting.isMe2MeSupported = function isMe2MeSupported() { remoting.isMe2MeInstallable = function() {
/** @type {string} */ /** @type {string} */
var platform = navigator.platform; var platform = navigator.platform;
return platform == 'Win32' || platform == 'MacIntel';
// Currently Me2Me is supported on Windows, OSX and some versions of Linux.
return platform == 'Win32' || platform == 'MacIntel' ||
((platform == 'Linux x86_64' || platform == 'Linux i386') &&
remoting.supportedLinuxDistibutionDetected_ &&
!remoting.runningOnChromeOS());
} }
/** /**
...@@ -238,17 +232,21 @@ remoting.initHomeScreenUi = function() { ...@@ -238,17 +232,21 @@ remoting.initHomeScreenUi = function() {
*/ */
remoting.updateLocalHostState = function() { remoting.updateLocalHostState = function() {
/** /**
* @param {string?} hostId Host id. * @param {remoting.HostController.State} state Host state.
*/ */
var onHostId = function(hostId) { var onHostState = function(state) {
remoting.hostController.getLocalHostState(onHostState.bind(null, hostId)); if (state == remoting.HostController.State.STARTED) {
remoting.hostController.getLocalHostId(onHostId.bind(null, state));
} else {
onHostId(state, null);
}
}; };
/** /**
* @param {string?} hostId Host id.
* @param {remoting.HostController.State} state Host state. * @param {remoting.HostController.State} state Host state.
* @param {string?} hostId Host id.
*/ */
var onHostState = function(hostId, state) { var onHostId = function(state, hostId) {
remoting.hostList.setLocalHostStateAndId(state, hostId); remoting.hostList.setLocalHostStateAndId(state, hostId);
remoting.hostList.display(); remoting.hostList.display();
}; };
...@@ -278,7 +276,7 @@ remoting.updateLocalHostState = function() { ...@@ -278,7 +276,7 @@ remoting.updateLocalHostState = function() {
remoting.hostController.hasFeature( remoting.hostController.hasFeature(
remoting.HostController.Feature.PAIRING_REGISTRY, onHasFeatureResponse); remoting.HostController.Feature.PAIRING_REGISTRY, onHasFeatureResponse);
remoting.hostController.getLocalHostId(onHostId); remoting.hostController.getLocalHostState(onHostState);
}; };
/** /**
......
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