blob: cec5a8ff1b762f840d21062604ed66b67f712869 (
plain)
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
|
// Copyright (c) 2012 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.
'use strict';
/** @suppress {duplicate} */
var remoting = remoting || {};
/** @constructor */
remoting.DaemonPlugin = function() {
/** @type {remoting.HostPlugin} @private */
this.plugin_ = remoting.HostSession.createPlugin();
/** @type {HTMLElement} @private */
this.container_ = document.getElementById('daemon-plugin-container');
this.container_.appendChild(this.plugin_);
};
// Note that the values in this enum are copied from daemon_controller.h and
// must be kept in sync.
/** @enum {number} */
remoting.DaemonPlugin.State = {
NOT_IMPLEMENTED: -1,
NOT_INSTALLED: 0,
STOPPED: 1,
STARTED: 2,
START_FAILED: 3,
UNKNOWN: 4
};
/** @return {remoting.DaemonPlugin.State} The current state of the daemon. */
remoting.DaemonPlugin.prototype.state = function() {
try {
return this.plugin_.daemonState;
} catch (err) {
// If the plug-in can't be instantiated, for example on ChromeOS, then
// return something sensible.
return remoting.DaemonPlugin.State.NOT_IMPLEMENTED;
}
};
/**
* Show or hide daemon-specific parts of the UI.
* @return {void} Nothing.
*/
remoting.DaemonPlugin.prototype.updateDom = function() {
var match = '';
switch (this.state()) {
case remoting.DaemonPlugin.State.STARTED:
match = 'enabled';
break;
case remoting.DaemonPlugin.State.STOPPED:
case remoting.DaemonPlugin.State.NOT_INSTALLED:
case remoting.DaemonPlugin.State.START_FAILED:
match = 'disabled';
break;
}
remoting.updateModalUi(match, 'data-daemon-state');
};
/**
* Start the daemon process.
* @return {boolean} False if insufficient state has been set.
*/
remoting.DaemonPlugin.prototype.start = function() {
return this.plugin_.startDaemon();
};
/**
* Stop the daemon process.
* @return {boolean} False if insufficient state has been set.
*/
remoting.DaemonPlugin.prototype.stop = function() {
return this.plugin_.stopDaemon();
};
/**
* @param {string} pin The new PIN for the daemon process.
* @return {boolean} True if the PIN was set successfully.
*/
remoting.DaemonPlugin.prototype.setPin = function(pin) {
return this.plugin_.setDaemonPin(pin);
};
/** @type {remoting.DaemonPlugin} */
remoting.daemonPlugin = null;
|