| 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/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "remoting/base/constants.h" | 8 #include "remoting/base/constants.h" |
| 9 #include "remoting/base/encoder.h" | 9 #include "remoting/base/encoder.h" |
| 10 #include "remoting/base/encoder_row_based.h" | 10 #include "remoting/base/encoder_row_based.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 365 |
| 366 // Close the connection to connection just to be safe. | 366 // Close the connection to connection just to be safe. |
| 367 connection->Disconnect(); | 367 connection->Disconnect(); |
| 368 | 368 |
| 369 // Also remove reference to ConnectionToClient from this object. | 369 // Also remove reference to ConnectionToClient from this object. |
| 370 clients_.erase(client); | 370 clients_.erase(client); |
| 371 | 371 |
| 372 if (!HasAuthenticatedClients()) { | 372 if (!HasAuthenticatedClients()) { |
| 373 EnableCurtainMode(false); | 373 EnableCurtainMode(false); |
| 374 if (is_me2mom_) | 374 if (is_me2mom_) |
| 375 desktop_environment_->disconnect_window()->Hide(); | 375 ShowDisconnectWindow(false, std::string()); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 // TODO(sergeyu): Move this to SessionManager? | 379 // TODO(sergeyu): Move this to SessionManager? |
| 380 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { | 380 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { |
| 381 const protocol::ChannelConfig& video_config = config->video_config(); | 381 const protocol::ChannelConfig& video_config = config->video_config(); |
| 382 | 382 |
| 383 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | 383 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
| 384 return EncoderRowBased::CreateVerbatimEncoder(); | 384 return EncoderRowBased::CreateVerbatimEncoder(); |
| 385 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { | 385 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 | 464 |
| 465 // Immediately add the connection and start the session. | 465 // Immediately add the connection and start the session. |
| 466 recorder_->AddConnection(connection); | 466 recorder_->AddConnection(connection); |
| 467 recorder_->Start(); | 467 recorder_->Start(); |
| 468 EnableCurtainMode(true); | 468 EnableCurtainMode(true); |
| 469 if (is_me2mom_) { | 469 if (is_me2mom_) { |
| 470 std::string username = connection->session()->jid(); | 470 std::string username = connection->session()->jid(); |
| 471 size_t pos = username.find('/'); | 471 size_t pos = username.find('/'); |
| 472 if (pos != std::string::npos) | 472 if (pos != std::string::npos) |
| 473 username.replace(pos, std::string::npos, ""); | 473 username.replace(pos, std::string::npos, ""); |
| 474 desktop_environment_->disconnect_window()->Show(this, username); | 474 ShowDisconnectWindow(true, username); |
| 475 } | 475 } |
| 476 } | 476 } |
| 477 | 477 |
| 478 void ChromotingHost::LocalLoginFailed( | 478 void ChromotingHost::LocalLoginFailed( |
| 479 scoped_refptr<ConnectionToClient> connection) { | 479 scoped_refptr<ConnectionToClient> connection) { |
| 480 if (MessageLoop::current() != context_->main_message_loop()) { | 480 if (MessageLoop::current() != context_->main_message_loop()) { |
| 481 context_->main_message_loop()->PostTask( | 481 context_->main_message_loop()->PostTask( |
| 482 FROM_HERE, | 482 FROM_HERE, |
| 483 NewRunnableMethod(this, &ChromotingHost::LocalLoginFailed, connection)); | 483 NewRunnableMethod(this, &ChromotingHost::LocalLoginFailed, connection)); |
| 484 return; | 484 return; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 496 // Find the client session corresponding to the given connection. | 496 // Find the client session corresponding to the given connection. |
| 497 ClientList::iterator client; | 497 ClientList::iterator client; |
| 498 for (client = clients_.begin(); client != clients_.end(); ++client) { | 498 for (client = clients_.begin(); client != clients_.end(); ++client) { |
| 499 if (client->get()->connection() == connection) | 499 if (client->get()->connection() == connection) |
| 500 break; | 500 break; |
| 501 } | 501 } |
| 502 CHECK(client != clients_.end()); | 502 CHECK(client != clients_.end()); |
| 503 client->get()->OnAuthorizationComplete(true); | 503 client->get()->OnAuthorizationComplete(true); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void ChromotingHost::ShowDisconnectWindow(bool show, |
| 507 const std::string& username) { |
| 508 if (context_->ui_message_loop() != MessageLoop::current()) { |
| 509 context_->ui_message_loop()->PostTask( |
| 510 FROM_HERE, |
| 511 NewRunnableMethod(this, &ChromotingHost::ShowDisconnectWindow, |
| 512 show, username)); |
| 513 return; |
| 514 } |
| 515 |
| 516 if (show) { |
| 517 desktop_environment_->disconnect_window()->Show(this, username); |
| 518 } else { |
| 519 desktop_environment_->disconnect_window()->Hide(); |
| 520 } |
| 521 } |
| 522 |
| 506 } // namespace remoting | 523 } // namespace remoting |
| OLD | NEW |