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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @constructor */ | 10 /** @constructor */ |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 throw "Invalid HostController.AsyncResult: " + result; | 61 throw "Invalid HostController.AsyncResult: " + result; |
62 } | 62 } |
63 return remoting.HostController.AsyncResult[result]; | 63 return remoting.HostController.AsyncResult[result]; |
64 } | 64 } |
65 | 65 |
66 /** | 66 /** |
67 * @return {remoting.HostDispatcher} | 67 * @return {remoting.HostDispatcher} |
68 * @private | 68 * @private |
69 */ | 69 */ |
70 remoting.HostController.prototype.createDispatcher_ = function() { | 70 remoting.HostController.prototype.createDispatcher_ = function() { |
71 /** @return {remoting.HostPlugin} */ | |
72 var createPluginForMe2Me = function() { | |
73 /** @type {HTMLElement} @private */ | |
74 var container = document.getElementById('daemon-plugin-container'); | |
75 return remoting.createNpapiPlugin(container); | |
76 }; | |
77 | |
78 /** @type {remoting.HostDispatcher} @private */ | 71 /** @type {remoting.HostDispatcher} @private */ |
79 var hostDispatcher = new remoting.HostDispatcher(createPluginForMe2Me); | 72 var hostDispatcher = new remoting.HostDispatcher(); |
80 | 73 |
81 /** @param {string} version */ | 74 /** @param {string} version */ |
82 var printVersion = function(version) { | 75 var printVersion = function(version) { |
83 if (version == '') { | 76 if (version == '') { |
84 console.log('Host not installed.'); | 77 console.log('Host not installed.'); |
85 } else { | 78 } else { |
86 console.log('Host version: ' + version); | 79 console.log('Host version: ' + version); |
87 } | 80 } |
88 }; | 81 }; |
89 | 82 |
(...skipping 29 matching lines...) Expand all Loading... |
119 * @param {function(boolean, boolean, boolean):void} onDone Callback to be | 112 * @param {function(boolean, boolean, boolean):void} onDone Callback to be |
120 * called when done. | 113 * called when done. |
121 * @param {function(remoting.Error):void} onError Callback to be called on | 114 * @param {function(remoting.Error):void} onError Callback to be called on |
122 * error. | 115 * error. |
123 */ | 116 */ |
124 remoting.HostController.prototype.getConsent = function(onDone, onError) { | 117 remoting.HostController.prototype.getConsent = function(onDone, onError) { |
125 this.hostDispatcher_.getUsageStatsConsent(onDone, onError); | 118 this.hostDispatcher_.getUsageStatsConsent(onDone, onError); |
126 }; | 119 }; |
127 | 120 |
128 /** | 121 /** |
129 * @param {function(remoting.HostController.AsyncResult):void} onDone | |
130 * @param {function(remoting.Error):void} onError | |
131 * @return {void} | |
132 */ | |
133 remoting.HostController.prototype.installHost = function(onDone, onError) { | |
134 /** @type {remoting.HostController} */ | |
135 var that = this; | |
136 | |
137 /** @param {remoting.HostController.AsyncResult} asyncResult */ | |
138 var onHostInstalled = function(asyncResult) { | |
139 // Refresh the dispatcher after the host has been installed. | |
140 if (asyncResult == remoting.HostController.AsyncResult.OK) { | |
141 that.hostDispatcher_ = that.createDispatcher_(); | |
142 } | |
143 onDone(asyncResult); | |
144 }; | |
145 | |
146 this.hostDispatcher_.installHost(onHostInstalled, onError); | |
147 }; | |
148 | |
149 /** | |
150 * Registers and starts the host. | 122 * Registers and starts the host. |
151 * | 123 * |
152 * @param {string} hostPin Host PIN. | 124 * @param {string} hostPin Host PIN. |
153 * @param {boolean} consent The user's consent to crash dump reporting. | 125 * @param {boolean} consent The user's consent to crash dump reporting. |
154 * @param {function():void} onDone Callback to be called when done. | 126 * @param {function():void} onDone Callback to be called when done. |
155 * @param {function(remoting.Error):void} onError Callback to be called on | 127 * @param {function(remoting.Error):void} onError Callback to be called on |
156 * error. | 128 * error. |
157 * @return {void} Nothing. | 129 * @return {void} Nothing. |
158 */ | 130 */ |
159 remoting.HostController.prototype.start = function(hostPin, consent, onDone, | 131 remoting.HostController.prototype.start = function(hostPin, consent, onDone, |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 * | 495 * |
524 * @param {function():void} onDone Completion callback. | 496 * @param {function():void} onDone Completion callback. |
525 * @param {function(remoting.Error):void} onError Error callback. | 497 * @param {function(remoting.Error):void} onError Error callback. |
526 * @return {void} | 498 * @return {void} |
527 */ | 499 */ |
528 remoting.HostController.prototype.clearPairedClients = function( | 500 remoting.HostController.prototype.clearPairedClients = function( |
529 onDone, onError) { | 501 onDone, onError) { |
530 this.hostDispatcher_.clearPairedClients(onDone, onError); | 502 this.hostDispatcher_.clearPairedClients(onDone, onError); |
531 }; | 503 }; |
532 | 504 |
533 /** | |
534 * Returns true if the NPAPI plugin is being used. | |
535 * @return {boolean} | |
536 */ | |
537 remoting.HostController.prototype.usingNpapiPlugin = function() { | |
538 return this.hostDispatcher_.usingNpapiPlugin(); | |
539 } | |
540 | |
541 /** @type {remoting.HostController} */ | 505 /** @type {remoting.HostController} */ |
542 remoting.hostController = null; | 506 remoting.hostController = null; |
OLD | NEW |