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/disconnect_window.h" | 9 #include "remoting/host/disconnect_window.h" |
10 #include "remoting/host/local_input_monitor.h" | 10 #include "remoting/host/local_input_monitor.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
14 HostUserInterface::HostUserInterface( | 14 HostUserInterface::HostUserInterface( |
15 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 15 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
16 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 16 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| 17 const UiStrings& ui_strings) |
17 : host_(NULL), | 18 : host_(NULL), |
18 network_task_runner_(network_task_runner), | 19 network_task_runner_(network_task_runner), |
19 ui_task_runner_(ui_task_runner), | 20 ui_task_runner_(ui_task_runner), |
20 is_monitoring_local_inputs_(false), | 21 is_monitoring_local_inputs_(false), |
| 22 ui_strings_(ui_strings), |
21 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 23 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
22 weak_ptr_(weak_factory_.GetWeakPtr()) { | 24 weak_ptr_(weak_factory_.GetWeakPtr()) { |
23 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 25 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
24 } | 26 } |
25 | 27 |
26 HostUserInterface::~HostUserInterface() { | 28 HostUserInterface::~HostUserInterface() { |
27 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 29 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
28 | 30 |
29 MonitorLocalInputs(false); | 31 MonitorLocalInputs(false); |
30 disconnect_window_->Hide(); | 32 disconnect_window_->Hide(); |
31 } | 33 } |
32 | 34 |
33 void HostUserInterface::Init() { | 35 void HostUserInterface::Init() { |
34 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 36 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
35 | 37 |
36 disconnect_window_ = DisconnectWindow::Create(); | 38 disconnect_window_ = DisconnectWindow::Create(&ui_strings()); |
37 local_input_monitor_ = LocalInputMonitor::Create(); | 39 local_input_monitor_ = LocalInputMonitor::Create(); |
38 } | 40 } |
39 | 41 |
40 void HostUserInterface::Start(ChromotingHost* host, | 42 void HostUserInterface::Start(ChromotingHost* host, |
41 const base::Closure& disconnect_callback) { | 43 const base::Closure& disconnect_callback) { |
42 DCHECK(network_task_runner_->BelongsToCurrentThread()); | 44 DCHECK(network_task_runner_->BelongsToCurrentThread()); |
43 DCHECK(host_ == NULL); | 45 DCHECK(host_ == NULL); |
44 | 46 |
45 host_ = host; | 47 host_ = host; |
46 disconnect_callback_ = disconnect_callback; | 48 disconnect_callback_ = disconnect_callback; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 102 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
101 | 103 |
102 disconnect_callback_.Run(); | 104 disconnect_callback_.Run(); |
103 } | 105 } |
104 | 106 |
105 void HostUserInterface::ProcessOnClientAuthenticated( | 107 void HostUserInterface::ProcessOnClientAuthenticated( |
106 const std::string& username) { | 108 const std::string& username) { |
107 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 109 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
108 | 110 |
109 if (!disconnect_window_->Show( | 111 if (!disconnect_window_->Show( |
110 host_->ui_strings(), | |
111 base::Bind(&HostUserInterface::OnDisconnectCallback, weak_ptr_), | 112 base::Bind(&HostUserInterface::OnDisconnectCallback, weak_ptr_), |
112 username)) { | 113 username)) { |
113 LOG(ERROR) << "Failed to show the disconnect window."; | 114 LOG(ERROR) << "Failed to show the disconnect window."; |
114 DisconnectSession(); | 115 DisconnectSession(); |
115 return; | 116 return; |
116 } | 117 } |
117 | 118 |
118 MonitorLocalInputs(true); | 119 MonitorLocalInputs(true); |
119 } | 120 } |
120 | 121 |
(...skipping 11 matching lines...) Expand all Loading... |
132 if (enable) { | 133 if (enable) { |
133 local_input_monitor_->Start(host_, disconnect_callback_); | 134 local_input_monitor_->Start(host_, disconnect_callback_); |
134 } else { | 135 } else { |
135 local_input_monitor_->Stop(); | 136 local_input_monitor_->Stop(); |
136 } | 137 } |
137 is_monitoring_local_inputs_ = enable; | 138 is_monitoring_local_inputs_ = enable; |
138 } | 139 } |
139 } | 140 } |
140 | 141 |
141 } // namespace remoting | 142 } // namespace remoting |
OLD | NEW |