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.
5 #ifndef REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_
6 #define REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_
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 #include "remoting/host/setup/daemon_installer_win.h"
18 class DaemonInstallerWin
;
20 class DaemonControllerDelegateWin
: public DaemonController::Delegate
{
22 DaemonControllerDelegateWin();
23 virtual ~DaemonControllerDelegateWin();
25 // DaemonController::Delegate interface.
26 virtual DaemonController::State
GetState() OVERRIDE
;
27 virtual scoped_ptr
<base::DictionaryValue
> GetConfig() OVERRIDE
;
28 virtual void InstallHost(
29 const DaemonController::CompletionCallback
& done
) OVERRIDE
;
30 virtual void SetConfigAndStart(
31 scoped_ptr
<base::DictionaryValue
> config
,
33 const DaemonController::CompletionCallback
& done
) OVERRIDE
;
34 virtual void UpdateConfig(
35 scoped_ptr
<base::DictionaryValue
> config
,
36 const DaemonController::CompletionCallback
& done
) OVERRIDE
;
37 virtual void Stop(const DaemonController::CompletionCallback
& done
) OVERRIDE
;
38 virtual void SetWindow(void* window_handle
) OVERRIDE
;
39 virtual std::string
GetVersion() OVERRIDE
;
40 virtual DaemonController::UsageStatsConsent
GetUsageStatsConsent() OVERRIDE
;
43 // Activates an unprivileged instance of the daemon controller and caches it.
44 HRESULT
ActivateController();
46 // Activates an instance of the daemon controller and caches it. If COM
47 // Elevation is supported (Vista+) the activated instance is elevated,
48 // otherwise it is activated under credentials of the caller.
49 HRESULT
ActivateElevatedController();
51 // Releases the cached instance of the controller.
52 void ReleaseController();
54 // Install the host and then invoke the callback.
55 void DoInstallHost(const DaemonInstallerWin::CompletionCallback
& done
);
57 // Procedes with the daemon configuration if the installation succeeded,
58 // otherwise reports the error.
59 void StartHostWithConfig(
60 scoped_ptr
<base::DictionaryValue
> config
,
62 const DaemonController::CompletionCallback
& done
,
65 // |control_| and |control2_| hold references to an instance of the daemon
66 // controller to prevent a UAC prompt on every operation.
67 base::win::ScopedComPtr
<IDaemonControl
> control_
;
68 base::win::ScopedComPtr
<IDaemonControl2
> control2_
;
70 // True if |control_| holds a reference to an elevated instance of the daemon
72 bool control_is_elevated_
;
74 // This timer is used to release |control_| after a timeout.
75 scoped_ptr
<base::OneShotTimer
<DaemonControllerDelegateWin
> > release_timer_
;
77 // Handle of the plugin window.
80 scoped_ptr
<DaemonInstallerWin
> installer_
;
82 DISALLOW_COPY_AND_ASSIGN(DaemonControllerDelegateWin
);
85 } // namespace remoting
87 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_