Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 onDispatcherInitialized, | 37 onDispatcherInitialized, |
| 38 onDispatcherInitializationFailed); | 38 onDispatcherInitializationFailed); |
| 39 } | 39 } |
| 40 | 40 |
| 41 /** @return {remoting.HostPlugin} */ | 41 /** @return {remoting.HostPlugin} */ |
| 42 var createPluginForIt2Me = function() { | 42 var createPluginForIt2Me = function() { |
| 43 return remoting.createNpapiPlugin( | 43 return remoting.createNpapiPlugin( |
| 44 document.getElementById('host-plugin-container')); | 44 document.getElementById('host-plugin-container')); |
| 45 } | 45 } |
| 46 | 46 |
| 47 /** @param {remoting.HostController.AsyncResult} asyncResult */ | |
| 48 var onHostInstalled = function(asyncResult) { | |
| 49 if (asyncResult == remoting.HostController.AsyncResult.OK) { | |
| 50 tryInitializeDispatcher(); | |
| 51 } else if (asyncResult == remoting.HostController.AsyncResult.CANCELLED) { | |
| 52 onInstallError(remoting.Error.CANCELLED); | |
| 53 } else { | |
| 54 onInstallError(remoting.Error.UNEXPECTED); | |
| 55 } | |
| 56 }; | |
| 57 | |
| 58 var onDispatcherInitialized = function () { | 47 var onDispatcherInitialized = function () { |
| 59 if (hostDispatcher.usingNpapi()) { | 48 if (hostDispatcher.usingNpapi()) { |
| 60 hostInstallDialog = new remoting.HostInstallDialog(); | 49 hostInstallDialog = new remoting.HostInstallDialog(); |
| 61 if (navigator.platform == 'Win32') { | 50 hostInstallDialog.show(tryInitializeDispatcher, onInstallError); |
| 62 hostInstallDialog.show( | |
| 63 hostDispatcher.getNpapiHost(), onHostInstalled, onInstallError); | |
| 64 } else { | |
| 65 hostInstallDialog.show(null, onHostInstalled, onInstallError); | |
| 66 } | |
| 67 } else { | 51 } else { |
| 68 // Host alrady installed. | 52 // Host alrady installed. |
| 69 remoting.startHostUsingDispatcher_(hostDispatcher); | 53 remoting.startHostUsingDispatcher_(hostDispatcher); |
| 70 } | 54 } |
| 71 }; | 55 }; |
| 72 | 56 |
| 73 /** @param {remoting.Error} error */ | 57 /** @param {remoting.Error} error */ |
| 74 var onDispatcherInitializationFailed = function(error) { | 58 var onDispatcherInitializationFailed = function(error) { |
| 75 if (error != remoting.Error.MISSING_PLUGIN) { | 59 if (error != remoting.Error.MISSING_PLUGIN) { |
| 76 showShareError_(error); | 60 showShareError_(error); |
| 77 return; | 61 return; |
| 78 } | 62 } |
| 79 | 63 |
| 80 // 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 |
| 81 // the host manually. | 65 // the host manually. |
| 82 if (hostInstallDialog == null) { | 66 if (hostInstallDialog == null) { |
| 83 hostInstallDialog = new remoting.HostInstallDialog(); | 67 hostInstallDialog = new remoting.HostInstallDialog(); |
| 84 | 68 |
| 85 (/** @type {remoting.HostInstallDialog} */ hostInstallDialog).show( | 69 hostInstallDialog.show(tryInitializeDispatcher, onInstallError); |
|
Sergey Ulanov
2014/05/24 01:50:34
does this still typecheck, without the type annota
| |
| 86 null, onHostInstalled, onInstallError); | |
| 87 } else { | 70 } else { |
| 88 (/** @type {remoting.HostInstallDialog} */ hostInstallDialog).tryAgain(); | 71 hostInstallDialog.tryAgain(); |
| 89 } | 72 } |
| 90 }; | 73 }; |
| 91 | 74 |
| 92 /** @param {remoting.Error} error */ | 75 /** @param {remoting.Error} error */ |
| 93 var onInstallError = function(error) { | 76 var onInstallError = function(error) { |
| 94 if (error == remoting.Error.CANCELLED) { | 77 if (error == remoting.Error.CANCELLED) { |
| 95 remoting.setMode(remoting.AppMode.HOME); | 78 remoting.setMode(remoting.AppMode.HOME); |
| 96 } else { | 79 } else { |
| 97 showShareError_(error); | 80 showShareError_(error); |
| 98 } | 81 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 370 * @private | 353 * @private |
| 371 */ | 354 */ |
| 372 function onNatTraversalPolicyChanged_(enabled) { | 355 function onNatTraversalPolicyChanged_(enabled) { |
| 373 var natBox = document.getElementById('nat-box'); | 356 var natBox = document.getElementById('nat-box'); |
| 374 if (enabled) { | 357 if (enabled) { |
| 375 natBox.classList.add('traversal-enabled'); | 358 natBox.classList.add('traversal-enabled'); |
| 376 } else { | 359 } else { |
| 377 natBox.classList.remove('traversal-enabled'); | 360 natBox.classList.remove('traversal-enabled'); |
| 378 } | 361 } |
| 379 } | 362 } |
| OLD | NEW |