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

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

Issue 12867004: Webapp changes to support asking for a PIN (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 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
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 23 matching lines...) Expand all
34 /** @param {string} message Log message. */ 34 /** @param {string} message Log message. */
35 this.onDebugMessageHandler = function (message) {}; 35 this.onDebugMessageHandler = function (message) {};
36 /** 36 /**
37 * @param {number} state The connection state. 37 * @param {number} state The connection state.
38 * @param {number} error The error code, if any. 38 * @param {number} error The error code, if any.
39 */ 39 */
40 this.onConnectionStatusUpdateHandler = function(state, error) {}; 40 this.onConnectionStatusUpdateHandler = function(state, error) {};
41 /** @param {boolean} ready Connection ready state. */ 41 /** @param {boolean} ready Connection ready state. */
42 this.onConnectionReadyHandler = function(ready) {}; 42 this.onConnectionReadyHandler = function(ready) {};
43 this.onDesktopSizeUpdateHandler = function () {}; 43 this.onDesktopSizeUpdateHandler = function () {};
44 this.fetchPinHandler = function () {};
44 45
45 /** @type {number} */ 46 /** @type {number} */
46 this.pluginApiVersion_ = -1; 47 this.pluginApiVersion_ = -1;
47 /** @type {Array.<string>} */ 48 /** @type {Array.<string>} */
48 this.pluginApiFeatures_ = []; 49 this.pluginApiFeatures_ = [];
49 /** @type {number} */ 50 /** @type {number} */
50 this.pluginApiMinVersion_ = -1; 51 this.pluginApiMinVersion_ = -1;
51 /** @type {boolean} */ 52 /** @type {boolean} */
52 this.helloReceived_ = false; 53 this.helloReceived_ = false;
53 /** @type {function(boolean)|null} */ 54 /** @type {function(boolean)|null} */
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (remoting.clientSession) { 199 if (remoting.clientSession) {
199 remoting.clientSession.onFirstFrameReceived(); 200 remoting.clientSession.onFirstFrameReceived();
200 } 201 }
201 } else if (message.method == 'onConnectionReady') { 202 } else if (message.method == 'onConnectionReady') {
202 if (typeof message.data['ready'] != 'boolean') { 203 if (typeof message.data['ready'] != 'boolean') {
203 console.error('Received incorrect onConnectionReady message.'); 204 console.error('Received incorrect onConnectionReady message.');
204 return; 205 return;
205 } 206 }
206 var ready = /** @type {boolean} */ message.data['ready']; 207 var ready = /** @type {boolean} */ message.data['ready'];
207 this.onConnectionReadyHandler(ready); 208 this.onConnectionReadyHandler(ready);
209 } else if (message.method == 'fetchPin') {
210 this.fetchPinHandler();
208 } 211 }
209 } 212 };
210 213
211 /** 214 /**
212 * Deletes the plugin. 215 * Deletes the plugin.
213 */ 216 */
214 remoting.ClientPluginAsync.prototype.cleanup = function() { 217 remoting.ClientPluginAsync.prototype.cleanup = function() {
215 this.plugin.parentNode.removeChild(this.plugin); 218 this.plugin.parentNode.removeChild(this.plugin);
216 }; 219 };
217 220
218 /** 221 /**
219 * @return {HTMLEmbedElement} HTML element that correspods to the plugin. 222 * @return {HTMLEmbedElement} HTML element that correspods to the plugin.
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 */ 431 */
429 remoting.ClientPluginAsync.prototype.pauseAudio = 432 remoting.ClientPluginAsync.prototype.pauseAudio =
430 function(pause) { 433 function(pause) {
431 if (!this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_AUDIO)) 434 if (!this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_AUDIO))
432 return; 435 return;
433 this.plugin.postMessage(JSON.stringify( 436 this.plugin.postMessage(JSON.stringify(
434 { method: 'pauseAudio', data: { pause: pause }})); 437 { method: 'pauseAudio', data: { pause: pause }}));
435 }; 438 };
436 439
437 /** 440 /**
441 * Called when a PIN is obtained from the user.
442 *
443 * @param {string} pin The PIN.
444 */
445 remoting.ClientPluginAsync.prototype.onPinFetched =
446 function(pin) {
447 if (!this.hasFeature(remoting.ClientPlugin.Feature.ON_PIN_FETCHED)) {
448 return;
449 }
450 this.plugin.postMessage(JSON.stringify(
451 { method: 'onPinFetched', data: { pin: pin }}));
452 };
453
454 /**
455 * Tells the plugin to ask for the PIN asynchronously.
456 */
457 remoting.ClientPluginAsync.prototype.useAsyncPinDialog =
458 function() {
459 if (!this.hasFeature(remoting.ClientPlugin.Feature.USE_ASYNC_PIN_DIALOG)) {
460 return;
461 }
462 this.plugin.postMessage(JSON.stringify(
463 { method: 'useAsyncPinDialog', data: {} }));
464 };
465
466 /**
438 * If we haven't yet received a "hello" message from the plugin, change its 467 * If we haven't yet received a "hello" message from the plugin, change its
439 * size so that the user can confirm it if click-to-play is enabled, or can 468 * size so that the user can confirm it if click-to-play is enabled, or can
440 * see the "this plugin is disabled" message if it is actually disabled. 469 * see the "this plugin is disabled" message if it is actually disabled.
441 * @private 470 * @private
442 */ 471 */
443 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() { 472 remoting.ClientPluginAsync.prototype.showPluginForClickToPlay_ = function() {
444 if (!this.helloReceived_) { 473 if (!this.helloReceived_) {
445 var width = 200; 474 var width = 200;
446 var height = 200; 475 var height = 200;
447 this.plugin.width = width; 476 this.plugin.width = width;
448 this.plugin.height = height; 477 this.plugin.height = height;
449 // Center the plugin just underneath the "Connnecting..." dialog. 478 // Center the plugin just underneath the "Connnecting..." dialog.
450 var parentNode = this.plugin.parentNode; 479 var parentNode = this.plugin.parentNode;
451 var dialog = document.getElementById('client-dialog'); 480 var dialog = document.getElementById('client-dialog');
452 var dialogRect = dialog.getBoundingClientRect(); 481 var dialogRect = dialog.getBoundingClientRect();
453 parentNode.style.top = (dialogRect.bottom + 16) + 'px'; 482 parentNode.style.top = (dialogRect.bottom + 16) + 'px';
454 parentNode.style.left = (window.innerWidth - width) / 2 + 'px'; 483 parentNode.style.left = (window.innerWidth - width) / 2 + 'px';
455 } 484 }
456 }; 485 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698