OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This implements the JavaScript class entrypoint for the plugin instance. | 5 // This implements the JavaScript class entrypoint for the plugin instance. |
6 // The Javascript API is defined as follows. | 6 // The Javascript API is defined as follows. |
7 // | 7 // |
8 // interface ChromotingScriptableObject { | 8 // interface ChromotingScriptableObject { |
9 // | 9 // |
10 // // Dimension of the desktop area. | 10 // // Chromoting session API version (for this plugin). |
11 // readonly attribute int desktopWidth; | 11 // // This is compared with the javascript API version to verify that they are |
12 // readonly attribute int desktopHeight; | 12 // // compatible. |
| 13 // readonly attribute unsigned short apiVersion; |
| 14 // |
| 15 // // The oldest API version that we support. |
| 16 // // This will differ from |apiVersion| if we decide to maintain backward |
| 17 // // compatibility with older API versions. |
| 18 // readonly attribute unsigned short apiMinVersion; |
13 // | 19 // |
14 // // Connection status. | 20 // // Connection status. |
15 // readonly attribute unsigned short status; | 21 // readonly attribute unsigned short status; |
16 // | 22 // |
17 // // Statistics. | |
18 // // Video Bandwidth in bytes per second. | |
19 // readonly attribute float videoBandwidth; | |
20 // // Latency for capturing in milliseconds. | |
21 // readonly attribute int videoCaptureLatency; | |
22 // // Latency for video encoding in milliseconds. | |
23 // readonly attribute int videoEncodeLatency; | |
24 // // Latency for video decoding in milliseconds. | |
25 // readonly attribute int videoDecodeLatency; | |
26 // // Latency for rendering in milliseconds. | |
27 // readonly attribute int videoRenderLatency; | |
28 // // Latency between an event is sent and a corresponding video packet is | |
29 // // received. | |
30 // readonly attribute int roundTripLatency; | |
31 // | |
32 // // Constants for connection status. | 23 // // Constants for connection status. |
33 // const unsigned short STATUS_UNKNOWN = 0; | 24 // const unsigned short STATUS_UNKNOWN = 0; |
34 // const unsigned short STATUS_CONNECTING = 1; | 25 // const unsigned short STATUS_CONNECTING = 1; |
35 // const unsigned short STATUS_INITIALIZING = 2; | 26 // const unsigned short STATUS_INITIALIZING = 2; |
36 // const unsigned short STATUS_CONNECTED = 3; | 27 // const unsigned short STATUS_CONNECTED = 3; |
37 // const unsigned short STATUS_CLOSED = 4; | 28 // const unsigned short STATUS_CLOSED = 4; |
38 // const unsigned short STATUS_FAILED = 5; | 29 // const unsigned short STATUS_FAILED = 5; |
39 // | 30 // |
40 // // Connection quality. | 31 // // Connection quality. |
41 // readonly attribute unsigned short quality; | 32 // readonly attribute unsigned short quality; |
| 33 // |
42 // // Constants for connection quality | 34 // // Constants for connection quality |
43 // const unsigned short QUALITY_UNKNOWN = 0; | 35 // const unsigned short QUALITY_UNKNOWN = 0; |
44 // const unsigned short QUALITY_GOOD = 1; | 36 // const unsigned short QUALITY_GOOD = 1; |
45 // const unsigned short QUALITY_BAD = 2; | 37 // const unsigned short QUALITY_BAD = 2; |
46 // | 38 // |
47 // // JS callback function so we can signal the JS UI when the connection | 39 // // JS callback function so we can signal the JS UI when the connection |
48 // // status has been updated. | 40 // // status has been updated. |
49 // attribute Function connectionInfoUpdate; | 41 // attribute Function connectionInfoUpdate; |
50 // | 42 // |
51 // // JS callback function to call when there is new debug info to display | 43 // // JS callback function to call when there is new debug info to display |
52 // // in the client UI. | 44 // // in the client UI. |
53 // attribute Function debugInfo; | 45 // attribute Function debugInfo; |
54 // | 46 // |
55 // // JS callback function to send an XMPP IQ stanza for performing the | 47 // attribute Function desktopSizeUpdate; |
56 // // signaling in a jingle connection. The callback function should be | |
57 // // of type void(string request_xml). | |
58 // attribute Function sendIq; | |
59 // | |
60 // // Method for receiving an XMPP IQ stanza in response to a previous | |
61 // // sendIq() invocation. Other packets will be silently dropped. | |
62 // void onIq(string response_xml); | |
63 // | 48 // |
64 // // This function is called when login information for the host machine is | 49 // // This function is called when login information for the host machine is |
65 // // needed. | 50 // // needed. |
66 // // | 51 // // |
67 // // User of this object should respond with calling submitLoginInfo() when | 52 // // User of this object should respond with calling submitLoginInfo() when |
68 // // username and password is available. | 53 // // username and password is available. |
69 // // | 54 // // |
70 // // This function will be called multiple times until login was successful | 55 // // This function will be called multiple times until login was successful |
71 // // or the maximum number of login attempts has been reached. In the | 56 // // or the maximum number of login attempts has been reached. In the |
72 // // later case |connection_status| is changed to STATUS_FAILED. | 57 // // later case |connection_status| is changed to STATUS_FAILED. |
73 // attribute Function loginChallenge; | 58 // attribute Function loginChallenge; |
74 // | 59 // |
| 60 // // JS callback function to send an XMPP IQ stanza for performing the |
| 61 // // signaling in a jingle connection. The callback function should be |
| 62 // // of type void(string request_xml). |
| 63 // attribute Function sendIq; |
| 64 // |
| 65 // // Dimension of the desktop area. |
| 66 // readonly attribute int desktopWidth; |
| 67 // readonly attribute int desktopHeight; |
| 68 // |
| 69 // // Statistics. |
| 70 // // Video Bandwidth in bytes per second. |
| 71 // readonly attribute float videoBandwidth; |
| 72 // // Latency for capturing in milliseconds. |
| 73 // readonly attribute int videoCaptureLatency; |
| 74 // // Latency for video encoding in milliseconds. |
| 75 // readonly attribute int videoEncodeLatency; |
| 76 // // Latency for video decoding in milliseconds. |
| 77 // readonly attribute int videoDecodeLatency; |
| 78 // // Latency for rendering in milliseconds. |
| 79 // readonly attribute int videoRenderLatency; |
| 80 // // Latency between an event is sent and a corresponding video packet is |
| 81 // // received. |
| 82 // readonly attribute int roundTripLatency; |
| 83 // |
75 // // Methods for establishing a Chromoting connection. | 84 // // Methods for establishing a Chromoting connection. |
76 // // | 85 // // |
77 // // Either use connect() or connectSandboxed(), not both. If using | 86 // // Either use connect() or connectSandboxed(), not both. If using |
78 // // connectSandboxed(), sendIq must be set, and responses to calls on | 87 // // connectSandboxed(), sendIq must be set, and responses to calls on |
79 // // sendIq must be piped back into onIq(). | 88 // // sendIq must be piped back into onIq(). |
80 // void connect(string username, string host_jid, string auth_token, | 89 // void connect(string username, string host_jid, string auth_token, |
81 // string nonce); | 90 // string nonce); |
82 // void connectSandboxed(string your_jid, string host_jid, string nonce); | 91 // void connectSandboxed(string your_jid, string host_jid, string nonce); |
83 // void disconnect(); | 92 // void disconnect(); |
84 // | 93 // |
85 // // Method for submitting login information. | 94 // // Method for submitting login information. |
86 // void submitLoginInfo(string username, string password); | 95 // void submitLoginInfo(string username, string password); |
87 // | 96 // |
88 // // Method for setting scale-to-fit. | 97 // // Method for setting scale-to-fit. |
89 // void setScaleToFit(bool scale_to_fit); | 98 // void setScaleToFit(bool scale_to_fit); |
| 99 // |
| 100 // // Method for receiving an XMPP IQ stanza in response to a previous |
| 101 // // sendIq() invocation. Other packets will be silently dropped. |
| 102 // void onIq(string response_xml); |
90 // } | 103 // } |
91 | 104 |
92 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ | 105 #ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ |
93 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ | 106 #define REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ |
94 | 107 |
95 #include <map> | 108 #include <map> |
96 #include <string> | 109 #include <string> |
97 #include <vector> | 110 #include <vector> |
98 | 111 |
99 #include "base/memory/weak_ptr.h" | 112 #include "base/memory/weak_ptr.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 pp::Var* exception); | 157 pp::Var* exception); |
145 | 158 |
146 void SetConnectionInfo(ConnectionStatus status, ConnectionQuality quality); | 159 void SetConnectionInfo(ConnectionStatus status, ConnectionQuality quality); |
147 void LogDebugInfo(const std::string& info); | 160 void LogDebugInfo(const std::string& info); |
148 void SetDesktopSize(int width, int height); | 161 void SetDesktopSize(int width, int height); |
149 | 162 |
150 // This should be called to signal JS code to provide login information. | 163 // This should be called to signal JS code to provide login information. |
151 void SignalLoginChallenge(); | 164 void SignalLoginChallenge(); |
152 | 165 |
153 // Attaches the XmppProxy used for issuing and receivng IQ stanzas for | 166 // Attaches the XmppProxy used for issuing and receivng IQ stanzas for |
154 // initiaing a jingle connection from within the sandbox. | 167 // initializing a jingle connection from within the sandbox. |
155 void AttachXmppProxy(PepperXmppProxy* xmpp_proxy); | 168 void AttachXmppProxy(PepperXmppProxy* xmpp_proxy); |
156 | 169 |
157 // Sends an IQ stanza, serialized as an xml string, into Javascript for | 170 // Sends an IQ stanza, serialized as an xml string, into Javascript for |
158 // handling. | 171 // handling. |
159 void SendIq(const std::string& request_xml); | 172 void SendIq(const std::string& request_xml); |
160 | 173 |
161 private: | 174 private: |
162 typedef std::map<std::string, int> PropertyNameMap; | 175 typedef std::map<std::string, int> PropertyNameMap; |
163 typedef pp::Var (ChromotingScriptableObject::*MethodHandler)( | 176 typedef pp::Var (ChromotingScriptableObject::*MethodHandler)( |
164 const std::vector<pp::Var>& args, pp::Var* exception); | 177 const std::vector<pp::Var>& args, pp::Var* exception); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 PropertyNameMap property_names_; | 223 PropertyNameMap property_names_; |
211 std::vector<PropertyDescriptor> properties_; | 224 std::vector<PropertyDescriptor> properties_; |
212 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 225 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
213 | 226 |
214 ChromotingInstance* instance_; | 227 ChromotingInstance* instance_; |
215 }; | 228 }; |
216 | 229 |
217 } // namespace remoting | 230 } // namespace remoting |
218 | 231 |
219 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ | 232 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ |
OLD | NEW |