Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / remoting / webapp / host_plugin_wrapper.js
blob870eec3be701029b35c799e82fcee57bbd02245f
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 || {};
14 /**
15 * @constructor
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;
24 /**
25 * @param {function(string):void} callback
26 * @return {void}
28 remoting.HostPluginWrapper.prototype.getHostName = function(callback) {
29 this.plugin_.getHostName(callback);
32 /**
33 * @param {string} hostId
34 * @param {string} pin
35 * @param {function(string):void} callback
36 * @return {void}
38 remoting.HostPluginWrapper.prototype.getPinHash = function(hostId, pin,
39 callback) {
40 this.plugin_.getPinHash(hostId, pin, callback);
43 /**
44 * @param {function(string, string):void} callback
45 * @return {void}
47 remoting.HostPluginWrapper.prototype.generateKeyPair = function(callback) {
48 this.plugin_.generateKeyPair(callback);
51 /**
52 * @param {string} config
53 * @param {function(remoting.HostController.AsyncResult):void} callback
54 * @return {void}
56 remoting.HostPluginWrapper.prototype.updateDaemonConfig = function(config,
57 callback) {
58 this.plugin_.updateDaemonConfig(config, callback);
61 /**
62 * @param {function(string):void} callback
63 * @return {void}
65 remoting.HostPluginWrapper.prototype.getDaemonConfig = function(callback) {
66 this.plugin_.getDaemonConfig(callback);
69 /**
70 * @param {function(string):void} callback
71 * @return {void}
73 remoting.HostPluginWrapper.prototype.getDaemonVersion = function(callback) {
74 this.plugin_.getDaemonVersion(callback);
77 /**
78 * @param {function(boolean, boolean, boolean):void} callback
79 * @return {void}
81 remoting.HostPluginWrapper.prototype.getUsageStatsConsent = function(callback) {
82 this.plugin_.getUsageStatsConsent(callback);
85 /**
86 * @param {string} config
87 * @param {function(remoting.HostController.AsyncResult):void} callback
88 * @return {void}
90 remoting.HostPluginWrapper.prototype.startDaemon = function(
91 config, consent, callback) {
92 this.plugin_.startDaemon(config, consent, callback);
95 /**
96 * @param {function(remoting.HostController.AsyncResult):void} callback
97 * @return {void}
99 remoting.HostPluginWrapper.prototype.stopDaemon = function(callback) {
100 this.plugin_.stopDaemon(callback);
104 * @param {function(remoting.HostController.State):void} callback
105 * @return {void}
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;
116 callback(state);