Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: remoting/webapp/me2mom/remoting_session.js

Issue 7065036: Add basic versioning check to Chromoting's plugin/JS code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/plugin/chromoting_scriptable_object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/me2mom/remoting_session.js
diff --git a/remoting/webapp/me2mom/remoting_session.js b/remoting/webapp/me2mom/remoting_session.js
index 8a605ddef32bfde41ab7fcbb6ee54df703d8c9ca..add7bfc78a00a3c1cf130a542b9465b783d55c3d 100644
--- a/remoting/webapp/me2mom/remoting_session.js
+++ b/remoting/webapp/me2mom/remoting_session.js
@@ -5,8 +5,19 @@
// Maximum numer of lines to record in the debug log.
// Only the most recent <n> lines are displayed.
var MAX_DEBUG_LOG_SIZE = 1000;
+
var remoting = chrome.extension.getBackgroundPage().remoting;
+// Chromoting session API version (for this javascript).
+// This is compared with the plugin API version to verify that they are
+// compatible.
+remoting.apiVersion = 1;
+
+// The oldest API version that we support.
+// This will differ from the |apiVersion| if we maintain backward
+// compatibility with older API versions.
+remoting.apiMinVersion = 1;
+
// Message id so that we can identify (and ignore) message fade operations for
// old messages. This starts at 1 and is incremented for each new message.
remoting.messageId = 1;
@@ -95,6 +106,11 @@ function sendIq(msg) {
'&host_jid=' + encodeURIComponent(remoting.hostjid));
}
+function checkVersion(plugin) {
+ return remoting.apiVersion >= plugin.apiMinVersion &&
+ plugin.apiVersion >= remoting.apiMinVersion;
+}
+
function init() {
// Kick off the connection.
var plugin = document.getElementById('remoting');
@@ -116,6 +132,12 @@ function init() {
plugin.desktopSizeUpdate = desktopSizeChanged;
plugin.loginChallenge = loginChallengeCallback;
+ if (!checkVersion(plugin)) {
+ // TODO(garykac): We need better messaging here. Perhaps an install link.
+ setClientStateMessage("Out of date. Please re-install.");
+ return;
+ }
+
addToDebugLog('Connect as user ' + remoting.username);
// TODO(garykac): Clean exit if |connect| isn't a function.
« no previous file with comments | « remoting/client/plugin/chromoting_scriptable_object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698