summaryrefslogtreecommitdiffstats
path: root/remoting/host/curtain_mode.h
blob: aeb9b140189d71742466d01ab6883b61fb30d08a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_HOST_CURTAIN_MODE_H_
#define REMOTING_HOST_CURTAIN_MODE_H_

#include <string>

#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"

namespace remoting {

class ChromotingHost;

class CurtainMode {
 public:
  virtual ~CurtainMode() {}

  // Creates a CurtainMode object, with callbacks to be invoked when the
  // switched-out session is switched back to the console, or in case of errors
  // activating the curtain. Typically, remote clients should be disconnected in
  // both cases: for errors, because the privacy guarantee of curtain-mode
  // cannot be honoured; for switch-in, to ensure that only one connection
  // (console or remote) exists to a session.
  static scoped_ptr<CurtainMode> Create(
      const base::Closure& on_session_activate,
      const base::Closure& on_error);

  // Sets/gets whether the curtain mode is required by policy.
  // TODO(rmsousa): Remove this piece of implementation from the interface once
  // we have a good way to do so.
  void set_required(bool required) { required_ = required; }
  bool required() { return required_; }

  // Activate or deactivate curtain mode.
  // If activated is true (meaning a remote client has just logged in), the
  // implementation must immediately activate the curtain, or call on_error if
  // it cannot do so. If a console user logs in while the curtain is activated,
  // the implementation must call on_session_activate (from any thread).
  // If activated is false (meaning the remote client has disconnected), the
  // implementation must not remove the curtain (since at this point we can make
  // no guarantees about whether the user intended to leave the console locked),
  // and must not call on_session_activate when the console user logs in.
  virtual void SetActivated(bool activated) = 0;

 protected:
  CurtainMode() : required_(false) {}

 private:
  bool required_;

  DISALLOW_COPY_AND_ASSIGN(CurtainMode);
};

}  // namespace remoting

#endif