| 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 // // Chromoting session API version (for this plugin). | 10 // // Chromoting session API version (for this plugin). |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // // JS callback function so we can signal the JS UI when the connection | 38 // // JS callback function so we can signal the JS UI when the connection |
| 39 // // status has been updated. | 39 // // status has been updated. |
| 40 // attribute Function connectionInfoUpdate; | 40 // attribute Function connectionInfoUpdate; |
| 41 // | 41 // |
| 42 // // JS callback function to call when there is new debug info to display | 42 // // JS callback function to call when there is new debug info to display |
| 43 // // in the client UI. | 43 // // in the client UI. |
| 44 // attribute Function debugInfo; | 44 // attribute Function debugInfo; |
| 45 // | 45 // |
| 46 // attribute Function desktopSizeUpdate; | 46 // attribute Function desktopSizeUpdate; |
| 47 // | 47 // |
| 48 // // This function is called when login information for the host machine is | |
| 49 // // needed. | |
| 50 // // | |
| 51 // // User of this object should respond with calling submitLoginInfo() when | |
| 52 // // username and password is available. | |
| 53 // // | |
| 54 // // This function will be called multiple times until login was successful | |
| 55 // // or the maximum number of login attempts has been reached. In the | |
| 56 // // later case |connection_status| is changed to STATUS_FAILED. | |
| 57 // attribute Function loginChallenge; | |
| 58 // | |
| 59 // // JS callback function to send an XMPP IQ stanza for performing the | 48 // // JS callback function to send an XMPP IQ stanza for performing the |
| 60 // // signaling in a jingle connection. The callback function should be | 49 // // signaling in a jingle connection. The callback function should be |
| 61 // // of type void(string request_xml). | 50 // // of type void(string request_xml). |
| 62 // attribute Function sendIq; | 51 // attribute Function sendIq; |
| 63 // | 52 // |
| 64 // // Dimension of the desktop area. | 53 // // Dimension of the desktop area. |
| 65 // readonly attribute int desktopWidth; | 54 // readonly attribute int desktopWidth; |
| 66 // readonly attribute int desktopHeight; | 55 // readonly attribute int desktopHeight; |
| 67 // | 56 // |
| 68 // // Statistics. | 57 // // Statistics. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 90 // // be piped back into onIq(). | 79 // // be piped back into onIq(). |
| 91 // // | 80 // // |
| 92 // // Note that auth_token_with_service should be specified as | 81 // // Note that auth_token_with_service should be specified as |
| 93 // // "auth_service:auth_token". For example, "oauth2:5/aBd123". | 82 // // "auth_service:auth_token". For example, "oauth2:5/aBd123". |
| 94 // void connect(string host_jid, string auth_token_with_service, | 83 // void connect(string host_jid, string auth_token_with_service, |
| 95 // optional string access_code); | 84 // optional string access_code); |
| 96 // | 85 // |
| 97 // // Terminating a Chromoting connection. | 86 // // Terminating a Chromoting connection. |
| 98 // void disconnect(); | 87 // void disconnect(); |
| 99 // | 88 // |
| 100 // // Method for submitting login information. | |
| 101 // void submitLoginInfo(string username, string password); | |
| 102 // | |
| 103 // // Method for setting scale-to-fit. | 89 // // Method for setting scale-to-fit. |
| 104 // void setScaleToFit(bool scale_to_fit); | 90 // void setScaleToFit(bool scale_to_fit); |
| 105 // | 91 // |
| 106 // // Method for receiving an XMPP IQ stanza in response to a previous | 92 // // Method for receiving an XMPP IQ stanza in response to a previous |
| 107 // // sendIq() invocation. Other packets will be silently dropped. | 93 // // sendIq() invocation. Other packets will be silently dropped. |
| 108 // void onIq(string response_xml); | 94 // void onIq(string response_xml); |
| 109 // | 95 // |
| 110 // // Method for releasing all keys to ensure a consistent host state. | 96 // // Method for releasing all keys to ensure a consistent host state. |
| 111 // void releaseAllKeys(); | 97 // void releaseAllKeys(); |
| 112 // } | 98 // } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 const pp::Var& value, | 156 const pp::Var& value, |
| 171 pp::Var* exception); | 157 pp::Var* exception); |
| 172 virtual pp::Var Call(const pp::Var& method_name, | 158 virtual pp::Var Call(const pp::Var& method_name, |
| 173 const std::vector<pp::Var>& args, | 159 const std::vector<pp::Var>& args, |
| 174 pp::Var* exception); | 160 pp::Var* exception); |
| 175 | 161 |
| 176 void SetConnectionStatus(ConnectionStatus status, ConnectionError error); | 162 void SetConnectionStatus(ConnectionStatus status, ConnectionError error); |
| 177 void LogDebugInfo(const std::string& info); | 163 void LogDebugInfo(const std::string& info); |
| 178 void SetDesktopSize(int width, int height); | 164 void SetDesktopSize(int width, int height); |
| 179 | 165 |
| 180 // This should be called to signal JS code to provide login information. | |
| 181 void SignalLoginChallenge(); | |
| 182 | |
| 183 // Attaches the XmppProxy used for issuing and receivng IQ stanzas for | 166 // Attaches the XmppProxy used for issuing and receivng IQ stanzas for |
| 184 // initializing a jingle connection from within the sandbox. | 167 // initializing a jingle connection from within the sandbox. |
| 185 void AttachXmppProxy(PepperXmppProxy* xmpp_proxy); | 168 void AttachXmppProxy(PepperXmppProxy* xmpp_proxy); |
| 186 | 169 |
| 187 // 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 |
| 188 // handling. | 171 // handling. |
| 189 void SendIq(const std::string& request_xml); | 172 void SendIq(const std::string& request_xml); |
| 190 | 173 |
| 191 private: | 174 private: |
| 192 typedef std::map<std::string, int> PropertyNameMap; | 175 typedef std::map<std::string, int> PropertyNameMap; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 217 void AddMethod(const std::string& name, MethodHandler handler); | 200 void AddMethod(const std::string& name, MethodHandler handler); |
| 218 | 201 |
| 219 void SignalConnectionInfoChange(); | 202 void SignalConnectionInfoChange(); |
| 220 void SignalDesktopSizeChange(); | 203 void SignalDesktopSizeChange(); |
| 221 | 204 |
| 222 // Calls to these methods are posted to the plugin thread so that we | 205 // Calls to these methods are posted to the plugin thread so that we |
| 223 // call JavaScript with clean stack. This is necessary because | 206 // call JavaScript with clean stack. This is necessary because |
| 224 // JavaScript event handlers may destroy the plugin. | 207 // JavaScript event handlers may destroy the plugin. |
| 225 void DoSignalConnectionInfoChange(); | 208 void DoSignalConnectionInfoChange(); |
| 226 void DoSignalDesktopSizeChange(); | 209 void DoSignalDesktopSizeChange(); |
| 227 void DoSignalLoginChallenge(); | |
| 228 void DoSendIq(const std::string& message_xml); | 210 void DoSendIq(const std::string& message_xml); |
| 229 | 211 |
| 230 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); | 212 pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); |
| 231 pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception); | 213 pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception); |
| 232 | 214 |
| 233 // This method is called by JS to provide login information. | |
| 234 pp::Var DoSubmitLogin(const std::vector<pp::Var>& args, pp::Var* exception); | |
| 235 | |
| 236 // This method is called by JS to set scale-to-fit. | 215 // This method is called by JS to set scale-to-fit. |
| 237 pp::Var DoSetScaleToFit(const std::vector<pp::Var>& args, pp::Var* exception); | 216 pp::Var DoSetScaleToFit(const std::vector<pp::Var>& args, pp::Var* exception); |
| 238 | 217 |
| 239 // This method is called by Javascript to provide responses to sendIq() | 218 // This method is called by Javascript to provide responses to sendIq() |
| 240 // requests. | 219 // requests. |
| 241 pp::Var DoOnIq(const std::vector<pp::Var>& args, pp::Var* exception); | 220 pp::Var DoOnIq(const std::vector<pp::Var>& args, pp::Var* exception); |
| 242 | 221 |
| 243 // This method is called by Javascript when the plugin loses input focus to | 222 // This method is called by Javascript when the plugin loses input focus to |
| 244 // release all pressed keys. | 223 // release all pressed keys. |
| 245 pp::Var DoReleaseAllKeys(const std::vector<pp::Var>& args, | 224 pp::Var DoReleaseAllKeys(const std::vector<pp::Var>& args, |
| 246 pp::Var* exception); | 225 pp::Var* exception); |
| 247 | 226 |
| 248 PropertyNameMap property_names_; | 227 PropertyNameMap property_names_; |
| 249 std::vector<PropertyDescriptor> properties_; | 228 std::vector<PropertyDescriptor> properties_; |
| 250 scoped_refptr<PepperXmppProxy> xmpp_proxy_; | 229 scoped_refptr<PepperXmppProxy> xmpp_proxy_; |
| 251 | 230 |
| 252 ChromotingInstance* instance_; | 231 ChromotingInstance* instance_; |
| 253 | 232 |
| 254 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; | 233 scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; |
| 255 ScopedRunnableMethodFactory<ChromotingScriptableObject> task_factory_; | 234 ScopedRunnableMethodFactory<ChromotingScriptableObject> task_factory_; |
| 256 | 235 |
| 257 DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject); | 236 DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject); |
| 258 }; | 237 }; |
| 259 | 238 |
| 260 } // namespace remoting | 239 } // namespace remoting |
| 261 | 240 |
| 262 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ | 241 #endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ |
| OLD | NEW |