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