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

Side by Side Diff: remoting/webapp/client_plugin_async.js

Issue 22477006: Added JsonMessage to the control channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Class that wraps low-level details of interacting with the client plugin. 7 * Class that wraps low-level details of interacting with the client plugin.
8 * 8 *
9 * This abstracts a <embed> element and controls the plugin which does 9 * This abstracts a <embed> element and controls the plugin which does
10 * the actual remoting work. It also handles differences between 10 * the actual remoting work. It also handles differences between
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 var scope = /** @type {string} */ message.data['scope']; 306 var scope = /** @type {string} */ message.data['scope'];
307 this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope); 307 this.fetchThirdPartyTokenHandler(tokenUrl, hostPublicKey, scope);
308 } else if (message.method == 'pairingResponse') { 308 } else if (message.method == 'pairingResponse') {
309 var clientId = /** @type {string} */ message.data['clientId']; 309 var clientId = /** @type {string} */ message.data['clientId'];
310 var sharedSecret = /** @type {string} */ message.data['sharedSecret']; 310 var sharedSecret = /** @type {string} */ message.data['sharedSecret'];
311 if (typeof clientId != 'string' || typeof sharedSecret != 'string') { 311 if (typeof clientId != 'string' || typeof sharedSecret != 'string') {
312 console.error('Received incorrect pairingResponse message.'); 312 console.error('Received incorrect pairingResponse message.');
313 return; 313 return;
314 } 314 }
315 this.onPairingComplete_(clientId, sharedSecret); 315 this.onPairingComplete_(clientId, sharedSecret);
316 } else if (message.method == 'jsonMessage') {
317 // No messages currently supported.
318 console.log('Unexpected message received: ' +
319 message.data.type + ': ' + message.data.json);
316 } 320 }
317 }; 321 };
318 322
319 /** 323 /**
320 * Deletes the plugin. 324 * Deletes the plugin.
321 */ 325 */
322 remoting.ClientPluginAsync.prototype.cleanup = function() { 326 remoting.ClientPluginAsync.prototype.cleanup = function() {
323 this.plugin.parentNode.removeChild(this.plugin); 327 this.plugin.parentNode.removeChild(this.plugin);
324 }; 328 };
325 329
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 function(clientName, onDone) { 604 function(clientName, onDone) {
601 if (!this.hasFeature(remoting.ClientPlugin.Feature.PINLESS_AUTH)) { 605 if (!this.hasFeature(remoting.ClientPlugin.Feature.PINLESS_AUTH)) {
602 return; 606 return;
603 } 607 }
604 this.onPairingComplete_ = onDone; 608 this.onPairingComplete_ = onDone;
605 this.plugin.postMessage(JSON.stringify( 609 this.plugin.postMessage(JSON.stringify(
606 { method: 'requestPairing', data: { clientName: clientName } })); 610 { method: 'requestPairing', data: { clientName: clientName } }));
607 }; 611 };
608 612
609 /** 613 /**
614 * Send a JSON message to the host.
615 *
616 * @param {string} type The message type.
617 * @param {Object} message The message payload.
618 */
619 remoting.ClientPluginAsync.prototype.sendClientJson = function(type, message) {
620 if (!this.hasFeature(remoting.ClientPlugin.Feature.JSON_MESSAGE)) {
621 return;
622 }
623 this.plugin.postMessage(JSON.stringify(
624 { method: 'jsonMessage',
625 data: { type: type, json: JSON.stringify(message) } }));
626
627 };
628
629 /**
610 * If we haven't yet received a "hello" message from the plugin, change its 630 * If we haven't yet received a "hello" message from the plugin, change its
611 * size so that the user can confirm it if click-to-play is enabled, or can 631 * size so that the user can confirm it if click-to-play is enabled, or can
612 * see the "this plugin is disabled" message if it is actually disabled. 632 * see the "this plugin is disabled" message if it is actually disabled.
613 * @private 633 * @private
614 */ 634 */
615 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { 635 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() {
616 if (!this.helloReceived_) { 636 if (!this.helloReceived_) {
617 var width = 200; 637 var width = 200;
618 var height = 200; 638 var height = 200;
619 this.plugin.width = width; 639 this.plugin.width = width;
620 this.plugin.height = height; 640 this.plugin.height = height;
621 // Center the plugin just underneath the "Connnecting..." dialog. 641 // Center the plugin just underneath the "Connnecting..." dialog.
622 var parentNode = this.plugin.parentNode; 642 var parentNode = this.plugin.parentNode;
623 var dialog = document.getElementById('client-dialog'); 643 var dialog = document.getElementById('client-dialog');
624 var dialogRect = dialog.getBoundingClientRect(); 644 var dialogRect = dialog.getBoundingClientRect();
625 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; 645 parentNode.style.top = (dialogRect.bottom + 16) + 'px';
626 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; 646 parentNode.style.left = (window.innerWidth - width) / 2 + 'px';
627 } 647 }
628 }; 648 };
OLDNEW
« remoting/protocol/host_stub.h ('K') | « remoting/webapp/client_plugin.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698