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

Side by Side Diff: remoting/webapp/crd/js/client_session.js

Issue 1054273002: [Webapp Refactor] Implements remoting.Activity. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 5 years, 8 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
« no previous file with comments | « remoting/webapp/crd/js/activity.js ('k') | remoting/webapp/crd/js/desktop_remoting.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 handling creation and teardown of a remoting client session. 7 * Class handling creation and teardown of a remoting client session.
8 * 8 *
9 * The ClientSession class controls lifetime of the client plugin 9 * The ClientSession class controls lifetime of the client plugin
10 * object and provides the plugin with the functionality it needs to 10 * object and provides the plugin with the functionality it needs to
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 /** @private {remoting.ClientPlugin} */ 86 /** @private {remoting.ClientPlugin} */
87 this.plugin_ = plugin; 87 this.plugin_ = plugin;
88 plugin.setConnectionEventHandler(this); 88 plugin.setConnectionEventHandler(this);
89 89
90 this.defineEvents(Object.keys(remoting.ClientSession.Events)); 90 this.defineEvents(Object.keys(remoting.ClientSession.Events));
91 }; 91 };
92 92
93 /** @enum {string} */ 93 /** @enum {string} */
94 remoting.ClientSession.Events = { 94 remoting.ClientSession.Events = {
95 stateChanged: 'stateChanged', 95 stateChanged: 'stateChanged', // deprecated.
96 videoChannelStateChanged: 'videoChannelStateChanged', 96 videoChannelStateChanged: 'videoChannelStateChanged',
97 }; 97 };
98 98
99 /**
100 * @interface
101 * [START]-------> [onConnected] ------> [onDisconnected]
102 * | |
103 * |-----> [OnConnectionFailed] |----> [onError]
104 *
105 * TODO(kelvinp): Route session state changes through this interface.
106 */
107 remoting.ClientSession.EventHandler = function() {};
108
109 /**
110 * Called when the connection failed before it is connected.
111 *
112 * @param {!remoting.Error} error
113 */
114 remoting.ClientSession.EventHandler.prototype.onConnectionFailed =
115 function(error) {};
116
117 /**
118 * Called when a new session has been connected. The |connectionInfo| will be
119 * valid until onDisconnected() or onError() is called.
120 *
121 * @param {!remoting.ConnectionInfo} connectionInfo
122 */
123 remoting.ClientSession.EventHandler.prototype.onConnected =
124 function(connectionInfo) {};
125
126 /**
127 * Called when the current session has been disconnected.
128 */
129 remoting.ClientSession.EventHandler.prototype.onDisconnected = function() {};
130
131 /**
132 * Called when an error needs to be displayed to the user.
133 * @param {!remoting.Error} error
134 */
135 remoting.ClientSession.EventHandler.prototype.onError = function(error) {};
136
99 // Note that the positive values in both of these enums are copied directly 137 // Note that the positive values in both of these enums are copied directly
100 // from connection_to_host.h and must be kept in sync. Code in 138 // from connection_to_host.h and must be kept in sync. Code in
101 // chromoting_instance.cc converts the C++ enums into strings that must match 139 // chromoting_instance.cc converts the C++ enums into strings that must match
102 // the names given here. 140 // the names given here.
103 // The negative values represent state transitions that occur within the 141 // The negative values represent state transitions that occur within the
104 // web-app that have no corresponding plugin state transition. 142 // web-app that have no corresponding plugin state transition.
105 /** @enum {number} */ 143 /** @enum {number} */
106 remoting.ClientSession.State = { 144 remoting.ClientSession.State = {
107 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting. 145 CONNECTION_CANCELED: -3, // Connection closed (gracefully) before connecting.
108 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error. 146 CONNECTION_DROPPED: -2, // Succeeded, but subsequently closed with an error.
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 * errors should not be logged because the JID will be refreshed and the 575 * errors should not be logged because the JID will be refreshed and the
538 * connection retried. 576 * connection retried.
539 * 577 *
540 * @param {boolean} enable True to log host-offline errors; false to suppress. 578 * @param {boolean} enable True to log host-offline errors; false to suppress.
541 */ 579 */
542 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) { 580 remoting.ClientSession.prototype.logHostOfflineErrors = function(enable) {
543 this.logHostOfflineErrors_ = enable; 581 this.logHostOfflineErrors_ = enable;
544 }; 582 };
545 583
546 /** 584 /**
547 * Request pairing with the host for PIN-less authentication.
548 *
549 * @param {string} clientName The human-readable name of the client.
550 * @param {function(string, string):void} onDone Callback to receive the
551 * client id and shared secret when they are available.
552 */
553 remoting.ClientSession.prototype.requestPairing = function(clientName, onDone) {
554 if (this.plugin_) {
555 this.plugin_.requestPairing(clientName, onDone);
556 }
557 };
558
559 /**
560 * Sends a clipboard item to the host. 585 * Sends a clipboard item to the host.
561 * 586 *
562 * @param {string} mimeType The MIME type of the clipboard item. 587 * @param {string} mimeType The MIME type of the clipboard item.
563 * @param {string} item The clipboard item. 588 * @param {string} item The clipboard item.
564 */ 589 */
565 remoting.ClientSession.prototype.sendClipboardItem = function(mimeType, item) { 590 remoting.ClientSession.prototype.sendClipboardItem = function(mimeType, item) {
566 if (!this.plugin_) 591 if (!this.plugin_)
567 return; 592 return;
568 this.plugin_.sendClipboardItem(mimeType, item); 593 this.plugin_.sendClipboardItem(mimeType, item);
569 }; 594 };
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 'https://docs.google.com/feeds/', 628 'https://docs.google.com/feeds/',
604 'https://www.googleapis.com/auth/drive' 629 'https://www.googleapis.com/auth/drive'
605 ]; 630 ];
606 remoting.identity.getNewToken(googleDriveScopes). 631 remoting.identity.getNewToken(googleDriveScopes).
607 then(sendToken). 632 then(sendToken).
608 catch(remoting.Error.handler(sendError)); 633 catch(remoting.Error.handler(sendError));
609 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this), 634 window.setTimeout(this.sendGoogleDriveAccessToken_.bind(this),
610 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS); 635 remoting.ACCESS_TOKEN_RESEND_INTERVAL_MS);
611 }; 636 };
612 637
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/activity.js ('k') | remoting/webapp/crd/js/desktop_remoting.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698