Chromium Code Reviews| 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 #include "remoting/host/plugin/host_script_object.h" | 5 #include "remoting/host/plugin/host_script_object.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 } | 316 } |
| 317 | 317 |
| 318 void HostNPScriptObject::OnAccessDenied() { | 318 void HostNPScriptObject::OnAccessDenied() { |
| 319 DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread()); | 319 DCHECK(host_context_.network_message_loop()->BelongsToCurrentThread()); |
| 320 | 320 |
| 321 ++failed_login_attempts_; | 321 ++failed_login_attempts_; |
| 322 if (failed_login_attempts_ == kMaxLoginAttempts) | 322 if (failed_login_attempts_ == kMaxLoginAttempts) |
| 323 DisconnectInternal(); | 323 DisconnectInternal(); |
| 324 } | 324 } |
| 325 | 325 |
| 326 void HostNPScriptObject::OnClientAuthenticated( | 326 void HostNPScriptObject::OnClientAuthenticated(const std::string& jid) { |
| 327 remoting::protocol::ConnectionToClient* client) { | |
| 328 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); | 327 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); |
| 329 | 328 |
| 330 if (state_ == kDisconnecting) { | 329 if (state_ == kDisconnecting) { |
| 331 // Ignore the new connection if we are disconnecting. | 330 // Ignore the new connection if we are disconnecting. |
| 332 return; | 331 return; |
| 333 } | 332 } |
| 334 | 333 |
| 335 client_username_ = client->session()->jid(); | 334 client_username_ = jid; |
| 336 size_t pos = client_username_.find('/'); | 335 size_t pos = client_username_.find('/'); |
| 337 if (pos != std::string::npos) | 336 if (pos != std::string::npos) |
| 338 client_username_.replace(pos, std::string::npos, ""); | 337 client_username_.replace(pos, std::string::npos, ""); |
|
Wez
2011/09/12 22:40:44
Not related to this CL per-se, but should we be de
Sergey Ulanov
2011/09/12 22:53:22
We could use buzz::Jid class here, but it means th
| |
| 339 LOG(INFO) << "Client " << client_username_ << " connected."; | 338 LOG(INFO) << "Client " << client_username_ << " connected."; |
| 340 SetState(kConnected); | 339 SetState(kConnected); |
| 341 } | 340 } |
| 342 | 341 |
| 343 void HostNPScriptObject::OnClientDisconnected( | 342 void HostNPScriptObject::OnClientDisconnected(const std::string& jid) { |
| 344 remoting::protocol::ConnectionToClient* client) { | |
| 345 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); | 343 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); |
| 346 | 344 |
| 347 client_username_.clear(); | 345 client_username_.clear(); |
| 348 | 346 |
| 349 // Disconnect the host when a client disconnects. | 347 // Disconnect the host when a client disconnects. |
| 350 DisconnectInternal(); | 348 DisconnectInternal(); |
| 351 } | 349 } |
| 352 | 350 |
| 353 void HostNPScriptObject::OnShutdown() { | 351 void HostNPScriptObject::OnShutdown() { |
| 354 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); | 352 DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 uint32_t argCount) { | 770 uint32_t argCount) { |
| 773 NPVariant np_result; | 771 NPVariant np_result; |
| 774 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, | 772 bool is_good = g_npnetscape_funcs->invokeDefault(plugin_, func, args, |
| 775 argCount, &np_result); | 773 argCount, &np_result); |
| 776 if (is_good) | 774 if (is_good) |
| 777 g_npnetscape_funcs->releasevariantvalue(&np_result); | 775 g_npnetscape_funcs->releasevariantvalue(&np_result); |
| 778 return is_good; | 776 return is_good; |
| 779 } | 777 } |
| 780 | 778 |
| 781 } // namespace remoting | 779 } // namespace remoting |
| OLD | NEW |