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 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_HOST_WIN_ELEVATED_CONTROLLER_H_ 6 #define REMOTING_HOST_WIN_ELEVATED_CONTROLLER_H_ 7 8 #include <atlbase.h> 9 #include <atlcom.h> 10 #include <atlctl.h> 11 12 #include "remoting/base/scoped_sc_handle_win.h" 13 14 // chromoting_lib.h contains MIDL-generated declarations. 15 #include "remoting/host/chromoting_lib.h" 16 17 namespace remoting { 18 19 class __declspec(uuid(DAEMON_CONTROLLER_CLSID)) ElevatedController 20 : public ATL::CComObjectRootEx<ATL::CComSingleThreadModel>, 21 public ATL::CComCoClass<ElevatedController, 22 &__uuidof(ElevatedController)>, 23 public ATL::IDispatchImpl<IDaemonControl2, &IID_IDaemonControl2, 24 &LIBID_ChromotingLib, 1, 0> { 25 public: 26 // Declare a class factory which must not lock the ATL module. This is the 27 // same as DECLARE_CLASSFACTORY() with the exception that 28 // ATL::CComObjectNoLock is used unconditionally. 29 // 30 // By default ATL generates locking class factories (by wrapping them in 31 // ATL::CComObjectCached) for classes hosted in a DLL. This class is compiled 32 // into a DLL but it is registered as an out-of-process class, so its class 33 // factory should not use locking. 34 typedef ATL::CComCreator<ATL::CComObjectNoLock<ATL::CComClassFactory> > 35 _ClassFactoryCreatorClass; 36 37 ElevatedController(); 38 39 HRESULT FinalConstruct(); 40 void FinalRelease(); 41 42 // IDaemonControl implementation. 43 STDMETHOD(GetConfig)(BSTR* config_out); 44 STDMETHOD(GetVersion)(BSTR* version_out); 45 STDMETHOD(SetConfig)(BSTR config); 46 STDMETHOD(SetOwnerWindow)(LONG_PTR owner_window); 47 STDMETHOD(StartDaemon)(); 48 STDMETHOD(StopDaemon)(); 49 STDMETHOD(UpdateConfig)(BSTR config); 50 51 // IDaemonControl2 implementation. 52 STDMETHOD(GetUsageStatsConsent)(BOOL* allowed, BOOL* set_by_policy); 53 STDMETHOD(SetUsageStatsConsent)(BOOL allowed); 54 55 DECLARE_NO_REGISTRY() 56 57 private: 58 HRESULT OpenService(ScopedScHandle* service_out); 59 60 BEGIN_COM_MAP(ElevatedController) 61 COM_INTERFACE_ENTRY(IDaemonControl) 62 COM_INTERFACE_ENTRY(IDaemonControl2) 63 COM_INTERFACE_ENTRY(IDispatch) 64 END_COM_MAP() 65 66 // Handle of the owner window (if any) for any UI to be shown. 67 HWND owner_window_; 68 69 DECLARE_PROTECT_FINAL_CONSTRUCT() 70 }; 71 72 } // namespace remoting 73 74 #endif // REMOTING_HOST_WIN_ELEVATED_CONTROLLER_H_ 75