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
3 // found in the LICENSE file.
5 // This file provides a compatibility wrapper around the NPAPI plugin object,
6 // exposing an interface that matches the Native Messaging interface.
8 // TODO(lambroslambrou): Add error callback parameters here, and in Native
9 // Messaging. The extra callback parameters will be ignored here.
11 /** @suppress {duplicate} */
12 var remoting
= remoting
|| {};
16 * @param {remoting.HostPlugin} plugin Wrapped NPAPI plugin object.
17 * @extends remoting.HostNativeMessaging
19 remoting
.HostPluginWrapper = function(plugin
) {
20 /** @type {remoting.HostPlugin} @private */
21 this.plugin_
= plugin
;
25 * @param {function(string):void} callback
28 remoting
.HostPluginWrapper
.prototype.getHostName = function(callback
) {
29 this.plugin_
.getHostName(callback
);
33 * @param {string} hostId
35 * @param {function(string):void} callback
38 remoting
.HostPluginWrapper
.prototype.getPinHash = function(hostId
, pin
,
40 this.plugin_
.getPinHash(hostId
, pin
, callback
);
44 * @param {function(string, string):void} callback
47 remoting
.HostPluginWrapper
.prototype.generateKeyPair = function(callback
) {
48 this.plugin_
.generateKeyPair(callback
);
52 * @param {string} config
53 * @param {function(remoting.HostController.AsyncResult):void} callback
56 remoting
.HostPluginWrapper
.prototype.updateDaemonConfig = function(config
,
58 this.plugin_
.updateDaemonConfig(config
, callback
);
62 * @param {function(string):void} callback
65 remoting
.HostPluginWrapper
.prototype.getDaemonConfig = function(callback
) {
66 this.plugin_
.getDaemonConfig(callback
);
70 * @param {function(string):void} callback
73 remoting
.HostPluginWrapper
.prototype.getDaemonVersion = function(callback
) {
74 this.plugin_
.getDaemonVersion(callback
);
78 * @param {function(boolean, boolean, boolean):void} callback
81 remoting
.HostPluginWrapper
.prototype.getUsageStatsConsent = function(callback
) {
82 this.plugin_
.getUsageStatsConsent(callback
);
86 * @param {string} config
87 * @param {function(remoting.HostController.AsyncResult):void} callback
90 remoting
.HostPluginWrapper
.prototype.startDaemon = function(
91 config
, consent
, callback
) {
92 this.plugin_
.startDaemon(config
, consent
, callback
);
96 * @param {function(remoting.HostController.AsyncResult):void} callback
99 remoting
.HostPluginWrapper
.prototype.stopDaemon = function(callback
) {
100 this.plugin_
.stopDaemon(callback
);
104 * @param {function(remoting.HostController.State):void} callback
107 remoting
.HostPluginWrapper
.prototype.getDaemonState = function(callback
) {
108 // Call the callback directly, since NPAPI exposes the state directly as a
109 // field member, rather than an asynchronous method.
110 var state
= this.plugin_
.daemonState
;
111 if (state
=== undefined) {
112 // If the plug-in can't be instantiated, for example on ChromeOS, then
113 // return something sensible.
114 state
= remoting
.HostController
.State
.NOT_IMPLEMENTED
;