blob: 9871591c9bbe9cd7545493405108f5ff7db6c39f [file] [log] [blame]
[email protected]ac115ce2013-04-24 20:44:381// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "remoting/host/continue_window.h"
6
7#include "base/location.h"
8#include "remoting/host/client_session_control.h"
9
10// Minutes before the local user should confirm that the session should go on.
11const int kSessionExpirationTimeoutMinutes = 10;
12
13// Minutes before the session will be disconnected (from the moment the Continue
14// window has been shown).
15const int kSessionDisconnectTimeoutMinutes = 1;
16
17namespace remoting {
18
19ContinueWindow::~ContinueWindow() {
20}
21
22void ContinueWindow::Start(
23 const base::WeakPtr<ClientSessionControl>& client_session_control) {
24 DCHECK(CalledOnValidThread());
[email protected]1d06fff2013-06-04 00:02:1225 DCHECK(!client_session_control_.get());
26 DCHECK(client_session_control.get());
[email protected]ac115ce2013-04-24 20:44:3827
28 client_session_control_ = client_session_control;
29
30 session_expired_timer_.Start(
31 FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes),
32 this, &ContinueWindow::OnSessionExpired);
33}
34
35void ContinueWindow::ContinueSession() {
36 DCHECK(CalledOnValidThread());
37
38 disconnect_timer_.Stop();
39
[email protected]1d06fff2013-06-04 00:02:1240 if (!client_session_control_.get())
[email protected]ac115ce2013-04-24 20:44:3841 return;
42
43 // Hide the Continue window and resume the session.
44 HideUi();
45 client_session_control_->SetDisableInputs(false);
46
47 session_expired_timer_.Start(
48 FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes),
49 this, &ContinueWindow::OnSessionExpired);
50}
51
52void ContinueWindow::DisconnectSession() {
53 DCHECK(CalledOnValidThread());
54
55 disconnect_timer_.Stop();
[email protected]1d06fff2013-06-04 00:02:1256 if (client_session_control_.get())
sergeyuec77d8542015-11-03 22:31:0057 client_session_control_->DisconnectSession(protocol::MAX_SESSION_LENGTH);
[email protected]ac115ce2013-04-24 20:44:3858}
59
sergeyuec77d8542015-11-03 22:31:0060ContinueWindow::ContinueWindow() {}
[email protected]ac115ce2013-04-24 20:44:3861
62void ContinueWindow::OnSessionExpired() {
63 DCHECK(CalledOnValidThread());
64
[email protected]1d06fff2013-06-04 00:02:1265 if (!client_session_control_.get())
[email protected]ac115ce2013-04-24 20:44:3866 return;
67
68 // Stop the remote input while the Continue window is shown.
69 client_session_control_->SetDisableInputs(true);
70
71 // Show the Continue window and wait for the local user input.
72 ShowUi();
73 disconnect_timer_.Start(
74 FROM_HERE, base::TimeDelta::FromMinutes(kSessionDisconnectTimeoutMinutes),
75 this, &ContinueWindow::DisconnectSession);
76}
77
78} // namespace remoting