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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "net/base/io_buffer.h" | 6 #include "net/base/io_buffer.h" |
7 #include "remoting/proto/control.pb.h" | 7 #include "remoting/proto/control.pb.h" |
8 #include "remoting/proto/event.pb.h" | 8 #include "remoting/proto/event.pb.h" |
9 #include "remoting/proto/internal.pb.h" | 9 #include "remoting/proto/internal.pb.h" |
10 #include "remoting/protocol/connection_to_client.h" | 10 #include "remoting/protocol/connection_to_client.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 event_message_reader_->Init( | 42 event_message_reader_->Init( |
43 session->event_channel(), | 43 session->event_channel(), |
44 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); | 44 NewCallback(this, &HostMessageDispatcher::OnEventMessageReceived)); |
45 control_message_reader_->Init( | 45 control_message_reader_->Init( |
46 session->control_channel(), | 46 session->control_channel(), |
47 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); | 47 NewCallback(this, &HostMessageDispatcher::OnControlMessageReceived)); |
48 } | 48 } |
49 | 49 |
50 void HostMessageDispatcher::OnControlMessageReceived( | 50 void HostMessageDispatcher::OnControlMessageReceived( |
51 ControlMessage* message, Task* done_task) { | 51 ControlMessage* message, Task* done_task) { |
52 // BeginSessionRequest is always allowed. | 52 // TODO(sergeyu): Add message validation. |
53 if (message->has_begin_session_request()) { | 53 if (message->has_begin_session_request()) { |
54 host_stub_->BeginSessionRequest( | 54 host_stub_->BeginSessionRequest( |
55 &message->begin_session_request().credentials(), done_task); | 55 &message->begin_session_request().credentials(), done_task); |
56 return; | 56 return; |
57 } | 57 } |
58 if (!host_stub_->authenticated()) { | 58 if (message->has_suggest_resolution()) { |
59 // When the client has not authenticated with the host, no other messages | 59 host_stub_->SuggestResolution(&message->suggest_resolution(), done_task); |
60 // are allowed. | 60 return; |
61 LOG(WARNING) << "Invalid control message received " | |
62 << "(client not authenticated)."; | |
63 } else { | |
64 // TODO(sergeyu): Add message validation. | |
65 if (message->has_suggest_resolution()) { | |
66 host_stub_->SuggestResolution(&message->suggest_resolution(), done_task); | |
67 return; | |
68 } else { | |
69 LOG(WARNING) << "Invalid control message received."; | |
70 } | |
71 } | 61 } |
62 LOG(WARNING) << "Invalid control message received."; | |
Wez
2011/03/30 20:24:57
If not authenticated, disconnect?
simonmorris
2011/03/31 11:14:00
Could be good, in another CL.
| |
72 done_task->Run(); | 63 done_task->Run(); |
73 delete done_task; | 64 delete done_task; |
74 } | 65 } |
75 | 66 |
76 void HostMessageDispatcher::OnEventMessageReceived( | 67 void HostMessageDispatcher::OnEventMessageReceived( |
77 EventMessage* message, Task* done_task) { | 68 EventMessage* message, Task* done_task) { |
78 if (input_stub_->authenticated()) { | 69 // TODO(sergeyu): Add message validation. |
79 // TODO(sergeyu): Add message validation. | 70 if (message->has_key_event()) { |
80 if (message->has_key_event()) { | 71 input_stub_->InjectKeyEvent(&message->key_event(), done_task); |
81 input_stub_->InjectKeyEvent(&message->key_event(), done_task); | 72 } else if (message->has_mouse_event()) { |
82 } else if (message->has_mouse_event()) { | 73 input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); |
83 input_stub_->InjectMouseEvent(&message->mouse_event(), done_task); | 74 } else { |
84 } else { | 75 LOG(WARNING) << "Invalid event message received."; |
85 LOG(WARNING) << "Invalid event message received."; | 76 done_task->Run(); |
86 done_task->Run(); | 77 delete done_task; |
Wez
2011/03/30 20:24:57
If not authenticated, disconnect?
nit: This block
simonmorris
2011/03/31 11:14:00
Done.
| |
87 delete done_task; | |
88 } | |
89 } | 78 } |
90 } | 79 } |
91 | 80 |
92 } // namespace protocol | 81 } // namespace protocol |
93 } // namespace remoting | 82 } // namespace remoting |
OLD | NEW |