1 // 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 #ifndef REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_ 6 #define REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 #include "base/timer/timer.h" 10 #include "base/win/scoped_comptr.h" 11 // chromoting_lib.h contains MIDL-generated declarations. 12 #include "remoting/host/chromoting_lib.h" 13 #include "remoting/host/setup/daemon_controller.h" 14 15 namespace remoting { 16 17 class DaemonInstallerWin; 18 19 class DaemonControllerDelegateWin : public DaemonController::Delegate { 20 public: 21 DaemonControllerDelegateWin(); 22 virtual ~DaemonControllerDelegateWin(); 23 24 // DaemonController::Delegate interface. 25 virtual DaemonController::State GetState() OVERRIDE; 26 virtual scoped_ptr<base::DictionaryValue> GetConfig() OVERRIDE; 27 virtual void SetConfigAndStart( 28 scoped_ptr<base::DictionaryValue> config, 29 bool consent, 30 const DaemonController::CompletionCallback& done) OVERRIDE; 31 virtual void UpdateConfig( 32 scoped_ptr<base::DictionaryValue> config, 33 const DaemonController::CompletionCallback& done) OVERRIDE; 34 virtual void Stop(const DaemonController::CompletionCallback& done) OVERRIDE; 35 virtual void SetWindow(void* window_handle) OVERRIDE; 36 virtual std::string GetVersion() OVERRIDE; 37 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() OVERRIDE; 38 39 private: 40 // Activates an unprivileged instance of the daemon controller and caches it. 41 HRESULT ActivateController(); 42 43 // Activates an instance of the daemon controller and caches it. If COM 44 // Elevation is supported (Vista+) the activated instance is elevated, 45 // otherwise it is activated under credentials of the caller. 46 HRESULT ActivateElevatedController(); 47 48 // Releases the cached instance of the controller. 49 void ReleaseController(); 50 51 // Procedes with the daemon configuration if the installation succeeded, 52 // otherwise reports the error. 53 void OnInstallationComplete( 54 scoped_ptr<base::DictionaryValue> config, 55 bool consent, 56 const DaemonController::CompletionCallback& done, 57 HRESULT hr); 58 59 // |control_| and |control2_| hold references to an instance of the daemon 60 // controller to prevent a UAC prompt on every operation. 61 base::win::ScopedComPtr<IDaemonControl> control_; 62 base::win::ScopedComPtr<IDaemonControl2> control2_; 63 64 // True if |control_| holds a reference to an elevated instance of the daemon 65 // controller. 66 bool control_is_elevated_; 67 68 // This timer is used to release |control_| after a timeout. 69 scoped_ptr<base::OneShotTimer<DaemonControllerDelegateWin> > release_timer_; 70 71 // Handle of the plugin window. 72 HWND window_handle_; 73 74 scoped_ptr<DaemonInstallerWin> installer_; 75 76 DISALLOW_COPY_AND_ASSIGN(DaemonControllerDelegateWin); 77 }; 78 79 } // namespace remoting 80 81 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_ 82