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" | |
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" | 8 #include "remoting/host/setup/daemon_controller.h" |
14 | 9 |
15 namespace remoting { | 10 namespace remoting { |
16 | 11 |
17 class DaemonInstallerWin; | 12 class DaemonInstallerWin; |
18 | 13 |
19 class DaemonControllerDelegateWin : public DaemonController::Delegate { | 14 class DaemonControllerDelegateWin : public DaemonController::Delegate { |
20 public: | 15 public: |
21 DaemonControllerDelegateWin(); | 16 DaemonControllerDelegateWin(); |
22 virtual ~DaemonControllerDelegateWin(); | 17 virtual ~DaemonControllerDelegateWin(); |
23 | 18 |
24 // DaemonController::Delegate interface. | 19 // DaemonController::Delegate interface. |
25 virtual DaemonController::State GetState() override; | 20 virtual DaemonController::State GetState() override; |
26 virtual scoped_ptr<base::DictionaryValue> GetConfig() override; | 21 virtual scoped_ptr<base::DictionaryValue> GetConfig() override; |
27 virtual void SetConfigAndStart( | 22 virtual void SetConfigAndStart( |
28 scoped_ptr<base::DictionaryValue> config, | 23 scoped_ptr<base::DictionaryValue> config, |
29 bool consent, | 24 bool consent, |
30 const DaemonController::CompletionCallback& done) override; | 25 const DaemonController::CompletionCallback& done) override; |
31 virtual void UpdateConfig( | 26 virtual void UpdateConfig( |
32 scoped_ptr<base::DictionaryValue> config, | 27 scoped_ptr<base::DictionaryValue> config, |
33 const DaemonController::CompletionCallback& done) override; | 28 const DaemonController::CompletionCallback& done) override; |
34 virtual void Stop(const DaemonController::CompletionCallback& done) override; | 29 virtual void Stop(const DaemonController::CompletionCallback& done) override; |
35 virtual void SetWindow(void* window_handle) override; | 30 virtual void SetWindow(void* window_handle) override; |
36 virtual std::string GetVersion() override; | 31 virtual std::string GetVersion() override; |
37 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() override; | 32 virtual DaemonController::UsageStatsConsent GetUsageStatsConsent() override; |
38 | 33 |
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 // |control_| and |control2_| hold references to an instance of the daemon | |
52 // controller to prevent a UAC prompt on every operation. | |
53 base::win::ScopedComPtr<IDaemonControl> control_; | |
54 base::win::ScopedComPtr<IDaemonControl2> control2_; | |
55 | |
56 // True if |control_| holds a reference to an elevated instance of the daemon | |
57 // controller. | |
58 bool control_is_elevated_; | |
59 | |
60 // This timer is used to release |control_| after a timeout. | |
61 scoped_ptr<base::OneShotTimer<DaemonControllerDelegateWin> > release_timer_; | |
62 | |
63 // Handle of the plugin window. | |
64 HWND window_handle_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(DaemonControllerDelegateWin); | 34 DISALLOW_COPY_AND_ASSIGN(DaemonControllerDelegateWin); |
67 }; | 35 }; |
68 | 36 |
69 } // namespace remoting | 37 } // namespace remoting |
70 | 38 |
71 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_ | 39 #endif // REMOTING_HOST_SETUP_DAEMON_CONTROLLER_DELEGATE_WIN_H_ |
OLD | NEW |