| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/host_user_interface.h" | 5 #include "remoting/host/host_user_interface.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "remoting/host/chromoting_host.h" | 8 #include "remoting/host/chromoting_host.h" |
| 9 #include "remoting/host/chromoting_host_context.h" | 9 #include "remoting/host/chromoting_host_context.h" |
| 10 #include "remoting/host/disconnect_window.h" | 10 #include "remoting/host/disconnect_window.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 25 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
| 26 | 26 |
| 27 MonitorLocalInputs(false); | 27 MonitorLocalInputs(false); |
| 28 ShowDisconnectWindow(false, std::string()); | 28 ShowDisconnectWindow(false, std::string()); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void HostUserInterface::Start(ChromotingHost* host, | 31 void HostUserInterface::Start(ChromotingHost* host, |
| 32 const base::Closure& disconnect_callback) { | 32 const base::Closure& disconnect_callback) { |
| 33 DCHECK(network_task_runner()->BelongsToCurrentThread()); | 33 DCHECK(network_task_runner()->BelongsToCurrentThread()); |
| 34 DCHECK(host_ == NULL); | 34 DCHECK(host_ == NULL); |
| 35 DCHECK(disconnect_callback_.is_null()); | |
| 36 | 35 |
| 37 host_ = host; | 36 host_ = host; |
| 38 disconnect_callback_ = disconnect_callback; | 37 disconnect_callback_ = disconnect_callback; |
| 39 disconnect_window_ = DisconnectWindow::Create(); | 38 disconnect_window_ = DisconnectWindow::Create(); |
| 40 local_input_monitor_ = LocalInputMonitor::Create(); | 39 local_input_monitor_ = LocalInputMonitor::Create(); |
| 41 host_->AddStatusObserver(this); | 40 host_->AddStatusObserver(this); |
| 42 } | 41 } |
| 43 | 42 |
| 44 void HostUserInterface::OnClientAuthenticated(const std::string& jid) { | 43 void HostUserInterface::OnClientAuthenticated(const std::string& jid) { |
| 45 DCHECK(network_task_runner()->BelongsToCurrentThread()); | 44 DCHECK(network_task_runner()->BelongsToCurrentThread()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 83 |
| 85 base::SingleThreadTaskRunner* HostUserInterface::network_task_runner() const { | 84 base::SingleThreadTaskRunner* HostUserInterface::network_task_runner() const { |
| 86 return context_->network_task_runner(); | 85 return context_->network_task_runner(); |
| 87 } | 86 } |
| 88 base::SingleThreadTaskRunner* HostUserInterface::ui_task_runner() const { | 87 base::SingleThreadTaskRunner* HostUserInterface::ui_task_runner() const { |
| 89 return context_->ui_task_runner(); | 88 return context_->ui_task_runner(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 void HostUserInterface::DisconnectSession() const { | 91 void HostUserInterface::DisconnectSession() const { |
| 93 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 92 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
| 94 DCHECK(!disconnect_callback_.is_null()); | |
| 95 | 93 |
| 96 disconnect_callback_.Run(); | 94 disconnect_callback_.Run(); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void HostUserInterface::ProcessOnClientAuthenticated( | 97 void HostUserInterface::ProcessOnClientAuthenticated( |
| 100 const std::string& username) { | 98 const std::string& username) { |
| 101 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 99 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
| 102 | 100 |
| 103 MonitorLocalInputs(true); | 101 MonitorLocalInputs(true); |
| 104 ShowDisconnectWindow(true, username); | 102 ShowDisconnectWindow(true, username); |
| 105 } | 103 } |
| 106 | 104 |
| 107 void HostUserInterface::ProcessOnClientDisconnected() { | 105 void HostUserInterface::ProcessOnClientDisconnected() { |
| 108 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 106 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
| 109 | 107 |
| 110 MonitorLocalInputs(false); | 108 MonitorLocalInputs(false); |
| 111 ShowDisconnectWindow(false, std::string()); | 109 ShowDisconnectWindow(false, std::string()); |
| 112 } | 110 } |
| 113 | 111 |
| 114 void HostUserInterface::StartForTest( | 112 void HostUserInterface::StartForTest( |
| 115 ChromotingHost* host, | 113 ChromotingHost* host, |
| 116 const base::Closure& disconnect_callback, | 114 const base::Closure& disconnect_callback, |
| 117 scoped_ptr<DisconnectWindow> disconnect_window, | 115 scoped_ptr<DisconnectWindow> disconnect_window, |
| 118 scoped_ptr<LocalInputMonitor> local_input_monitor) { | 116 scoped_ptr<LocalInputMonitor> local_input_monitor) { |
| 119 DCHECK(network_task_runner()->BelongsToCurrentThread()); | 117 DCHECK(network_task_runner()->BelongsToCurrentThread()); |
| 120 DCHECK(host_ == NULL); | 118 DCHECK(host_ == NULL); |
| 121 DCHECK(disconnect_callback_.is_null()); | |
| 122 | 119 |
| 123 host_ = host; | 120 host_ = host; |
| 124 disconnect_callback_ = disconnect_callback; | 121 disconnect_callback_ = disconnect_callback; |
| 125 disconnect_window_ = disconnect_window.Pass(); | 122 disconnect_window_ = disconnect_window.Pass(); |
| 126 local_input_monitor_ = local_input_monitor.Pass(); | 123 local_input_monitor_ = local_input_monitor.Pass(); |
| 127 } | 124 } |
| 128 | 125 |
| 129 void HostUserInterface::MonitorLocalInputs(bool enable) { | 126 void HostUserInterface::MonitorLocalInputs(bool enable) { |
| 130 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 127 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
| 131 | 128 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 147 disconnect_window_->Show( | 144 disconnect_window_->Show( |
| 148 host_, | 145 host_, |
| 149 base::Bind(&HostUserInterface::OnDisconnectCallback, weak_ptr_), | 146 base::Bind(&HostUserInterface::OnDisconnectCallback, weak_ptr_), |
| 150 username); | 147 username); |
| 151 } else { | 148 } else { |
| 152 disconnect_window_->Hide(); | 149 disconnect_window_->Hide(); |
| 153 } | 150 } |
| 154 } | 151 } |
| 155 | 152 |
| 156 } // namespace remoting | 153 } // namespace remoting |
| OLD | NEW |