| 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/desktop_environment.h" | 5 #include "remoting/host/desktop_environment.h" |
| 6 | 6 |
| 7 #include "remoting/host/capturer.h" | 7 #include "remoting/host/capturer.h" |
| 8 #include "remoting/host/chromoting_host.h" | |
| 9 #include "remoting/host/user_authenticator.h" | |
| 10 #include "remoting/proto/auth.pb.h" | |
| 11 #include "remoting/protocol/client_stub.h" | |
| 12 #include "remoting/protocol/input_stub.h" | 8 #include "remoting/protocol/input_stub.h" |
| 13 | 9 |
| 14 using remoting::protocol::InputStub; | 10 using remoting::protocol::InputStub; |
| 15 | 11 |
| 16 namespace remoting { | 12 namespace remoting { |
| 17 | 13 |
| 18 DesktopEnvironment::DesktopEnvironment(Capturer* capturer, | 14 DesktopEnvironment::DesktopEnvironment(Capturer* capturer, |
| 19 InputStub* input_stub) | 15 InputStub* input_stub) |
| 20 : event_handler_(NULL), | 16 : capturer_(capturer), |
| 21 capturer_(capturer), | |
| 22 input_stub_(input_stub) { | 17 input_stub_(input_stub) { |
| 23 } | 18 } |
| 24 | 19 |
| 25 DesktopEnvironment::~DesktopEnvironment() { | 20 DesktopEnvironment::~DesktopEnvironment() { |
| 26 } | 21 } |
| 27 | 22 |
| 28 void DesktopEnvironment::SuggestResolution( | |
| 29 const protocol::SuggestResolutionRequest* msg, Task* done) { | |
| 30 done->Run(); | |
| 31 delete done; | |
| 32 } | |
| 33 | |
| 34 void DesktopEnvironment::BeginSessionRequest( | |
| 35 const protocol::LocalLoginCredentials* credentials, Task* done) { | |
| 36 DCHECK(event_handler_); | |
| 37 | |
| 38 bool success = false; | |
| 39 scoped_ptr<UserAuthenticator> authenticator(UserAuthenticator::Create()); | |
| 40 switch (credentials->type()) { | |
| 41 case protocol::PASSWORD: | |
| 42 success = authenticator->Authenticate(credentials->username(), | |
| 43 credentials->credential()); | |
| 44 break; | |
| 45 | |
| 46 default: | |
| 47 LOG(ERROR) << "Invalid credentials type " << credentials->type(); | |
| 48 break; | |
| 49 } | |
| 50 | |
| 51 if (success) { | |
| 52 event_handler_->LocalLoginSucceeded(); | |
| 53 } else { | |
| 54 LOG(WARNING) << "Login failed for user " << credentials->username(); | |
| 55 event_handler_->LocalLoginFailed(); | |
| 56 } | |
| 57 | |
| 58 done->Run(); | |
| 59 delete done; | |
| 60 } | |
| 61 | |
| 62 } // namespace remoting | 23 } // namespace remoting |
| OLD | NEW |