OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 * This class provides an interface between the HostController and either the | 7 * This class provides an interface between the HostController and either the |
8 * NativeMessaging Host or the Host NPAPI plugin, depending on whether or not | 8 * NativeMessaging Host or the Host NPAPI plugin, depending on whether or not |
9 * NativeMessaging is supported. Since the test for NativeMessaging support is | 9 * NativeMessaging is supported. Since the test for NativeMessaging support is |
10 * asynchronous, this class stores any requests on a queue, pending the result | 10 * asynchronous, this class stores any requests on a queue, pending the result |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 that.state_ = that.npapiHost_ ? remoting.HostDispatcher.State.NPAPI | 80 that.state_ = that.npapiHost_ ? remoting.HostDispatcher.State.NPAPI |
81 : remoting.HostDispatcher.State.NOT_INSTALLED; | 81 : remoting.HostDispatcher.State.NOT_INSTALLED; |
82 sendPendingRequests(); | 82 sendPendingRequests(); |
83 } | 83 } |
84 | 84 |
85 this.nativeMessagingHost_.initialize(onNativeMessagingInit, | 85 this.nativeMessagingHost_.initialize(onNativeMessagingInit, |
86 onNativeMessagingFailed); | 86 onNativeMessagingFailed); |
87 }; | 87 }; |
88 | 88 |
89 /** | 89 /** |
| 90 * @return {remoting.HostPlugin} |
| 91 */ |
| 92 remoting.HostDispatcher.prototype.getNpapiHost = function() { |
| 93 return this.npapiHost_; |
| 94 } |
| 95 |
| 96 /** |
90 * @param {remoting.HostController.Feature} feature The feature to test for. | 97 * @param {remoting.HostController.Feature} feature The feature to test for. |
91 * @param {function(boolean):void} onDone | 98 * @param {function(boolean):void} onDone |
92 * @return {void} | 99 * @return {void} |
93 */ | 100 */ |
94 remoting.HostDispatcher.prototype.hasFeature = function( | 101 remoting.HostDispatcher.prototype.hasFeature = function( |
95 feature, onDone) { | 102 feature, onDone) { |
96 switch (this.state_) { | 103 switch (this.state_) { |
97 case remoting.HostDispatcher.State.UNKNOWN: | 104 case remoting.HostDispatcher.State.UNKNOWN: |
98 this.pendingRequests_.push( | 105 this.pendingRequests_.push( |
99 this.hasFeature.bind(this, feature, onDone)); | 106 this.hasFeature.bind(this, feature, onDone)); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 onError(remoting.Error.MISSING_PLUGIN); | 327 onError(remoting.Error.MISSING_PLUGIN); |
321 } | 328 } |
322 break; | 329 break; |
323 case remoting.HostDispatcher.State.NOT_INSTALLED: | 330 case remoting.HostDispatcher.State.NOT_INSTALLED: |
324 onError(remoting.Error.MISSING_PLUGIN); | 331 onError(remoting.Error.MISSING_PLUGIN); |
325 break; | 332 break; |
326 } | 333 } |
327 }; | 334 }; |
328 | 335 |
329 /** | 336 /** |
330 * This function installs the chromoting host using the NPAPI plugin and should | 337 * This function installs the host using the NPAPI plugin and should only be |
331 * only be called on Windows. | 338 * called on Windows. |
332 * | 339 * |
333 * @param {function(remoting.HostController.AsyncResult):void} onDone | 340 * @param {function(remoting.HostController.AsyncResult):void} onDone |
334 * @param {function(remoting.Error):void} onError | 341 * @param {function(remoting.Error):void} onError |
335 * @return {void} | 342 * @return {void} |
336 */ | 343 */ |
337 remoting.HostDispatcher.prototype.installHost = function(onDone, onError) { | 344 remoting.HostDispatcher.prototype.installHost = function(onDone, onError) { |
338 switch (this.state_) { | 345 switch (this.state_) { |
339 case remoting.HostDispatcher.State.UNKNOWN: | 346 case remoting.HostDispatcher.State.UNKNOWN: |
340 this.pendingRequests_.push(this.installHost.bind(this, onDone, onError)); | 347 this.pendingRequests_.push(this.installHost.bind(this, onDone, onError)); |
341 break; | 348 break; |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 643 } |
637 }; | 644 }; |
638 | 645 |
639 /** | 646 /** |
640 * Returns true if the NPAPI plugin is being used. | 647 * Returns true if the NPAPI plugin is being used. |
641 * @return {boolean} | 648 * @return {boolean} |
642 */ | 649 */ |
643 remoting.HostDispatcher.prototype.usingNpapiPlugin = function() { | 650 remoting.HostDispatcher.prototype.usingNpapiPlugin = function() { |
644 return this.state_ == remoting.HostDispatcher.State.NPAPI; | 651 return this.state_ == remoting.HostDispatcher.State.NPAPI; |
645 } | 652 } |
OLD | NEW |