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/it2me_host_user_interface.h" | 5 #include "remoting/host/it2me_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/continue_window.h" | 9 #include "remoting/host/continue_window.h" |
10 #include "remoting/host/disconnect_window.h" | 10 #include "remoting/host/disconnect_window.h" |
11 #include "remoting/host/local_input_monitor.h" | 11 #include "remoting/host/local_input_monitor.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 // Milliseconds before the continue window is shown. | 15 // Milliseconds before the continue window is shown. |
16 static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000; | 16 static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000; |
17 | 17 |
18 // Milliseconds before the continue window is automatically dismissed and | 18 // Milliseconds before the continue window is automatically dismissed and |
19 // the connection is closed. | 19 // the connection is closed. |
20 static const int kContinueWindowHideTimeoutMs = 60 * 1000; | 20 static const int kContinueWindowHideTimeoutMs = 60 * 1000; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 namespace remoting { | 24 namespace remoting { |
25 | 25 |
26 It2MeHostUserInterface::It2MeHostUserInterface( | 26 It2MeHostUserInterface::It2MeHostUserInterface( |
27 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 27 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) | 28 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
29 : HostUserInterface(network_task_runner, ui_task_runner), | 29 const UiStrings& ui_strings) |
| 30 : HostUserInterface(network_task_runner, ui_task_runner, ui_strings), |
30 ALLOW_THIS_IN_INITIALIZER_LIST(timer_weak_factory_(this)) { | 31 ALLOW_THIS_IN_INITIALIZER_LIST(timer_weak_factory_(this)) { |
31 DCHECK(ui_task_runner->BelongsToCurrentThread()); | 32 DCHECK(ui_task_runner->BelongsToCurrentThread()); |
32 } | 33 } |
33 | 34 |
34 It2MeHostUserInterface::~It2MeHostUserInterface() { | 35 It2MeHostUserInterface::~It2MeHostUserInterface() { |
35 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 36 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
36 | 37 |
37 ShowContinueWindow(false); | 38 ShowContinueWindow(false); |
38 } | 39 } |
39 | 40 |
40 void It2MeHostUserInterface::Init() { | 41 void It2MeHostUserInterface::Init() { |
41 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 42 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
42 | 43 |
43 HostUserInterface::Init(); | 44 HostUserInterface::Init(); |
44 continue_window_ = ContinueWindow::Create(); | 45 continue_window_ = ContinueWindow::Create(&ui_strings()); |
45 } | 46 } |
46 | 47 |
47 void It2MeHostUserInterface::ProcessOnClientAuthenticated( | 48 void It2MeHostUserInterface::ProcessOnClientAuthenticated( |
48 const std::string& username) { | 49 const std::string& username) { |
49 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 50 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
50 | 51 |
51 HostUserInterface::ProcessOnClientAuthenticated(username); | 52 HostUserInterface::ProcessOnClientAuthenticated(username); |
52 StartContinueWindowTimer(true); | 53 StartContinueWindowTimer(true); |
53 } | 54 } |
54 | 55 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 91 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
91 | 92 |
92 ShowContinueWindow(false); | 93 ShowContinueWindow(false); |
93 DisconnectSession(); | 94 DisconnectSession(); |
94 } | 95 } |
95 | 96 |
96 void It2MeHostUserInterface::ShowContinueWindow(bool show) { | 97 void It2MeHostUserInterface::ShowContinueWindow(bool show) { |
97 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 98 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
98 | 99 |
99 if (show) { | 100 if (show) { |
100 continue_window_->Show(get_host(), base::Bind( | 101 continue_window_->Show(base::Bind( |
101 &It2MeHostUserInterface::ContinueSession, base::Unretained(this))); | 102 &It2MeHostUserInterface::ContinueSession, base::Unretained(this))); |
102 } else { | 103 } else { |
103 continue_window_->Hide(); | 104 continue_window_->Hide(); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 void It2MeHostUserInterface::StartContinueWindowTimer(bool start) { | 108 void It2MeHostUserInterface::StartContinueWindowTimer(bool start) { |
108 DCHECK(ui_task_runner()->BelongsToCurrentThread()); | 109 DCHECK(ui_task_runner()->BelongsToCurrentThread()); |
109 | 110 |
110 // Abandon previous timer events by invalidating their weak pointer to us. | 111 // Abandon previous timer events by invalidating their weak pointer to us. |
111 timer_weak_factory_.InvalidateWeakPtrs(); | 112 timer_weak_factory_.InvalidateWeakPtrs(); |
112 if (start) { | 113 if (start) { |
113 ui_task_runner()->PostDelayedTask( | 114 ui_task_runner()->PostDelayedTask( |
114 FROM_HERE, | 115 FROM_HERE, |
115 base::Bind(&It2MeHostUserInterface::OnContinueWindowTimer, | 116 base::Bind(&It2MeHostUserInterface::OnContinueWindowTimer, |
116 timer_weak_factory_.GetWeakPtr()), | 117 timer_weak_factory_.GetWeakPtr()), |
117 base::TimeDelta::FromMilliseconds(kContinueWindowShowTimeoutMs)); | 118 base::TimeDelta::FromMilliseconds(kContinueWindowShowTimeoutMs)); |
118 } | 119 } |
119 } | 120 } |
120 | 121 |
121 } // namespace remoting | 122 } // namespace remoting |
OLD | NEW |