Index: remoting/client/plugin/chromoting_scriptable_object.cc |
diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc |
index 106141fbcb59beceb57ad3f654e65e2f9ce726b4..6ba70f061139f2a7727a5fe24628898e708651fd 100644 |
--- a/remoting/client/plugin/chromoting_scriptable_object.cc |
+++ b/remoting/client/plugin/chromoting_scriptable_object.cc |
@@ -85,8 +85,11 @@ void ChromotingScriptableObject::Init() { |
AddAttribute(kRoundTripLatencyAttribute, Var()); |
AddMethod("connect", &ChromotingScriptableObject::DoConnect); |
+ AddMethod("connectNonce", &ChromotingScriptableObject::DoConnectNonce); |
AddMethod("connectSandboxed", |
&ChromotingScriptableObject::DoConnectSandboxed); |
+ AddMethod("connectSandboxedNonce", |
+ &ChromotingScriptableObject::DoConnectSandboxedNonce); |
Wez
2011/05/20 22:38:59
Why are you still adding these?
|
AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); |
AddMethod("submitLoginInfo", &ChromotingScriptableObject::DoSubmitLogin); |
AddMethod("setScaleToFit", &ChromotingScriptableObject::DoSetScaleToFit); |
@@ -327,16 +330,32 @@ void ChromotingScriptableObject::SendIq(const std::string& message_xml) { |
cb.Call(Var(), Var(message_xml), &exception); |
if (!exception.is_undefined()) |
- LogDebugInfo("Exception when invoking loginChallenge JS callback."); |
+ LogDebugInfo("Exception when invoking sendiq JS callback."); |
Wez
2011/05/20 22:38:59
Is This the correct callback name?
|
} |
Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, |
Var* exception) { |
- if (args.size() != 4) { |
+ if (args.size() != 3) { |
*exception = Var("Usage: connect(username, host_jid, auth_token)"); |
return Var(); |
} |
+ return DoConnect_(args, exception, false); |
+} |
+ |
+Var ChromotingScriptableObject::DoConnectNonce(const std::vector<Var>& args, |
+ Var* exception) { |
+ if (args.size() != 4) { |
+ *exception = Var("Usage: connect(username, host_jid, auth_token, nonce)"); |
+ return Var(); |
+ } |
+ |
+ return DoConnect_(args, exception, true); |
+} |
+ |
+Var ChromotingScriptableObject::DoConnect_(const std::vector<Var>& args, |
+ Var* exception, |
+ bool require_nonce) { |
ClientConfig config; |
if (!args[0].is_string()) { |
@@ -357,11 +376,13 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, |
} |
config.auth_token = args[2].AsString(); |
- if (!args[3].is_string()) { |
- *exception = Var("nonce must be a string."); |
- return Var(); |
+ if (require_nonce) { |
+ if (!args[3].is_string()) { |
+ *exception = Var("nonce must be a string."); |
+ return Var(); |
+ } |
+ config.nonce = args[3].AsString(); |
} |
- config.nonce = args[3].AsString(); |
LogDebugInfo("Connecting to host."); |
instance_->Connect(config); |
@@ -371,11 +392,26 @@ Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, |
Var ChromotingScriptableObject::DoConnectSandboxed( |
const std::vector<Var>& args, Var* exception) { |
+ if (args.size() != 2) { |
+ *exception = Var("Usage: connectSandboxed(your_jid, host_jid)"); |
+ return Var(); |
+ } |
+ |
+ return DoConnectSandboxed_(args, exception, false); |
+} |
+ |
+Var ChromotingScriptableObject::DoConnectSandboxedNonce( |
+ const std::vector<Var>& args, Var* exception) { |
if (args.size() != 3) { |
*exception = Var("Usage: connectSandboxed(your_jid, host_jid, nonce)"); |
return Var(); |
} |
+ return DoConnectSandboxed_(args, exception, true); |
+} |
+ |
+Var ChromotingScriptableObject::DoConnectSandboxed_( |
+ const std::vector<Var>& args, Var* exception, bool require_nonce) { |
std::string your_jid; |
if (!args[0].is_string()) { |
*exception = Var("your_jid must be a string."); |
@@ -391,11 +427,13 @@ Var ChromotingScriptableObject::DoConnectSandboxed( |
host_jid = args[1].AsString(); |
std::string nonce; |
- if (!args[2].is_string()) { |
- *exception = Var("nonce must be a string."); |
- return Var(); |
+ if (require_nonce) { |
+ if (!args[2].is_string()) { |
+ *exception = Var("nonce must be a string."); |
+ return Var(); |
+ } |
+ nonce = args[2].AsString(); |
} |
- nonce = args[2].AsString(); |
VLOG(1) << "your_jid: " << your_jid << ", host_jid: " << host_jid |
<< ", nonce: " << nonce; |