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

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

Issue 1093373005: [Webapp Refactor] Cleans up the ClientSession.EventHandler interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 if (error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) && 133 if (error.hasTag(remoting.Error.Tag.HOST_IS_OFFLINE) &&
134 this.retryOnHostOffline_) { 134 this.retryOnHostOffline_) {
135 var that = this; 135 var that = this;
136 var onHostListRefresh = function(/** boolean */ success) { 136 var onHostListRefresh = function(/** boolean */ success) {
137 if (success) { 137 if (success) {
138 // Get the host from the hostList for the refreshed JID. 138 // Get the host from the hostList for the refreshed JID.
139 that.host_ = remoting.hostList.getHostForId(that.host_.hostId); 139 that.host_ = remoting.hostList.getHostForId(that.host_.hostId);
140 that.connect_(false); 140 that.connect_(false);
141 return; 141 return;
142 } 142 }
143 that.onError(error); 143 that.showErrorMessage_(error);
144 }; 144 };
145 this.retryOnHostOffline_ = false; 145 this.retryOnHostOffline_ = false;
146 146
147 // The plugin will be re-created when the host finished refreshing 147 // The plugin will be re-created when the host finished refreshing
148 remoting.hostList.refresh(onHostListRefresh); 148 remoting.hostList.refresh(onHostListRefresh);
149 } else { 149 } else if (!error.isNone()) {
150 this.onError(error); 150 this.showErrorMessage_(error);
151 } 151 }
152
153 base.dispose(this.desktopActivity_);
154 this.desktopActivity_ = null;
152 }; 155 };
153 156
154 /** 157 /**
155 * @param {!remoting.ConnectionInfo} connectionInfo 158 * @param {!remoting.ConnectionInfo} connectionInfo
156 */ 159 */
157 remoting.Me2MeActivity.prototype.onConnected = function(connectionInfo) { 160 remoting.Me2MeActivity.prototype.onConnected = function(connectionInfo) {
158 // Reset the refresh flag so that the next connection will retry if needed. 161 // Reset the refresh flag so that the next connection will retry if needed.
159 this.retryOnHostOffline_ = true; 162 this.retryOnHostOffline_ = true;
160 163
161 var plugin = connectionInfo.plugin(); 164 var plugin = connectionInfo.plugin();
162 if (plugin.hasCapability(remoting.ClientSession.Capability.CAST)) { 165 if (plugin.hasCapability(remoting.ClientSession.Capability.CAST)) {
163 plugin.extensions().register(new remoting.CastExtensionHandler()); 166 plugin.extensions().register(new remoting.CastExtensionHandler());
164 } 167 }
165 plugin.extensions().register(new remoting.GnubbyAuthHandler()); 168 plugin.extensions().register(new remoting.GnubbyAuthHandler());
166 this.pinDialog_.requestPairingIfNecessary(connectionInfo.plugin()); 169 this.pinDialog_.requestPairingIfNecessary(connectionInfo.plugin());
167 170
168 base.dispose(this.reconnector_); 171 base.dispose(this.reconnector_);
169 this.reconnector_ = new remoting.SmartReconnector( 172 this.reconnector_ = new remoting.SmartReconnector(
170 this.connect_.bind(this, false), 173 this.connect_.bind(this, false),
171 this.stop.bind(this), 174 this.stop.bind(this),
172 connectionInfo.session()); 175 connectionInfo.session());
173 }; 176 };
174 177
175 remoting.Me2MeActivity.prototype.onDisconnected = function() { 178 remoting.Me2MeActivity.prototype.onDisconnected = function(error) {
176 this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME); 179 if (error.isNone()) {
180 this.showFinishDialog_(remoting.AppMode.CLIENT_SESSION_FINISHED_ME2ME);
181 } else {
182 this.reconnector_.onConnectionDropped(error);
183 this.showErrorMessage_(error);
184 }
185
186 base.dispose(this.desktopActivity_);
187 this.desktopActivity_ = null;
177 }; 188 };
178 189
179 /** 190 /**
180 * @param {!remoting.Error} error 191 * @param {!remoting.Error} error
192 * @private
181 */ 193 */
182 remoting.Me2MeActivity.prototype.onError = function(error) { 194 remoting.Me2MeActivity.prototype.showErrorMessage_ = function(error) {
183 var errorDiv = document.getElementById('connect-error-message'); 195 var errorDiv = document.getElementById('connect-error-message');
184 l10n.localizeElementFromTag(errorDiv, error.getTag()); 196 l10n.localizeElementFromTag(errorDiv, error.getTag());
185 this.showFinishDialog_(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); 197 this.showFinishDialog_(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
186 }; 198 };
187 199
188 /** 200 /**
189 * @param {remoting.AppMode} mode 201 * @param {remoting.AppMode} mode
190 * @private 202 * @private
191 */ 203 */
192 remoting.Me2MeActivity.prototype.showFinishDialog_ = function(mode) { 204 remoting.Me2MeActivity.prototype.showFinishDialog_ = function(mode) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 clientName = 'Linux'; 330 clientName = 'Linux';
319 } else { 331 } else {
320 console.log('Unrecognized client platform. Using navigator.platform.'); 332 console.log('Unrecognized client platform. Using navigator.platform.');
321 clientName = navigator.platform; 333 clientName = navigator.platform;
322 } 334 }
323 plugin.requestPairing(clientName, onPairingComplete); 335 plugin.requestPairing(clientName, onPairingComplete);
324 } 336 }
325 }; 337 };
326 338
327 })(); 339 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698