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 'use strict'; | 10 'use strict'; |
(...skipping 15 matching lines...) Expand all Loading... |
26 * to install them if necessary. | 26 * to install them if necessary. |
27 */ | 27 */ |
28 remoting.tryShare = function() { | 28 remoting.tryShare = function() { |
29 /** @type {remoting.HostIt2MeDispatcher} */ | 29 /** @type {remoting.HostIt2MeDispatcher} */ |
30 var hostDispatcher = new remoting.HostIt2MeDispatcher(); | 30 var hostDispatcher = new remoting.HostIt2MeDispatcher(); |
31 | 31 |
32 /** @type {remoting.HostInstallDialog} */ | 32 /** @type {remoting.HostInstallDialog} */ |
33 var hostInstallDialog = null; | 33 var hostInstallDialog = null; |
34 | 34 |
35 var tryInitializeDispatcher = function() { | 35 var tryInitializeDispatcher = function() { |
36 hostDispatcher.initialize(onDispatcherInitialized, | 36 hostDispatcher.initialize(createPluginForIt2Me, |
| 37 onDispatcherInitialized, |
37 onDispatcherInitializationFailed); | 38 onDispatcherInitializationFailed); |
38 } | 39 } |
39 | 40 |
| 41 /** @return {remoting.HostPlugin} */ |
| 42 var createPluginForIt2Me = function() { |
| 43 return remoting.createNpapiPlugin( |
| 44 document.getElementById('host-plugin-container')); |
| 45 } |
| 46 |
40 var onDispatcherInitialized = function () { | 47 var onDispatcherInitialized = function () { |
41 // Host already installed. | 48 if (hostDispatcher.usingNpapi()) { |
42 remoting.startHostUsingDispatcher_(hostDispatcher); | 49 hostInstallDialog = new remoting.HostInstallDialog(); |
| 50 hostInstallDialog.show(tryInitializeDispatcher, onInstallError); |
| 51 } else { |
| 52 // Host alrady installed. |
| 53 remoting.startHostUsingDispatcher_(hostDispatcher); |
| 54 } |
43 }; | 55 }; |
44 | 56 |
45 /** @param {remoting.Error} error */ | 57 /** @param {remoting.Error} error */ |
46 var onDispatcherInitializationFailed = function(error) { | 58 var onDispatcherInitializationFailed = function(error) { |
47 if (error != remoting.Error.MISSING_PLUGIN) { | 59 if (error != remoting.Error.MISSING_PLUGIN) { |
48 showShareError_(error); | 60 showShareError_(error); |
49 return; | 61 return; |
50 } | 62 } |
51 | 63 |
52 // If we failed to initialize the dispatcher then prompt the user to install | 64 // If we failed to initialize the dispatcher then prompt the user to install |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 if (remoting.currentMode != remoting.AppMode.HOST_SHARE_FAILED) { | 174 if (remoting.currentMode != remoting.AppMode.HOST_SHARE_FAILED) { |
163 // If an error is being displayed, then the plugin should not be able to | 175 // If an error is being displayed, then the plugin should not be able to |
164 // hide it by setting the state. Errors must be dismissed by the user | 176 // hide it by setting the state. Errors must be dismissed by the user |
165 // clicking OK, which puts the app into mode HOME. | 177 // clicking OK, which puts the app into mode HOME. |
166 if (lastShareWasCancelled_) { | 178 if (lastShareWasCancelled_) { |
167 remoting.setMode(remoting.AppMode.HOME); | 179 remoting.setMode(remoting.AppMode.HOME); |
168 } else { | 180 } else { |
169 remoting.setMode(remoting.AppMode.HOST_SHARE_FINISHED); | 181 remoting.setMode(remoting.AppMode.HOST_SHARE_FINISHED); |
170 } | 182 } |
171 } | 183 } |
| 184 remoting.hostSession.cleanup(); |
| 185 |
172 } else if (state == remoting.HostSession.State.ERROR) { | 186 } else if (state == remoting.HostSession.State.ERROR) { |
173 console.error('Host state: ERROR'); | 187 console.error('Host state: ERROR'); |
174 showShareError_(remoting.Error.UNEXPECTED); | 188 showShareError_(remoting.Error.UNEXPECTED); |
175 } else if (state == remoting.HostSession.State.INVALID_DOMAIN_ERROR) { | 189 } else if (state == remoting.HostSession.State.INVALID_DOMAIN_ERROR) { |
176 console.error('Host state: INVALID_DOMAIN_ERROR'); | 190 console.error('Host state: INVALID_DOMAIN_ERROR'); |
177 showShareError_(remoting.Error.INVALID_HOST_DOMAIN); | 191 showShareError_(remoting.Error.INVALID_HOST_DOMAIN); |
178 } else { | 192 } else { |
179 console.error('Unknown state -> ' + state); | 193 console.error('Unknown state -> ' + state); |
180 } | 194 } |
181 } | 195 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 * @private | 354 * @private |
341 */ | 355 */ |
342 function onNatTraversalPolicyChanged_(enabled) { | 356 function onNatTraversalPolicyChanged_(enabled) { |
343 var natBox = document.getElementById('nat-box'); | 357 var natBox = document.getElementById('nat-box'); |
344 if (enabled) { | 358 if (enabled) { |
345 natBox.classList.add('traversal-enabled'); | 359 natBox.classList.add('traversal-enabled'); |
346 } else { | 360 } else { |
347 natBox.classList.remove('traversal-enabled'); | 361 natBox.classList.remove('traversal-enabled'); |
348 } | 362 } |
349 } | 363 } |
OLD | NEW |