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

Side by Side Diff: remoting/webapp/app_remoting/js/app_remoting_activity.js

Issue 1097133002: [Webapp Refactor] Remove remoting.SessionConnector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflicts 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/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.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 /** 8 /**
9 * Type definition for the RunApplicationResponse returned by the API. 9 * Type definition for the RunApplicationResponse returned by the API.
10 * @typedef {{ 10 * @typedef {{
(...skipping 17 matching lines...) Expand all
28 * @param {Array<string>} appCapabilities Array of application capabilities. 28 * @param {Array<string>} appCapabilities Array of application capabilities.
29 * 29 *
30 * @constructor 30 * @constructor
31 * @implements {remoting.Activity} 31 * @implements {remoting.Activity}
32 */ 32 */
33 remoting.AppRemotingActivity = function(appCapabilities) { 33 remoting.AppRemotingActivity = function(appCapabilities) {
34 /** @private {remoting.AppConnectedView} */ 34 /** @private {remoting.AppConnectedView} */
35 this.connectedView_ = null; 35 this.connectedView_ = null;
36 36
37 /** @private */ 37 /** @private */
38 this.connector_ = remoting.SessionConnector.factory.createConnector( 38 this.sessionFactory_ = new remoting.ClientSessionFactory(
39 document.getElementById('client-container'), appCapabilities, 39 document.querySelector('#client-container .client-plugin-container'),
40 this); 40 appCapabilities);
41 41
42 /** @private {remoting.ClientSession} */ 42 /** @private {remoting.ClientSession} */
43 this.session_ = null; 43 this.session_ = null;
44 }; 44 };
45 45
46 remoting.AppRemotingActivity.prototype.dispose = function() { 46 remoting.AppRemotingActivity.prototype.dispose = function() {
47 base.dispose(this.connectedView_); 47 base.dispose(this.connectedView_);
48 this.connectedView_ = null; 48 this.connectedView_ = null;
49 remoting.LoadingWindow.close(); 49 remoting.LoadingWindow.close();
50 }; 50 };
(...skipping 11 matching lines...) Expand all
62 remoting.AppRemotingActivity.prototype.stop = function() { 62 remoting.AppRemotingActivity.prototype.stop = function() {
63 if (this.session_) { 63 if (this.session_) {
64 this.session_.disconnect(remoting.Error.none()); 64 this.session_.disconnect(remoting.Error.none());
65 } 65 }
66 }; 66 };
67 67
68 /** @private */ 68 /** @private */
69 remoting.AppRemotingActivity.prototype.cleanup_ = function() { 69 remoting.AppRemotingActivity.prototype.cleanup_ = function() {
70 base.dispose(this.connectedView_); 70 base.dispose(this.connectedView_);
71 this.connectedView_ = null; 71 this.connectedView_ = null;
72 base.dispose(this.session_);
72 this.session_ = null; 73 this.session_ = null;
73 }; 74 };
74 75
75 /** 76 /**
76 * @param {string} token 77 * @param {string} token
77 * @return {Promise<!remoting.Xhr.Response>} 78 * @return {Promise<!remoting.Xhr.Response>}
78 * @private 79 * @private
79 */ 80 */
80 remoting.AppRemotingActivity.prototype.getAppHostInfo_ = function(token) { 81 remoting.AppRemotingActivity.prototype.getAppHostInfo_ = function(token) {
81 var url = remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + 82 var url = remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' +
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 * @param {function(string, string):void} onThirdPartyTokenFetched 121 * @param {function(string, string):void} onThirdPartyTokenFetched
121 * Callback. 122 * Callback.
122 */ 123 */
123 var fetchThirdPartyToken = function( 124 var fetchThirdPartyToken = function(
124 tokenUrl, hostPublicKey, scope, onThirdPartyTokenFetched) { 125 tokenUrl, hostPublicKey, scope, onThirdPartyTokenFetched) {
125 // Use the authentication tokens returned by the app-remoting server. 126 // Use the authentication tokens returned by the app-remoting server.
126 onThirdPartyTokenFetched(host['authorizationCode'], 127 onThirdPartyTokenFetched(host['authorizationCode'],
127 host['sharedSecret']); 128 host['sharedSecret']);
128 }; 129 };
129 130
130 this.connector_.connect( 131 remoting.app.setConnectionMode(remoting.Application.Mode.APP_REMOTING);
131 remoting.Application.Mode.APP_REMOTING, host, 132 var credentialsProvider = new remoting.CredentialsProvider(
132 new remoting.CredentialsProvider( 133 {fetchThirdPartyToken: fetchThirdPartyToken});
133 {fetchThirdPartyToken: fetchThirdPartyToken})); 134 var that = this;
134 135
136 this.sessionFactory_.createSession(this).then(
137 function(/** remoting.ClientSession */ session) {
138 that.session_ = session;
139 session.logHostOfflineErrors(true);
140 session.connect(host, credentialsProvider);
141 });
135 } else if (response && response.status == 'pending') { 142 } else if (response && response.status == 'pending') {
136 this.onError(new remoting.Error( 143 this.onError(new remoting.Error(
137 remoting.Error.Tag.SERVICE_UNAVAILABLE)); 144 remoting.Error.Tag.SERVICE_UNAVAILABLE));
138 } 145 }
139 } else { 146 } else {
140 console.error('Invalid "runApplication" response from server.'); 147 console.error('Invalid "runApplication" response from server.');
141 this.onError(remoting.Error.fromHttpStatus(xhrResponse.status)); 148 this.onError(remoting.Error.fromHttpStatus(xhrResponse.status));
142 } 149 }
143 }; 150 };
144 151
145 /** 152 /**
146 * @param {remoting.ConnectionInfo} connectionInfo 153 * @param {remoting.ConnectionInfo} connectionInfo
147 */ 154 */
148 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) { 155 remoting.AppRemotingActivity.prototype.onConnected = function(connectionInfo) {
149 this.connectedView_ = new remoting.AppConnectedView( 156 this.connectedView_ = new remoting.AppConnectedView(
150 document.getElementById('client-container'), connectionInfo); 157 document.getElementById('client-container'), connectionInfo);
151 158
152 this.session_ = connectionInfo.session();
153 var idleDetector = new remoting.IdleDetector( 159 var idleDetector = new remoting.IdleDetector(
154 document.getElementById('idle-dialog'), this.stop.bind(this)); 160 document.getElementById('idle-dialog'), this.stop.bind(this));
155 161
156 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard 162 // Map Cmd to Ctrl on Mac since hosts typically use Ctrl for keyboard
157 // shortcuts, but we want them to act as natively as possible. 163 // shortcuts, but we want them to act as natively as possible.
158 if (remoting.platformIsMac()) { 164 if (remoting.platformIsMac()) {
159 connectionInfo.plugin().setRemapKeys('0x0700e3>0x0700e0,0x0700e7>0x0700e4'); 165 connectionInfo.plugin().setRemapKeys('0x0700e3>0x0700e0,0x0700e7>0x0700e4');
160 } 166 }
161 }; 167 };
162 168
(...skipping 15 matching lines...) Expand all
178 remoting.AppRemotingActivity.prototype.onError = function(error) { 184 remoting.AppRemotingActivity.prototype.onError = function(error) {
179 console.error('Connection failed: ' + error.toString()); 185 console.error('Connection failed: ' + error.toString());
180 remoting.LoadingWindow.close(); 186 remoting.LoadingWindow.close();
181 remoting.MessageWindow.showErrorMessage( 187 remoting.MessageWindow.showErrorMessage(
182 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'), 188 chrome.i18n.getMessage(/*i18n-content*/'CONNECTION_FAILED'),
183 chrome.i18n.getMessage(error.getTag())); 189 chrome.i18n.getMessage(error.getTag()));
184 this.cleanup_(); 190 this.cleanup_();
185 }; 191 };
186 192
187 })(); 193 })();
OLDNEW
« no previous file with comments | « remoting/remoting_webapp_files.gypi ('k') | remoting/webapp/base/js/application.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698