diff options
author | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 23:38:36 +0000 |
---|---|---|
committer | jamiewalch@google.com <jamiewalch@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-19 23:38:36 +0000 |
commit | 3885d24158f8a60332bb96ec01b7437e0f75ee11 (patch) | |
tree | b46f4da9a54f12a4d0afffd0cc29b7a84ed45e6a /remoting | |
parent | 55afdcdfa9d06219869ffc726a948fa4216c2098 (diff) | |
download | chromium_src-3885d24158f8a60332bb96ec01b7437e0f75ee11.zip chromium_src-3885d24158f8a60332bb96ec01b7437e0f75ee11.tar.gz chromium_src-3885d24158f8a60332bb96ec01b7437e0f75ee11.tar.bz2 |
Show client plugin if no hello is received in 0.5s.
This allows us to support click-to-play, and also to display a "missing plugin"
box if the plugin is disabled.
BUG=123885
TEST=
Review URL: https://chromiumcodereview.appspot.com/10152001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133084 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/webapp/client_plugin_async.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js index 183b836..b0baec3 100644 --- a/remoting/webapp/client_plugin_async.js +++ b/remoting/webapp/client_plugin_async.js @@ -58,6 +58,10 @@ remoting.ClientPluginAsync = function(plugin) { this.plugin.addEventListener('message', function(event) { that.handleMessage_(event.data); }, false); + var showPluginForClickToPlay = function() { + that.showPluginForClickToPlay_(); + }; + window.setTimeout(showPluginForClickToPlay, 500); }; /** @@ -93,6 +97,9 @@ remoting.ClientPluginAsync.prototype.handleMessage_ = function(message_str) { } if (message.method == 'hello') { + // Reset the size in case we had to enlarge it to support click-to-play. + this.plugin.width = 0; + this.plugin.height = 0; if (typeof message.data['apiVersion'] != 'number' || typeof message.data['apiMinVersion'] != 'number') { console.error('Received invalid hello message: ' + message_str); @@ -356,3 +363,24 @@ remoting.ClientPluginAsync.prototype.sendClipboardItem = { method: 'sendClipboardItem', data: { mimeType: mimeType, item: item }})); }; + +/** + * If we haven't yet received a "hello" message from the plugin, change its + * size so that the user can confirm it if click-to-play is enabled, or can + * see the "this plugin is disabled" message if it is actually disabled. + * @private + */ +remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { + if (!this.helloReceived_) { + var width = 200; + var height = 200; + this.plugin.width = width; + this.plugin.height = height; + // Center the plugin just underneath the "Connnecting..." dialog. + var parentNode = this.plugin.parentNode; + var dialog = document.getElementById('client-dialog'); + var dialogRect = dialog.getBoundingClientRect(); + parentNode.style.top = (dialogRect.bottom + 16) + 'px'; + parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; + } +}; |