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

Unified Diff: remoting/host/client_session.cc

Issue 6724033: Remove authenticated_ fields from stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix .gyp file for unit tests. Created 9 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/client_session.cc
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 72cd5ba518fe202209ae9a22d4e33dc5eb8fc141..003631f0a8f2671e9c8d4656041351931545705a 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -6,6 +6,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/task.h"
+#include "media/base/callback.h"
Alpha Left Google 2011/03/28 16:22:26 do you mean base/callback.h?
simonmorris 2011/03/29 17:07:51 I wanted media/base/callback.h for AutoTaskRunner.
#include "remoting/host/user_authenticator.h"
#include "remoting/proto/auth.pb.h"
@@ -13,9 +14,14 @@ namespace remoting {
ClientSession::ClientSession(
EventHandler* event_handler,
- scoped_refptr<protocol::ConnectionToClient> connection)
+ const base::Callback<UserAuthenticator*(void)>& auth_factory,
+ scoped_refptr<protocol::ConnectionToClient> connection,
+ protocol::InputStub* input_stub)
: event_handler_(event_handler),
- connection_(connection) {
+ auth_factory_(auth_factory),
+ connection_(connection),
+ input_stub_(input_stub),
+ authenticated_(false) {
}
ClientSession::~ClientSession() {
@@ -23,8 +29,13 @@ ClientSession::~ClientSession() {
void ClientSession::SuggestResolution(
const protocol::SuggestResolutionRequest* msg, Task* done) {
- done->Run();
- delete done;
+ media::AutoTaskRunner task_runner(done);
+
+ if (!authenticated_) {
+ LOG(WARNING) << "Invalid control message received "
+ << "(client not authenticated).";
+ return;
+ }
}
void ClientSession::BeginSessionRequest(
@@ -32,7 +43,7 @@ void ClientSession::BeginSessionRequest(
DCHECK(event_handler_);
bool success = false;
- scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create());
+ scoped_ptr<UserAuthenticator> authenticator(auth_factory_.Run());
switch (credentials->type()) {
case protocol::PASSWORD:
success = authenticator->Authenticate(credentials->username(),
@@ -45,6 +56,7 @@ void ClientSession::BeginSessionRequest(
}
if (success) {
+ authenticated_ = true;
event_handler_->LocalLoginSucceeded(connection_.get());
} else {
LOG(WARNING) << "Login failed for user " << credentials->username();
@@ -55,12 +67,37 @@ void ClientSession::BeginSessionRequest(
delete done;
}
+void ClientSession::InjectKeyEvent(const protocol::KeyEvent* event,
+ Task* done) {
+ if (authenticated_) {
+ input_stub_->InjectKeyEvent(event, done);
+ return;
+ }
+ done->Run();
+ delete done;
+}
+
+void ClientSession::InjectMouseEvent(const protocol::MouseEvent* event,
+ Task* done) {
+ if (authenticated_) {
+ input_stub_->InjectMouseEvent(event, done);
+ return;
+ }
+ done->Run();
+ delete done;
+}
+
void ClientSession::Disconnect() {
connection_->Disconnect();
+ authenticated_ = false;
}
protocol::ConnectionToClient* ClientSession::connection() const {
return connection_.get();
}
+bool ClientSession::authenticated() const {
+ return authenticated_;
+}
+
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698