summaryrefslogtreecommitdiffstats
path: root/remoting
diff options
context:
space:
mode:
authorweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 04:42:52 +0000
committerweitaosu@chromium.org <weitaosu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 04:42:52 +0000
commit95c8b02f2a68cb77af92d1f5384a39853a2ae4df (patch)
tree7ed0336d9c4f37f68105794da317e7de98d5eb0c /remoting
parent3d3fba2c7f9c67fa5e76b65091e3f85e70a7873f (diff)
downloadchromium_src-95c8b02f2a68cb77af92d1f5384a39853a2ae4df.zip
chromium_src-95c8b02f2a68cb77af92d1f5384a39853a2ae4df.tar.gz
chromium_src-95c8b02f2a68cb77af92d1f5384a39853a2ae4df.tar.bz2
Show the host setup dialog when the user tries to share an IT2Me session if neither the host nor the plugin is present.
The reason we didn't catch this earlier is that chrome throws different errors upon native messaging connection request when the NM host manifest is not present vs. when the manifest is present but not the host binary. We now show the host setup dialog when the native messaging connection fails for any reason before it is initialized. It is not reliable to depend on exact error message string match anyway. BUG=360678 Review URL: https://codereview.chromium.org/227903002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r--remoting/webapp/error.js8
-rw-r--r--remoting/webapp/host_it2me_dispatcher.js25
-rw-r--r--remoting/webapp/host_it2me_native_messaging.js23
-rw-r--r--remoting/webapp/remoting.js2
4 files changed, 26 insertions, 32 deletions
diff --git a/remoting/webapp/error.js b/remoting/webapp/error.js
index 04abb60..1b81a33 100644
--- a/remoting/webapp/error.js
+++ b/remoting/webapp/error.js
@@ -33,11 +33,3 @@ remoting.Error = {
P2P_FAILURE: /*i18n-content*/'ERROR_P2P_FAILURE',
REGISTRATION_FAILED: /*i18n-content*/'ERROR_HOST_REGISTRATION_FAILED'
};
-
-/**
- * Message returned by chrome.runtime.lastError.message when chrome fails
- * to find a native messaging host.
- * @type {string}
- */
-remoting.NATIVE_MESSAGING_HOST_NOT_FOUND_ERROR =
- 'Specified native messaging host not found.';
diff --git a/remoting/webapp/host_it2me_dispatcher.js b/remoting/webapp/host_it2me_dispatcher.js
index 1098e4b..f2a7e90 100644
--- a/remoting/webapp/host_it2me_dispatcher.js
+++ b/remoting/webapp/host_it2me_dispatcher.js
@@ -42,25 +42,24 @@ remoting.HostIt2MeDispatcher = function() {
* @param {function():remoting.HostPlugin} createPluginCallback Callback to
* instantiate the NPAPI plugin when NativeMessaging is determined to be
* unsupported.
- * @param {function():void} onDone Callback to be called after initialization
- * has finished successfully.
- * @param {function(remoting.Error):void} onError Callback to invoke if neither
- * the native messaging host nor the NPAPI plugin works.
+ * @param {function():void} onDispatcherInitialized Callback to be called after
+ * initialization has finished successfully.
+ * @param {function(remoting.Error):void} onDispatcherInitializationFailed
+ * Callback to invoke if neither the native messaging host nor the NPAPI
+ * plugin works.
*/
remoting.HostIt2MeDispatcher.prototype.initialize =
- function(createPluginCallback, onDone, onError) {
+ function(createPluginCallback, onDispatcherInitialized,
+ onDispatcherInitializationFailed) {
/** @type {remoting.HostIt2MeDispatcher} */
var that = this;
function onNativeMessagingStarted() {
console.log('Native Messaging supported.');
- onDone();
+ onDispatcherInitialized();
}
- /**
- * @param {remoting.Error} error
- */
- function onNativeMessagingFailed(error) {
+ function onNativeMessagingInitFailed() {
console.log('Native Messaging unsupported, falling back to NPAPI.');
that.nativeMessagingHost_ = null;
@@ -69,15 +68,15 @@ remoting.HostIt2MeDispatcher.prototype.initialize =
// TODO(weitaosu): is there a better way to check whether NPAPI plugin is
// supported?
if (that.npapiHost_) {
- onDone();
+ onDispatcherInitialized();
} else {
- onError(error);
+ onDispatcherInitializationFailed(remoting.Error.MISSING_PLUGIN);
}
}
this.nativeMessagingHost_ = new remoting.HostIt2MeNativeMessaging();
this.nativeMessagingHost_.initialize(onNativeMessagingStarted,
- onNativeMessagingFailed,
+ onNativeMessagingInitFailed,
this.onNativeMessagingError_.bind(this));
}
diff --git a/remoting/webapp/host_it2me_native_messaging.js b/remoting/webapp/host_it2me_native_messaging.js
index 45efaa9..6af8168 100644
--- a/remoting/webapp/host_it2me_native_messaging.js
+++ b/remoting/webapp/host_it2me_native_messaging.js
@@ -60,10 +60,9 @@ remoting.HostIt2MeNativeMessaging = function() {
/**
* Called if Native Messaging host has failed to start.
- * @param {remoting.Error} error
* @private
* */
- this.onHostInitFailed_ = function(error) {};
+ this.onHostInitFailed_ = function() {};
/**
* Called if the It2Me Native Messaging host sends a malformed message:
@@ -94,8 +93,7 @@ remoting.HostIt2MeNativeMessaging = function() {
*
* @param {function():void} onHostStarted Called after successful
* initialization.
- * @param {function(remoting.Error):void} onHostInitFailed Called if cannot
- * connect to host.
+ * @param {function():void} onHostInitFailed Called if cannot connect to host.
* @param {function(remoting.Error):void} onError Called on host error after
* successfully connecting to the host.
* @return {void}
@@ -115,7 +113,7 @@ remoting.HostIt2MeNativeMessaging.prototype.initialize =
} catch (err) {
console.log('Native Messaging initialization failed: ',
/** @type {*} */ (err));
- onHostInitFailed(remoting.Error.UNEXPECTED);
+ onHostInitFailed();
return;
}
};
@@ -290,12 +288,15 @@ remoting.HostIt2MeNativeMessaging.prototype.onConnected_ =
*/
remoting.HostIt2MeNativeMessaging.prototype.onHostDisconnect_ = function() {
if (!this.initialized_) {
- var error = (chrome.runtime.lastError.message ==
- remoting.NATIVE_MESSAGING_HOST_NOT_FOUND_ERROR)
- ? remoting.Error.MISSING_PLUGIN
- : remoting.Error.UNEXPECTED;
- console.error('Native Messaging initialization failed.');
- this.onHostInitFailed_(error);
+ // If the host is disconnected before it is initialized, it probably means
+ // the host is not propertly installed (or not installed at all).
+ // E.g., if the host manifest is not present we get "Specified native
+ // messaging host not found" error. If the host manifest is present but
+ // the host binary cannot be found we get the "Native host has exited"
+ // error.
+ console.log('Native Messaging initialization failed: ' +
+ chrome.runtime.lastError.message);
+ this.onHostInitFailed_();
} else {
console.error('Native Messaging port disconnected.');
this.onError_(remoting.Error.UNEXPECTED);
diff --git a/remoting/webapp/remoting.js b/remoting/webapp/remoting.js
index 8b69379..4c5efadd 100644
--- a/remoting/webapp/remoting.js
+++ b/remoting/webapp/remoting.js
@@ -184,6 +184,8 @@ remoting.createNpapiPlugin = function(container) {
remoting.isMe2MeInstallable = function() {
/** @type {string} */
var platform = navigator.platform;
+ // Chromoting host is not installable on ChromeOS and any linux distro other
+ // than Ubuntu.
return platform == 'Win32' || platform == 'MacIntel';
}