summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-03 07:34:43 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-03 07:34:43 +0000
commit487d3a271cd57794afac1e430497b739af6f2391 (patch)
tree752c5b8ab10667b31eaddd85fa4e3bdc4595ddb9
parentb96c80eeb741b0aa9105dd36d47732c1071e5fee (diff)
downloadchromium_src-487d3a271cd57794afac1e430497b739af6f2391.zip
chromium_src-487d3a271cd57794afac1e430497b739af6f2391.tar.gz
chromium_src-487d3a271cd57794afac1e430497b739af6f2391.tar.bz2
Add an apiFeatures property to the client plugin.
To date features have been added with an associated plugin API bump, leading to conflicts when multiple features go in within the same API bump, and one of them is subsequently back-ported to an earlier release. apiFeatures allows features of the client plugin to be treated independently. TEST=Manual testing of client default scaling setting. Review URL: http://codereview.chromium.org/9969073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130337 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/plugin/chromoting_instance.cc5
-rw-r--r--remoting/client/plugin/chromoting_instance.h6
-rw-r--r--remoting/webapp/client_plugin.js24
-rw-r--r--remoting/webapp/client_plugin_async.js29
-rw-r--r--remoting/webapp/client_plugin_v1.js9
-rw-r--r--remoting/webapp/client_session.js3
6 files changed, 57 insertions, 19 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index 46ee36a..aa8c331 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -100,6 +100,10 @@ static logging::LogMessageHandlerFunction g_logging_old_handler = NULL;
static base::LazyInstance<base::Lock>::Leaky
g_logging_lock = LAZY_INSTANCE_INITIALIZER;
+// String sent in the "hello" message to the plugin to describe features.
+const char ChromotingInstance::kApiFeatures[] =
+ "highQualityScaling injectKeyEvent sendClipboardItem";
+
bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str,
ClientConfig* config) {
if (auth_methods_str == "v1_token") {
@@ -141,6 +145,7 @@ ChromotingInstance::ChromotingInstance(PP_Instance pp_instance)
// Send hello message.
scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue());
data->SetInteger("apiVersion", kApiVersion);
+ data->SetString("apiFeatures", kApiFeatures);
data->SetInteger("apiMinVersion", kApiMinMessagingVersion);
PostChromotingMessage("hello", data.Pass());
}
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index 014ec80..5e36fc8 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -89,7 +89,11 @@ class ChromotingInstance :
// Plugin API version. This should be incremented whenever the API
// interface changes.
- static const int kApiVersion = 6;
+ static const int kApiVersion = 7;
+
+ // Plugin API features. This allows orthogonal features to be supported
+ // without bumping the API version.
+ static const char kApiFeatures[];
// Backward-compatibility version used by for the messaging
// interface. Should be updated whenever we remove support for
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
index 724e689..ed46537 100644
--- a/remoting/webapp/client_plugin.js
+++ b/remoting/webapp/client_plugin.js
@@ -42,25 +42,31 @@ remoting.ClientPlugin.prototype.initialize = function(onDone) {};
remoting.ClientPlugin.prototype.isSupportedVersion = function() {};
/**
- * @return {Element} HTML element that correspods to the plugin.
+ * Set of features for which hasFeature() can be used to test.
+ *
+ * @enum {string}
*/
-remoting.ClientPlugin.prototype.element = function() {};
+remoting.ClientPlugin.Feature = {
+ HIGH_QUALITY_SCALING: 'highQualityScaling',
+ INJECT_KEY_EVENT: 'injectKeyEvent',
+ SEND_CLIPBOARD_ITEM: 'sendClipboardItem'
+};
/**
- * Deletes the plugin.
+ * @param {remoting.ClientPlugin.Feature} feature The feature to test for.
+ * @return {boolean} True if the plugin supports the named feature.
*/
-remoting.ClientPlugin.prototype.cleanup = function() {};
+remoting.ClientPlugin.prototype.hasFeature = function(feature) {};
/**
- * @return {boolean} True if the plugin supports high-quality scaling.
+ * @return {Element} HTML element that correspods to the plugin.
*/
-remoting.ClientPlugin.prototype.isHiQualityScalingSupported =
- function() {};
+remoting.ClientPlugin.prototype.element = function() {};
/**
- * @return {boolean} True if the plugin supports the injectKeyEvent API.
+ * Deletes the plugin.
*/
-remoting.ClientPlugin.prototype.isInjectKeyEventSupported = function() {};
+remoting.ClientPlugin.prototype.cleanup = function() {};
/**
* Must be called for each incoming stanza received from the host.
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index 0ebd54f..b35504f 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -40,6 +40,8 @@ remoting.ClientPluginAsync = function(plugin) {
/** @type {number} */
this.pluginApiVersion_ = -1;
+ /** @type {Array.<string>} */
+ this.pluginApiFeatures_ = [];
/** @type {number} */
this.pluginApiMinVersion_ = -1;
/** @type {boolean} */
@@ -97,6 +99,18 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(message_str) {
return;
}
this.pluginApiVersion_ = /** @type {number} */ message.data['apiVersion'];
+ if (this.pluginApiVersion_ >= 7) {
+ if (typeof message.data['apiFeatures'] != 'string') {
+ console.error('Received invalid hello message: ' + message_str);
+ return;
+ }
+ this.pluginApiFeatures_ =
+ /** @type {Array.<string>} */ message.data['apiFeatures'].split(' ');
+ } else if (this.pluginApiVersion_ >= 6) {
+ this.pluginApiFeatures_ = ['highQualityScaling', 'injectKeyEvent'];
+ } else {
+ this.pluginApiFeatures_ = ['highQualityScaling'];
+ }
this.pluginApiMinVersion_ =
/** @type {number} */ message.data['apiMinVersion'];
this.helloReceived_ = true;
@@ -210,10 +224,16 @@ remoting.ClientPluginAsync.prototype.isSupportedVersion = function() {
};
/**
- * @return {boolean} True if the plugin supports high-quality scaling.
+ * @param {remoting.ClientPlugin.Feature} feature The feature to test for.
+ * @return {boolean} True if the plugin supports the named feature.
*/
-remoting.ClientPluginAsync.prototype.isHiQualityScalingSupported = function() {
- return true;
+remoting.ClientPluginAsync.prototype.hasFeature = function(feature) {
+ if (!this.helloReceived_) {
+ console.error(
+ "hasFeature() is called before the plugin is initialized.");
+ return false;
+ }
+ return this.pluginApiFeatures_.indexOf(feature) > -1;
};
/**
@@ -315,9 +335,8 @@ remoting.ClientPluginAsync.prototype.getPerfStats = function() {
*/
remoting.ClientPluginAsync.prototype.sendClipboardItem =
function(mimeType, item) {
- if (this.plugin.apiVersion < 6) {
+ if (!this.hasFeature(remoting.ClientPlugin.Feature.SEND_CLIPBOARD_ITEM))
return;
- }
this.plugin.postMessage(JSON.stringify(
{ method: 'sendClipboardItem',
data: { mimeType: mimeType, item: item }}));
diff --git a/remoting/webapp/client_plugin_v1.js b/remoting/webapp/client_plugin_v1.js
index 611043d..396b320 100644
--- a/remoting/webapp/client_plugin_v1.js
+++ b/remoting/webapp/client_plugin_v1.js
@@ -141,10 +141,13 @@ remoting.ClientPluginV1.prototype.isSupportedVersion = function() {
};
/**
- * @return {boolean} True if the plugin supports high-quality scaling.
+ * @param {remoting.ClientPlugin.Feature} feature The feature to test for.
+ * @return {boolean} True if the plugin supports the named feature.
*/
-remoting.ClientPluginV1.prototype.isHiQualityScalingSupported = function() {
- return this.plugin.apiVersion >= 3;
+remoting.ClientPluginV1.prototype.hasFeature = function(feature) {
+ if (feature == remoting.ClientPlugin.Feature.HIGH_QUALITY_SCALING)
+ return this.plugin.apiVersion >= 3;
+ return false;
};
/**
diff --git a/remoting/webapp/client_session.js b/remoting/webapp/client_session.js
index ae73bc8..f989dfd 100644
--- a/remoting/webapp/client_session.js
+++ b/remoting/webapp/client_session.js
@@ -279,7 +279,8 @@ remoting.ClientSession.prototype.onPluginInitialized_ =
// Enable scale-to-fit if and only if the plugin is new enough for
// high-quality scaling.
- this.setScaleToFit(this.plugin.isHiQualityScalingSupported());
+ this.setScaleToFit(this.plugin.hasFeature(
+ remoting.ClientPlugin.Feature.HIGH_QUALITY_SCALING));
/** @type {remoting.ClientSession} */ var that = this;
/** @param {string} msg The IQ stanza to send. */