| OLD | NEW |
| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 if (connectionInfo.plugin().hasCapability( | 81 if (connectionInfo.plugin().hasCapability( |
| 82 remoting.ClientSession.Capability.VIDEO_RECORDER)) { | 82 remoting.ClientSession.Capability.VIDEO_RECORDER)) { |
| 83 var recorder = new remoting.VideoFrameRecorder(); | 83 var recorder = new remoting.VideoFrameRecorder(); |
| 84 connectionInfo.plugin().extensions().register(recorder); | 84 connectionInfo.plugin().extensions().register(recorder); |
| 85 this.connectedView_.setVideoFrameRecorder(recorder); | 85 this.connectedView_.setVideoFrameRecorder(recorder); |
| 86 } | 86 } |
| 87 | 87 |
| 88 this.parentActivity_.onConnected(connectionInfo); | 88 this.parentActivity_.onConnected(connectionInfo); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 remoting.DesktopRemotingActivity.prototype.onDisconnected = function() { | 91 remoting.DesktopRemotingActivity.prototype.onDisconnected = function(reason) { |
| 92 this.parentActivity_.onDisconnected(); | 92 if (this.handleError_(reason)) { |
| 93 this.dispose(); | 93 return; |
| 94 } |
| 95 this.parentActivity_.onDisconnected(reason); |
| 94 }; | 96 }; |
| 95 | 97 |
| 96 /** | 98 /** |
| 97 * @param {!remoting.Error} error | 99 * @param {!remoting.Error} error |
| 98 */ | 100 */ |
| 99 remoting.DesktopRemotingActivity.prototype.onConnectionFailed = | 101 remoting.DesktopRemotingActivity.prototype.onConnectionFailed = |
| 100 function(error) { | 102 function(error) { |
| 103 if (this.handleError_(error)) { |
| 104 return; |
| 105 } |
| 101 this.parentActivity_.onConnectionFailed(error); | 106 this.parentActivity_.onConnectionFailed(error); |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 /** | 109 /** |
| 105 * @param {!remoting.Error} error The error to be localized and displayed. | 110 * @param {!remoting.Error} error The error to be localized and displayed. |
| 111 * @return {boolean} returns true if the error is handled. |
| 112 * @private |
| 106 */ | 113 */ |
| 107 remoting.DesktopRemotingActivity.prototype.onError = function(error) { | 114 remoting.DesktopRemotingActivity.prototype.handleError_ = function(error) { |
| 108 console.error('Connection failed: ' + error.toString()); | |
| 109 | |
| 110 if (error.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) { | 115 if (error.hasTag(remoting.Error.Tag.AUTHENTICATION_FAILED)) { |
| 111 remoting.setMode(remoting.AppMode.HOME); | 116 remoting.setMode(remoting.AppMode.HOME); |
| 112 remoting.handleAuthFailureAndRelaunch(); | 117 remoting.handleAuthFailureAndRelaunch(); |
| 113 return; | 118 return true; |
| 114 } | 119 } |
| 115 | 120 return false; |
| 116 this.parentActivity_.onError(error); | |
| 117 | |
| 118 this.dispose(); | |
| 119 }; | 121 }; |
| 120 | 122 |
| 121 remoting.DesktopRemotingActivity.prototype.dispose = function() { | 123 remoting.DesktopRemotingActivity.prototype.dispose = function() { |
| 122 base.dispose(this.connectedView_); | 124 base.dispose(this.connectedView_); |
| 123 this.connectedView_ = null; | 125 this.connectedView_ = null; |
| 124 base.dispose(this.session_); | 126 base.dispose(this.session_); |
| 125 this.session_ = null; | 127 this.session_ = null; |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 /** @return {remoting.DesktopConnectedView} */ | 130 /** @return {remoting.DesktopConnectedView} */ |
| 129 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() { | 131 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() { |
| 130 return this.connectedView_; | 132 return this.connectedView_; |
| 131 }; | 133 }; |
| 132 | 134 |
| 133 /** | 135 /** |
| 134 * @return {remoting.ClientSession}. | 136 * @return {remoting.ClientSession}. |
| 135 */ | 137 */ |
| 136 remoting.DesktopRemotingActivity.prototype.getSession = function() { | 138 remoting.DesktopRemotingActivity.prototype.getSession = function() { |
| 137 return this.session_; | 139 return this.session_; |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 })(); | 142 })(); |
| OLD | NEW |