Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: remoting/host/chromoting_host.cc

Issue 8351084: Remove old Authentication code that we don't use or need. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "remoting/base/constants.h" 12 #include "remoting/base/constants.h"
13 #include "remoting/base/encoder.h" 13 #include "remoting/base/encoder.h"
14 #include "remoting/base/encoder_row_based.h" 14 #include "remoting/base/encoder_row_based.h"
15 #include "remoting/base/encoder_vp8.h" 15 #include "remoting/base/encoder_vp8.h"
16 #include "remoting/host/chromoting_host_context.h" 16 #include "remoting/host/chromoting_host_context.h"
17 #include "remoting/host/curtain.h" 17 #include "remoting/host/curtain.h"
18 #include "remoting/host/desktop_environment.h" 18 #include "remoting/host/desktop_environment.h"
19 #include "remoting/host/event_executor.h" 19 #include "remoting/host/event_executor.h"
20 #include "remoting/host/host_config.h" 20 #include "remoting/host/host_config.h"
21 #include "remoting/host/host_key_pair.h" 21 #include "remoting/host/host_key_pair.h"
22 #include "remoting/host/screen_recorder.h" 22 #include "remoting/host/screen_recorder.h"
23 #include "remoting/host/user_authenticator.h" 23 #include "remoting/host/user_authenticator.h"
24 #include "remoting/jingle_glue/xmpp_signal_strategy.h" 24 #include "remoting/jingle_glue/xmpp_signal_strategy.h"
25 #include "remoting/proto/auth.pb.h"
26 #include "remoting/protocol/connection_to_client.h" 25 #include "remoting/protocol/connection_to_client.h"
27 #include "remoting/protocol/client_stub.h" 26 #include "remoting/protocol/client_stub.h"
28 #include "remoting/protocol/host_stub.h" 27 #include "remoting/protocol/host_stub.h"
29 #include "remoting/protocol/input_stub.h" 28 #include "remoting/protocol/input_stub.h"
30 #include "remoting/protocol/jingle_session_manager.h" 29 #include "remoting/protocol/jingle_session_manager.h"
31 #include "remoting/protocol/session_config.h" 30 #include "remoting/protocol/session_config.h"
32 31
33 using remoting::protocol::ConnectionToClient; 32 using remoting::protocol::ConnectionToClient;
34 using remoting::protocol::InputStub; 33 using remoting::protocol::InputStub;
35 34
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 LOG(INFO) << "Client connected: " << session->jid(); 296 LOG(INFO) << "Client connected: " << session->jid();
298 297
299 // We accept the connection, so create a connection object. 298 // We accept the connection, so create a connection object.
300 ConnectionToClient* connection = new ConnectionToClient( 299 ConnectionToClient* connection = new ConnectionToClient(
301 context_->network_message_loop(), this); 300 context_->network_message_loop(), this);
302 connection->Init(session); 301 connection->Init(session);
303 302
304 // Create a client object. 303 // Create a client object.
305 ClientSession* client = new ClientSession( 304 ClientSession* client = new ClientSession(
306 this, 305 this,
307 UserAuthenticator::Create(),
308 connection, 306 connection,
309 desktop_environment_->event_executor(), 307 desktop_environment_->event_executor(),
310 desktop_environment_->capturer()); 308 desktop_environment_->capturer());
311 connection->set_host_stub(client); 309 connection->set_host_stub(client);
312 connection->set_input_stub(client); 310 connection->set_input_stub(client);
313 311
314 clients_.push_back(client); 312 clients_.push_back(client);
315 } 313 }
316 314
317 void ChromotingHost::set_protocol_config( 315 void ChromotingHost::set_protocol_config(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 if (recorder_.get()) { 373 if (recorder_.get()) {
376 recorder_->RemoveConnection(connection); 374 recorder_->RemoveConnection(connection);
377 } 375 }
378 376
379 // Close the connection to client just to be safe. 377 // Close the connection to client just to be safe.
380 // TODO(garykac): This should be removed when we revisit our shutdown and 378 // TODO(garykac): This should be removed when we revisit our shutdown and
381 // disconnect code. This should only need to be done in 379 // disconnect code. This should only need to be done in
382 // ClientSession::Disconnect(). 380 // ClientSession::Disconnect().
383 connection->Disconnect(); 381 connection->Disconnect();
384 382
385 if (client->authenticated()) { 383 if (client->authenticated()) {
Wez 2011/11/03 18:14:37 Why remove the conditional?
386 for (StatusObserverList::iterator it = status_observers_.begin(); 384 for (StatusObserverList::iterator it = status_observers_.begin();
387 it != status_observers_.end(); ++it) { 385 it != status_observers_.end(); ++it) {
388 (*it)->OnClientDisconnected(client->client_jid()); 386 (*it)->OnClientDisconnected(client->client_jid());
389 } 387 }
390 } 388 }
391 389
392 if (AuthenticatedClientsCount() == 0) { 390 if (AuthenticatedClientsCount() == 0) {
393 if (recorder_.get()) { 391 if (recorder_.get()) {
394 // Stop the recorder if there are no more clients. 392 // Stop the recorder if there are no more clients.
395 StopScreenRecorder(); 393 StopScreenRecorder();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 void ChromotingHost::EnableCurtainMode(bool enable) { 437 void ChromotingHost::EnableCurtainMode(bool enable) {
440 // TODO(jamiewalch): This will need to be more sophisticated when we think 438 // TODO(jamiewalch): This will need to be more sophisticated when we think
441 // about proper crash recovery and daemon mode. 439 // about proper crash recovery and daemon mode.
442 // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost. 440 // TODO(wez): CurtainMode shouldn't be driven directly by ChromotingHost.
443 if (is_it2me_ || enable == is_curtained_) 441 if (is_it2me_ || enable == is_curtained_)
444 return; 442 return;
445 desktop_environment_->curtain()->EnableCurtainMode(enable); 443 desktop_environment_->curtain()->EnableCurtainMode(enable);
446 is_curtained_ = enable; 444 is_curtained_ = enable;
447 } 445 }
448 446
449 void ChromotingHost::LocalLoginSucceeded( 447 void ChromotingHost::OnAuthorizationComplete(
450 scoped_refptr<ConnectionToClient> connection) { 448 scoped_refptr<ConnectionToClient> connection) {
451 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 449 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
452 450
453 context_->main_message_loop()->PostTask( 451 context_->main_message_loop()->PostTask(
454 FROM_HERE, base::Bind(&ChromotingHost::AddAuthenticatedClient, 452 FROM_HERE, base::Bind(&ChromotingHost::AddAuthenticatedClient,
455 this, connection, connection->session()->config(), 453 this, connection, connection->session()->config(),
456 connection->session()->jid())); 454 connection->session()->jid()));
457 } 455 }
458 456
459 void ChromotingHost::AddAuthenticatedClient( 457 void ChromotingHost::AddAuthenticatedClient(
460 scoped_refptr<ConnectionToClient> connection, 458 scoped_refptr<ConnectionToClient> connection,
461 const protocol::SessionConfig& config, 459 const protocol::SessionConfig& config,
462 const std::string& jid) { 460 const std::string& jid) {
463 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 461 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
464 462
465 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
466 status->set_success(true);
467 connection->client_stub()->BeginSessionResponse(
468 status, base::Bind(&DeletePointer<protocol::LocalLoginStatus>, status));
469
470 // Disconnect all other clients. 463 // Disconnect all other clients.
471 // Iterate over a copy of the list of clients, to avoid mutating the list 464 // Iterate over a copy of the list of clients, to avoid mutating the list
472 // while iterating over it. 465 // while iterating over it.
473 ClientList clients_copy(clients_); 466 ClientList clients_copy(clients_);
474 for (ClientList::const_iterator client = clients_copy.begin(); 467 for (ClientList::const_iterator client = clients_copy.begin();
475 client != clients_copy.end(); client++) { 468 client != clients_copy.end(); client++) {
476 ConnectionToClient* connection_other = client->get()->connection(); 469 ConnectionToClient* connection_other = client->get()->connection();
477 if (connection_other != connection) { 470 if (connection_other != connection) {
478 OnClientDisconnected(connection_other); 471 OnClientDisconnected(connection_other);
479 } 472 }
(...skipping 27 matching lines...) Expand all
507 EnableCurtainMode(true); 500 EnableCurtainMode(true);
508 if (is_it2me_) { 501 if (is_it2me_) {
509 std::string username = jid; 502 std::string username = jid;
510 size_t pos = username.find('/'); 503 size_t pos = username.find('/');
511 if (pos != std::string::npos) 504 if (pos != std::string::npos)
512 username.replace(pos, std::string::npos, ""); 505 username.replace(pos, std::string::npos, "");
513 desktop_environment_->OnConnect(username); 506 desktop_environment_->OnConnect(username);
514 } 507 }
515 } 508 }
516 509
517 void ChromotingHost::LocalLoginFailed(
518 scoped_refptr<ConnectionToClient> connection) {
519 if (MessageLoop::current() != context_->main_message_loop()) {
520 context_->main_message_loop()->PostTask(
521 FROM_HERE, base::Bind(&ChromotingHost::LocalLoginFailed, this,
522 connection));
523 return;
524 }
525
526 protocol::LocalLoginStatus* status = new protocol::LocalLoginStatus();
527 status->set_success(false);
528 connection->client_stub()->BeginSessionResponse(
529 status, base::Bind(&DeletePointer<protocol::LocalLoginStatus>, status));
530 }
531
532 void ChromotingHost::ProcessPreAuthentication( 510 void ChromotingHost::ProcessPreAuthentication(
533 const scoped_refptr<ConnectionToClient>& connection) { 511 const scoped_refptr<ConnectionToClient>& connection) {
534 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current()); 512 DCHECK_EQ(context_->main_message_loop(), MessageLoop::current());
535 // Find the client session corresponding to the given connection. 513 // Find the client session corresponding to the given connection.
536 ClientList::iterator client; 514 ClientList::iterator client;
537 for (client = clients_.begin(); client != clients_.end(); ++client) { 515 for (client = clients_.begin(); client != clients_.end(); ++client) {
538 if (client->get()->connection() == connection) 516 if (client->get()->connection() == connection)
539 break; 517 break;
540 } 518 }
541 CHECK(client != clients_.end()); 519 CHECK(client != clients_.end());
542 520
543 context_->network_message_loop()->PostTask( 521 context_->network_message_loop()->PostTask(
544 FROM_HERE, base::Bind(&ClientSession::OnAuthorizationComplete, 522 FROM_HERE, base::Bind(&ClientSession::OnAuthorizationComplete,
545 client->get(), true)); 523 client->get()));
Wez 2011/11/03 00:25:02 nit: It seems a little strange that we go through
Sergey Ulanov 2011/11/03 01:21:12 The original intent was to call authorization the
Wez 2011/11/03 18:14:37 Strictly speaking, we should probably talk about a
546 } 524 }
547 525
548 void ChromotingHost::StopScreenRecorder() { 526 void ChromotingHost::StopScreenRecorder() {
549 DCHECK(MessageLoop::current() == context_->main_message_loop()); 527 DCHECK(MessageLoop::current() == context_->main_message_loop());
550 DCHECK(recorder_.get()); 528 DCHECK(recorder_.get());
551 529
552 ++stopping_recorders_; 530 ++stopping_recorders_;
553 recorder_->Stop(base::Bind(&ChromotingHost::OnScreenRecorderStopped, this)); 531 recorder_->Stop(base::Bind(&ChromotingHost::OnScreenRecorderStopped, this));
554 recorder_ = NULL; 532 recorder_ = NULL;
555 } 533 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 617
640 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin(); 618 for (std::vector<Task*>::iterator it = shutdown_tasks_.begin();
641 it != shutdown_tasks_.end(); ++it) { 619 it != shutdown_tasks_.end(); ++it) {
642 (*it)->Run(); 620 (*it)->Run();
643 delete *it; 621 delete *it;
644 } 622 }
645 shutdown_tasks_.clear(); 623 shutdown_tasks_.clear();
646 } 624 }
647 625
648 } // namespace remoting 626 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698