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

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

Issue 1101613003: [Webapp Refactor] Reliably cancels a connection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ImproveUnittest
Patch Set: Rebase 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/desktop_remoting.js ('k') | remoting/webapp/crd/js/it2me_activity.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** @suppress {duplicate} */ 5 /** @suppress {duplicate} */
6 var remoting = remoting || {}; 6 var remoting = remoting || {};
7 7
8 (function() { 8 (function() {
9 9
10 'use strict'; 10 'use strict';
(...skipping 12 matching lines...) Expand all
23 /** @private */ 23 /** @private */
24 this.parentActivity_ = parentActivity; 24 this.parentActivity_ = parentActivity;
25 /** @private {remoting.DesktopConnectedView} */ 25 /** @private {remoting.DesktopConnectedView} */
26 this.connectedView_ = null; 26 this.connectedView_ = null;
27 /** @private */ 27 /** @private */
28 this.sessionFactory_ = new remoting.ClientSessionFactory( 28 this.sessionFactory_ = new remoting.ClientSessionFactory(
29 document.querySelector('#client-container .client-plugin-container'), 29 document.querySelector('#client-container .client-plugin-container'),
30 remoting.app_capabilities()); 30 remoting.app_capabilities());
31 /** @private {remoting.ClientSession} */ 31 /** @private {remoting.ClientSession} */
32 this.session_ = null; 32 this.session_ = null;
33 /** @private {remoting.ConnectingDialog} */
34 this.connectingDialog_ =
35 new remoting.ConnectingDialog(parentActivity.stop.bind(parentActivity));
33 }; 36 };
34 37
35 /** 38 /**
36 * Initiates a connection. 39 * Initiates a connection.
37 * 40 *
38 * @param {remoting.Host} host the Host to connect to. 41 * @param {remoting.Host} host the Host to connect to.
39 * @param {remoting.CredentialsProvider} credentialsProvider 42 * @param {remoting.CredentialsProvider} credentialsProvider
40 * @param {boolean=} opt_suppressOfflineError 43 * @param {boolean=} opt_suppressOfflineError
41 * @return {void} Nothing. 44 * @return {void} Nothing.
42 */ 45 */
43 remoting.DesktopRemotingActivity.prototype.start = 46 remoting.DesktopRemotingActivity.prototype.start =
44 function(host, credentialsProvider, opt_suppressOfflineError) { 47 function(host, credentialsProvider, opt_suppressOfflineError) {
45 var that = this; 48 var that = this;
46 this.sessionFactory_.createSession(this).then( 49 this.sessionFactory_.createSession(this).then(
47 function(/** remoting.ClientSession */ session) { 50 function(/** remoting.ClientSession */ session) {
48 that.session_ = session; 51 that.session_ = session;
49 session.logHostOfflineErrors(!opt_suppressOfflineError); 52 session.logHostOfflineErrors(!opt_suppressOfflineError);
50 session.connect(host, credentialsProvider); 53 session.connect(host, credentialsProvider);
51 }); 54 }).catch(remoting.Error.handler(
55 function(/** !remoting.Error */ error) {
56 that.parentActivity_.onConnectionFailed(error);
57 }));
52 }; 58 };
53 59
54 remoting.DesktopRemotingActivity.prototype.stop = function() { 60 remoting.DesktopRemotingActivity.prototype.stop = function() {
55 if (this.session_) { 61 if (this.session_) {
56 this.session_.disconnect(remoting.Error.none()); 62 this.session_.disconnect(remoting.Error.none());
57 console.log('Disconnected.'); 63 console.log('Disconnected.');
58 } 64 }
59 }; 65 };
60 66
61 /** 67 /**
62 * @param {remoting.ConnectionInfo} connectionInfo 68 * @param {remoting.ConnectionInfo} connectionInfo
63 */ 69 */
64 remoting.DesktopRemotingActivity.prototype.onConnected = 70 remoting.DesktopRemotingActivity.prototype.onConnected =
65 function(connectionInfo) { 71 function(connectionInfo) {
72 this.connectingDialog_.hide();
66 remoting.setMode(remoting.AppMode.IN_SESSION); 73 remoting.setMode(remoting.AppMode.IN_SESSION);
67 if (!base.isAppsV2()) { 74 if (!base.isAppsV2()) {
68 remoting.toolbar.center(); 75 remoting.toolbar.center();
69 remoting.toolbar.preview(); 76 remoting.toolbar.preview();
70 } 77 }
71 78
72 this.connectedView_ = new remoting.DesktopConnectedView( 79 this.connectedView_ = new remoting.DesktopConnectedView(
73 document.getElementById('client-container'), connectionInfo); 80 document.getElementById('client-container'), connectionInfo);
74 81
75 // By default, under ChromeOS, remap the right Control key to the right 82 // By default, under ChromeOS, remap the right Control key to the right
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return true; 125 return true;
119 } 126 }
120 return false; 127 return false;
121 }; 128 };
122 129
123 remoting.DesktopRemotingActivity.prototype.dispose = function() { 130 remoting.DesktopRemotingActivity.prototype.dispose = function() {
124 base.dispose(this.connectedView_); 131 base.dispose(this.connectedView_);
125 this.connectedView_ = null; 132 this.connectedView_ = null;
126 base.dispose(this.session_); 133 base.dispose(this.session_);
127 this.session_ = null; 134 this.session_ = null;
135 this.connectingDialog_.hide();
128 }; 136 };
129 137
130 /** @return {remoting.DesktopConnectedView} */ 138 /** @return {remoting.DesktopConnectedView} */
131 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() { 139 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() {
132 return this.connectedView_; 140 return this.connectedView_;
133 }; 141 };
134 142
135 /** 143 /**
136 * @return {remoting.ClientSession}. 144 * @return {remoting.ClientSession}.
137 */ 145 */
138 remoting.DesktopRemotingActivity.prototype.getSession = function() { 146 remoting.DesktopRemotingActivity.prototype.getSession = function() {
139 return this.session_; 147 return this.session_;
140 }; 148 };
141 149
150 /** @return {remoting.ConnectingDialog} */
151 remoting.DesktopRemotingActivity.prototype.getConnectingDialog = function() {
152 return this.connectingDialog_;
153 };
154
142 })(); 155 })();
OLDNEW
« no previous file with comments | « remoting/webapp/crd/js/desktop_remoting.js ('k') | remoting/webapp/crd/js/it2me_activity.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698