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