summaryrefslogtreecommitdiffstats
path: root/remoting/host/resizing_host_observer.h
blob: 85c23f1971d90ec278f52679faa1afb2ba08d47c (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
// 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_RESIZING_HOST_OBSERVER_H_
#define REMOTING_HOST_RESIZING_HOST_OBSERVER_H_

#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "remoting/host/host_status_observer.h"
#include "third_party/skia/include/core/SkSize.h"

namespace remoting {

class DesktopResizer;
class HostStatusMonitor;

// Use the specified DesktopResizer to match host desktop size to the client
// view size as closely as is possible. When the connection closes, restore
// the original desktop size.
class ResizingHostObserver : public HostStatusObserver {
 public:
  ResizingHostObserver(DesktopResizer* desktop_resizer,
                       base::WeakPtr<HostStatusMonitor> monitor);
  virtual ~ResizingHostObserver();

  // HostStatusObserver interface
  virtual void OnClientAuthenticated(const std::string& jid) OVERRIDE;
  virtual void OnClientDisconnected(const std::string& jid) OVERRIDE;
  virtual void OnClientResolutionChanged(const std::string& jid,
                                         const SkISize& size,
                                         const SkIPoint& dpi) OVERRIDE;

 private:
  DesktopResizer* const desktop_resizer_;
  base::WeakPtr<HostStatusMonitor> monitor_;
  SkISize original_size_;
  std::string client_jid_;

  DISALLOW_COPY_AND_ASSIGN(ResizingHostObserver);
};

}  // namespace remoting

#endif  // REMOTING_HOST_RESIZING_HOST_OBSERVER_H_