forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhost_plugin_wrapper.js
117 lines (103 loc) · 3.38 KB
/
host_plugin_wrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file provides a compatibility wrapper around the NPAPI plugin object,
// exposing an interface that matches the Native Messaging interface.
// TODO(lambroslambrou): Add error callback parameters here, and in Native
// Messaging. The extra callback parameters will be ignored here.
/** @suppress {duplicate} */
var remoting = remoting || {};
/**
* @constructor
* @param {remoting.HostPlugin} plugin Wrapped NPAPI plugin object.
* @extends remoting.HostNativeMessaging
*/
remoting.HostPluginWrapper = function(plugin) {
/** @type {remoting.HostPlugin} @private */
this.plugin_ = plugin;
};
/**
* @param {function(string):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getHostName = function(callback) {
this.plugin_.getHostName(callback);
};
/**
* @param {string} hostId
* @param {string} pin
* @param {function(string):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getPinHash = function(hostId, pin,
callback) {
this.plugin_.getPinHash(hostId, pin, callback);
};
/**
* @param {function(string, string):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.generateKeyPair = function(callback) {
this.plugin_.generateKeyPair(callback);
};
/**
* @param {string} config
* @param {function(remoting.HostController.AsyncResult):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.updateDaemonConfig = function(config,
callback) {
this.plugin_.updateDaemonConfig(config, callback);
};
/**
* @param {function(string):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getDaemonConfig = function(callback) {
this.plugin_.getDaemonConfig(callback);
};
/**
* @param {function(string):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getDaemonVersion = function(callback) {
this.plugin_.getDaemonVersion(callback);
};
/**
* @param {function(boolean, boolean, boolean):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getUsageStatsConsent = function(callback) {
this.plugin_.getUsageStatsConsent(callback);
};
/**
* @param {string} config
* @param {function(remoting.HostController.AsyncResult):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.startDaemon = function(
config, consent, callback) {
this.plugin_.startDaemon(config, consent, callback);
};
/**
* @param {function(remoting.HostController.AsyncResult):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.stopDaemon = function(callback) {
this.plugin_.stopDaemon(callback);
};
/**
* @param {function(remoting.HostController.State):void} callback
* @return {void}
*/
remoting.HostPluginWrapper.prototype.getDaemonState = function(callback) {
// Call the callback directly, since NPAPI exposes the state directly as a
// field member, rather than an asynchronous method.
var state = this.plugin_.daemonState;
if (state === undefined) {
// If the plug-in can't be instantiated, for example on ChromeOS, then
// return something sensible.
state = remoting.HostController.State.NOT_IMPLEMENTED;
}
callback(state);
}