OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Functions related to the 'host screen' for Chromoting. | 7 * Functions related to the 'host screen' for Chromoting. |
8 */ | 8 */ |
9 | 9 |
10 /** @suppress {duplicate} */ | 10 /** @suppress {duplicate} */ |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 if (!hasHostDialog) { | 52 if (!hasHostDialog) { |
53 hostInstallDialog = new remoting.HostInstallDialog(); | 53 hostInstallDialog = new remoting.HostInstallDialog(); |
54 hostInstallDialog.show(tryInitializeFacade, onInstallError); | 54 hostInstallDialog.show(tryInitializeFacade, onInstallError); |
55 } else { | 55 } else { |
56 hostInstallDialog.tryAgain(); | 56 hostInstallDialog.tryAgain(); |
57 } | 57 } |
58 }; | 58 }; |
59 | 59 |
60 /** @param {!remoting.Error} error */ | 60 /** @param {!remoting.Error} error */ |
61 var onInstallError = function(error) { | 61 var onInstallError = function(error) { |
62 if (error.tag == remoting.Error.Tag.CANCELLED) { | 62 if (error.hasTag(remoting.Error.Tag.CANCELLED)) { |
63 remoting.setMode(remoting.AppMode.HOME); | 63 remoting.setMode(remoting.AppMode.HOME); |
64 } else { | 64 } else { |
65 showShareError_(error); | 65 showShareError_(error); |
66 } | 66 } |
67 }; | 67 }; |
68 | 68 |
69 tryInitializeFacade(); | 69 tryInitializeFacade(); |
70 }; | 70 }; |
71 | 71 |
72 /** | 72 /** |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // clicking OK, which puts the app into mode HOME. | 162 // clicking OK, which puts the app into mode HOME. |
163 if (lastShareWasCancelled_) { | 163 if (lastShareWasCancelled_) { |
164 remoting.setMode(remoting.AppMode.HOME); | 164 remoting.setMode(remoting.AppMode.HOME); |
165 } else { | 165 } else { |
166 remoting.setMode(remoting.AppMode.HOST_SHARE_FINISHED); | 166 remoting.setMode(remoting.AppMode.HOST_SHARE_FINISHED); |
167 } | 167 } |
168 } | 168 } |
169 cleanUp(); | 169 cleanUp(); |
170 } else if (state == remoting.HostSession.State.ERROR) { | 170 } else if (state == remoting.HostSession.State.ERROR) { |
171 console.error('Host state: ERROR'); | 171 console.error('Host state: ERROR'); |
172 showShareError_(remoting.Error.UNEXPECTED); | 172 showShareError_(remoting.Error.unexpected()); |
173 } else if (state == remoting.HostSession.State.INVALID_DOMAIN_ERROR) { | 173 } else if (state == remoting.HostSession.State.INVALID_DOMAIN_ERROR) { |
174 console.error('Host state: INVALID_DOMAIN_ERROR'); | 174 console.error('Host state: INVALID_DOMAIN_ERROR'); |
175 showShareError_(remoting.Error.INVALID_HOST_DOMAIN); | 175 showShareError_(new remoting.Error(remoting.Error.Tag.INVALID_HOST_DOMAIN)); |
176 } else { | 176 } else { |
177 console.error('Unknown state -> ' + state); | 177 console.error('Unknown state -> ' + state); |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 /** | 181 /** |
182 * This is the callback that the host plugin invokes to indicate that there | 182 * This is the callback that the host plugin invokes to indicate that there |
183 * is additional debug log info to display. | 183 * is additional debug log info to display. |
184 * @param {string} msg The message (which will not be localized) to be logged. | 184 * @param {string} msg The message (which will not be localized) to be logged. |
185 */ | 185 */ |
(...skipping 18 matching lines...) Expand all Loading... |
204 /** | 204 /** |
205 * Show a sharing error with error code UNEXPECTED . | 205 * Show a sharing error with error code UNEXPECTED . |
206 * | 206 * |
207 * @return {void} Nothing. | 207 * @return {void} Nothing. |
208 */ | 208 */ |
209 function it2meConnectFailed_() { | 209 function it2meConnectFailed_() { |
210 // TODO (weitaosu): Instruct the user to install the native messaging host. | 210 // TODO (weitaosu): Instruct the user to install the native messaging host. |
211 // We probably want to add a new error code (with the corresponding error | 211 // We probably want to add a new error code (with the corresponding error |
212 // message for sharing error. | 212 // message for sharing error. |
213 console.error('Cannot share desktop.'); | 213 console.error('Cannot share desktop.'); |
214 showShareError_(remoting.Error.UNEXPECTED); | 214 showShareError_(remoting.Error.unexpected()); |
215 } | 215 } |
216 | 216 |
217 function cleanUp() { | 217 function cleanUp() { |
218 base.dispose(hostSession_); | 218 base.dispose(hostSession_); |
219 hostSession_ = null; | 219 hostSession_ = null; |
220 } | 220 } |
221 | 221 |
222 /** | 222 /** |
223 * Cancel an active or pending it2me share operation. | 223 * Cancel an active or pending it2me share operation. |
224 * | 224 * |
225 * @return {void} Nothing. | 225 * @return {void} Nothing. |
226 */ | 226 */ |
227 remoting.cancelShare = function() { | 227 remoting.cancelShare = function() { |
228 document.getElementById('cancel-share-button').disabled = true; | 228 document.getElementById('cancel-share-button').disabled = true; |
229 console.log('Canceling share...'); | 229 console.log('Canceling share...'); |
230 remoting.lastShareWasCancelled = true; | 230 remoting.lastShareWasCancelled = true; |
231 try { | 231 try { |
232 hostSession_.disconnect(); | 232 hostSession_.disconnect(); |
233 } catch (/** @type {*} */ error) { | 233 } catch (/** @type {*} */ error) { |
234 console.error('Error disconnecting: ' + error + | 234 console.error('Error disconnecting: ' + error + |
235 '. The host probably crashed.'); | 235 '. The host probably crashed.'); |
236 // TODO(jamiewalch): Clean this up. We should have a class representing | 236 // TODO(jamiewalch): Clean this up. We should have a class representing |
237 // the host plugin, like we do for the client, which should handle crash | 237 // the host plugin, like we do for the client, which should handle crash |
238 // reporting and it should use a more detailed error message than the | 238 // reporting and it should use a more detailed error message than the |
239 // default 'generic' one. See crbug.com/94624 | 239 // default 'generic' one. See crbug.com/94624 |
240 showShareError_(remoting.Error.UNEXPECTED); | 240 showShareError_(remoting.Error.unexpected()); |
241 } | 241 } |
242 disableTimeoutCountdown_(); | 242 disableTimeoutCountdown_(); |
243 }; | 243 }; |
244 | 244 |
245 /** | 245 /** |
246 * @type {boolean} Whether or not the access code timeout countdown is running. | 246 * @type {boolean} Whether or not the access code timeout countdown is running. |
247 */ | 247 */ |
248 var timerRunning_ = false; | 248 var timerRunning_ = false; |
249 | 249 |
250 /** | 250 /** |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 function onNatTraversalPolicyChanged_(enabled) { | 332 function onNatTraversalPolicyChanged_(enabled) { |
333 var natBox = document.getElementById('nat-box'); | 333 var natBox = document.getElementById('nat-box'); |
334 if (enabled) { | 334 if (enabled) { |
335 natBox.classList.add('traversal-enabled'); | 335 natBox.classList.add('traversal-enabled'); |
336 } else { | 336 } else { |
337 natBox.classList.remove('traversal-enabled'); | 337 natBox.classList.remove('traversal-enabled'); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 })(); | 341 })(); |
OLD | NEW |