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

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

Issue 1016623002: [Webapp Refactor] Reparent the ConnectedView into the delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Please diff this patch against patch set 1 Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * This class implements the functionality that is specific to desktop 7 * This class implements the functionality that is specific to desktop
8 * remoting ("Chromoting" or CRD). 8 * remoting ("Chromoting" or CRD).
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 this.app_ = app; 29 this.app_ = app;
30 app.setDelegate(this); 30 app.setDelegate(this);
31 31
32 /** 32 /**
33 * Whether to refresh the JID and retry the connection if the current JID 33 * Whether to refresh the JID and retry the connection if the current JID
34 * is offline. 34 * is offline.
35 * 35 *
36 * @private {boolean} 36 * @private {boolean}
37 */ 37 */
38 this.refreshHostJidIfOffline_ = true; 38 this.refreshHostJidIfOffline_ = true;
39
40 /** @private {remoting.DesktopConnectedView} */
41 this.connectedView_ = null;
42
43 remoting.desktopDelegateForTesting = this;
39 }; 44 };
40 45
41 /** 46 /**
42 * Initialize the application and register all event handlers. After this 47 * Initialize the application and register all event handlers. After this
43 * is called, the app is running and waiting for user events. 48 * is called, the app is running and waiting for user events.
44 * 49 *
45 * @return {void} Nothing. 50 * @return {void} Nothing.
46 */ 51 */
47 remoting.DesktopRemoting.prototype.init = function() { 52 remoting.DesktopRemoting.prototype.init = function() {
48 remoting.initElementEventHandlers(); 53 remoting.initElementEventHandlers();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 var onIsWindowed = function(isWindowed) { 111 var onIsWindowed = function(isWindowed) {
107 if (!isWindowed) { 112 if (!isWindowed) {
108 document.getElementById('startup-mode-box-me2me').hidden = false; 113 document.getElementById('startup-mode-box-me2me').hidden = false;
109 document.getElementById('startup-mode-box-it2me').hidden = false; 114 document.getElementById('startup-mode-box-it2me').hidden = false;
110 } 115 }
111 }; 116 };
112 isWindowed_(onIsWindowed); 117 isWindowed_(onIsWindowed);
113 } 118 }
114 119
115 remoting.ClientPlugin.factory.preloadPlugin(); 120 remoting.ClientPlugin.factory.preloadPlugin();
116 } 121 };
117 122
118 /** 123 /**
119 * Start the application. Once start() is called, the delegate can assume that 124 * Start the application. Once start() is called, the delegate can assume that
120 * the user has consented to all permissions specified in the manifest. 125 * the user has consented to all permissions specified in the manifest.
121 * 126 *
122 * @param {remoting.SessionConnector} connector 127 * @param {remoting.SessionConnector} connector
123 * @param {string} token An OAuth access token. The delegate should not cache 128 * @param {string} token An OAuth access token. The delegate should not cache
124 * this token, but can assume that it will remain valid during application 129 * this token, but can assume that it will remain valid during application
125 * start-up. 130 * start-up.
126 */ 131 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Reset the refresh flag so that the next connection will retry if needed. 190 // Reset the refresh flag so that the next connection will retry if needed.
186 this.refreshHostJidIfOffline_ = true; 191 this.refreshHostJidIfOffline_ = true;
187 192
188 document.getElementById('access-code-entry').value = ''; 193 document.getElementById('access-code-entry').value = '';
189 remoting.setMode(remoting.AppMode.IN_SESSION); 194 remoting.setMode(remoting.AppMode.IN_SESSION);
190 if (!base.isAppsV2()) { 195 if (!base.isAppsV2()) {
191 remoting.toolbar.center(); 196 remoting.toolbar.center();
192 remoting.toolbar.preview(); 197 remoting.toolbar.preview();
193 } 198 }
194 199
195 if (remoting.desktopConnectedView.getMode() == 200 this.connectedView_ = new remoting.DesktopConnectedView(
196 remoting.DesktopConnectedView.Mode.ME2ME) { 201 document.getElementById('client-container'), connectionInfo,
202 this.getDefaultRemapKeys());
203
204 if (connectionInfo.mode() === remoting.DesktopConnectedView.Mode.ME2ME) {
197 var sessionConnector = remoting.app.getSessionConnector(); 205 var sessionConnector = remoting.app.getSessionConnector();
198 if (remoting.app.hasCapability(remoting.ClientSession.Capability.CAST)) { 206 if (remoting.app.hasCapability(remoting.ClientSession.Capability.CAST)) {
199 sessionConnector.registerProtocolExtension( 207 sessionConnector.registerProtocolExtension(
200 new remoting.CastExtensionHandler()); 208 new remoting.CastExtensionHandler());
201 } 209 }
202 sessionConnector.registerProtocolExtension( 210 sessionConnector.registerProtocolExtension(
203 new remoting.GnubbyAuthHandler()); 211 new remoting.GnubbyAuthHandler());
204 } 212 }
205 213
206 if (remoting.pairingRequested) { 214 if (remoting.pairingRequested) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 connectionInfo.session().requestPairing(clientName, onPairingComplete); 246 connectionInfo.session().requestPairing(clientName, onPairingComplete);
239 } 247 }
240 }; 248 };
241 249
242 /** 250 /**
243 * Called when the current session has been disconnected. 251 * Called when the current session has been disconnected.
244 * 252 *
245 * @return {void} Nothing. 253 * @return {void} Nothing.
246 */ 254 */
247 remoting.DesktopRemoting.prototype.handleDisconnected = function() { 255 remoting.DesktopRemoting.prototype.handleDisconnected = function() {
248 if (remoting.desktopConnectedView.getMode() == 256 var mode = this.connectedView_.getMode();
249 remoting.DesktopConnectedView.Mode.IT2ME) { 257 if (mode === remoting.DesktopConnectedView.Mode.IT2ME) {
250 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME); 258 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_IT2ME);
251 } else { 259 } else {
252 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); 260 remoting.setMode(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
253 } 261 }
262 base.dispose(this.connectedView_);
263 this.connectedView_ = null;
254 }; 264 };
255 265
256 /** 266 /**
257 * Called when the current session's connection has failed. 267 * Called when the current session's connection has failed.
258 * 268 *
259 * @param {remoting.SessionConnector} connector 269 * @param {remoting.SessionConnector} connector
260 * @param {!remoting.Error} error 270 * @param {!remoting.Error} error
261 * @return {void} Nothing. 271 * @return {void} Nothing.
262 */ 272 */
263 remoting.DesktopRemoting.prototype.handleConnectionFailed = function( 273 remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
(...skipping 26 matching lines...) Expand all
290 /** 300 /**
291 * Called when the current session has reached the point where the host has 301 * Called when the current session has reached the point where the host has
292 * started streaming video frames to the client. 302 * started streaming video frames to the client.
293 * 303 *
294 * @return {void} Nothing. 304 * @return {void} Nothing.
295 */ 305 */
296 remoting.DesktopRemoting.prototype.handleVideoStreamingStarted = function() { 306 remoting.DesktopRemoting.prototype.handleVideoStreamingStarted = function() {
297 }; 307 };
298 308
299 /** 309 /**
300 * @param {string} type The type of the extension message.
301 * @param {Object} message The parsed extension message data.
302 * @return {boolean} Return true if the extension message was recognized.
303 */
304 remoting.DesktopRemoting.prototype.handleExtensionMessage = function(
305 type, message) {
306 return false;
307 };
308
309 /**
310 * Called when an error needs to be displayed to the user. 310 * Called when an error needs to be displayed to the user.
311 * 311 *
312 * @param {!remoting.Error} error The error to be localized and displayed. 312 * @param {!remoting.Error} error The error to be localized and displayed.
313 * @return {void} Nothing. 313 * @return {void} Nothing.
314 */ 314 */
315 remoting.DesktopRemoting.prototype.handleError = function(error) { 315 remoting.DesktopRemoting.prototype.handleError = function(error) {
316 console.error('Connection failed: ' + error.toString()); 316 console.error('Connection failed: ' + error.toString());
317 remoting.accessCode = ''; 317 var mode = this.connectedView_ ? this.connectedView_.getMode()
318 : this.app_.getSessionConnector().getConnectionMode();
319 base.dispose(this.connectedView_);
320 this.connectedView_ = null;
318 321
319 if (error.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) { 322 if (error.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) {
320 remoting.setMode(remoting.AppMode.HOME); 323 remoting.setMode(remoting.AppMode.HOME);
321 remoting.handleAuthFailureAndRelaunch(); 324 remoting.handleAuthFailureAndRelaunch();
322 return; 325 return;
323 } 326 }
324 327
325 // Reset the refresh flag so that the next connection will retry if needed. 328 // Reset the refresh flag so that the next connection will retry if needed.
326 this.refreshHostJidIfOffline_ = true; 329 this.refreshHostJidIfOffline_ = true;
327 330
328 var errorDiv = document.getElementById('connect-error-message'); 331 var errorDiv = document.getElementById('connect-error-message');
329 l10n.localizeElementFromTag(errorDiv, error.getTag()); 332 l10n.localizeElementFromTag(errorDiv, error.getTag());
330 333
331 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode()
332 : this.app_.getSessionConnector().getConnectionMode();
333 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) { 334 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) {
334 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); 335 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
335 } else { 336 } else {
336 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); 337 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
337 } 338 }
338 }; 339 };
339 340
340 /** 341 /**
341 * No cleanup required for desktop remoting. 342 * No cleanup required for desktop remoting.
342 */ 343 */
343 remoting.DesktopRemoting.prototype.handleExit = function() { 344 remoting.DesktopRemoting.prototype.handleExit = function() {
344 }; 345 };
346
347 /** @returns {remoting.DesktopConnectedView} */
348 remoting.DesktopRemoting.prototype.getConnectedViewForTesting = function() {
349 return this.connectedView_;
350 };
351
352 /**
353 * Global instance of remoting.DesktopRemoting used for testing.
354 * @type {remoting.DesktopRemoting}
355 */
356 remoting.desktopDelegateForTesting = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698