• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 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 #ifndef REMOTING_HOST_WIN_RDP_DESKTOP_SESSION_H_
6 #define REMOTING_HOST_WIN_RDP_DESKTOP_SESSION_H_
7 
8 #include <atlbase.h>
9 #include <atlcom.h>
10 #include <atlctl.h>
11 
12 #include "base/memory/scoped_ptr.h"
13 #include "base/win/scoped_comptr.h"
14 // chromoting_lib.h contains MIDL-generated declarations.
15 #include "remoting/host/chromoting_lib.h"
16 #include "remoting/host/win/rdp_client.h"
17 
18 namespace remoting {
19 
20 // Implements IRdpDesktopSession interface providing a way to host RdpClient
21 // objects in a COM component.
22 class __declspec(uuid(RDP_DESKTOP_SESSION_CLSID)) RdpDesktopSession
23     : public ATL::CComObjectRootEx<ATL::CComSingleThreadModel>,
24       public ATL::CComCoClass<RdpDesktopSession, &__uuidof(RdpDesktopSession)>,
25       public IRdpDesktopSession,
26       public RdpClient::EventHandler {
27  public:
28   // Declare a class factory which must not lock the ATL module. This is the
29   // same as DECLARE_CLASSFACTORY() with the exception that
30   // ATL::CComObjectNoLock is used unconditionally.
31   //
32   // By default ATL generates locking class factories (by wrapping them in
33   // ATL::CComObjectCached) for classes hosted in a DLL. This class is compiled
34   // into a DLL but it is registered as an out-of-process class, so its class
35   // factory should not use locking.
36   typedef ATL::CComCreator<ATL::CComObjectNoLock<ATL::CComClassFactory> >
37       _ClassFactoryCreatorClass;
38 
39   RdpDesktopSession();
40 
41   // IRdpDesktopSession implementation.
42   STDMETHOD(Connect)(long width, long height, BSTR terminal_id,
43                      IRdpDesktopSessionEventHandler* event_handler);
44   STDMETHOD(Disconnect)();
45   STDMETHOD(ChangeResolution)(long width, long height);
46   STDMETHOD(InjectSas)();
47 
48   DECLARE_NO_REGISTRY()
49 
50  private:
51   // RdpClient::EventHandler interface.
52   virtual void OnRdpConnected() OVERRIDE;
53   virtual void OnRdpClosed() OVERRIDE;
54 
55   BEGIN_COM_MAP(RdpDesktopSession)
56     COM_INTERFACE_ENTRY(IRdpDesktopSession)
57     COM_INTERFACE_ENTRY(IUnknown)
58   END_COM_MAP()
59 
60   // Implements loading and instantiation of the RDP ActiveX client.
61   scoped_ptr<RdpClient> client_;
62 
63   // Holds a reference to the caller's EventHandler, through which notifications
64   // are dispatched. Released in Disconnect(), to prevent further notifications.
65   base::win::ScopedComPtr<IRdpDesktopSessionEventHandler> event_handler_;
66 
67   DECLARE_PROTECT_FINAL_CONSTRUCT()
68 };
69 
70 } // namespace remoting
71 
72 #endif  // REMOTING_HOST_WIN_RDP_DESKTOP_SESSION_H_
73