Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: remoting/host/win/elevated_native_messaging_host.h

Issue 2149983003: Refactoring Elevated Host Communication Channel into its own class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@process_helper
Patch Set: Merging upstream changes. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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_NATIVE_MESSAGING_HOST_H_
6 #define REMOTING_HOST_WIN_ELEVATED_NATIVE_MESSAGING_HOST_H_
7
8 #include <cstdint>
9 #include <memory>
10
11 #include "base/files/file_path.h"
12 #include "base/macros.h"
13 #include "base/threading/thread_checker.h"
14 #include "base/time/time.h"
15 #include "base/timer/timer.h"
16 #include "extensions/browser/api/messaging/native_message_host.h"
17 #include "extensions/browser/api/messaging/native_messaging_channel.h"
18
19 namespace base {
20 class Value;
21 } // namespace base
22
23 namespace remoting {
24
25 // Helper class which manages the creation and lifetime of an elevated native
26 // messaging host process.
27 class ElevatedNativeMessagingHost
28 : public extensions::NativeMessagingChannel::EventHandler {
29 public:
30 ElevatedNativeMessagingHost(const base::FilePath& binary_path,
31 intptr_t parent_window_handle,
32 bool elevate_process,
33 base::TimeDelta host_timeout,
34 extensions::NativeMessageHost::Client* client);
35 ~ElevatedNativeMessagingHost() override;
36
37 // extensions::NativeMessagingChannel::EventHandle implementation.
38 void OnMessage(std::unique_ptr<base::Value> message) override;
39 void OnDisconnect() override;
40
41 // Create and connect to an elevated host process if necessary.
42 // |elevated_channel_| will contain the native messaging channel to the
43 // elevated host if the function succeeds.
44 bool EnsureElevatedHostCreated();
45
46 // Send |message| to the elevated host.
47 void SendMessage(std::unique_ptr<base::Value> message);
48
49 private:
50 // Disconnect and shut down the elevated host.
51 void DisconnectHost();
52
53 // Path to the binary to use for the elevated host process.
54 base::FilePath host_binary_path_;
55
56 // Handle of the parent window.
57 intptr_t parent_window_handle_;
58
59 // Indicates whether the launched process should be elevated when lauinched.
60 // Note: Binaries with uiaccess run at a higher UIPI level than the launching
61 // process so they still need to be launched and controlled by this class but
62 // do not require traditional elevation to function.
63 bool elevate_host_process_;
64
65 // Specifies the amount of time to allow the elevated host to run.
66 base::TimeDelta host_process_timeout_;
67
68 // EventHandler of the parent process.
69 extensions::NativeMessageHost::Client* client_;
70
71 // Native messaging channel used to communicate with the elevated host.
72 std::unique_ptr<extensions::NativeMessagingChannel> elevated_channel_;
73
74 // Timer to control the lifetime of the elevated host.
75 base::OneShotTimer elevated_host_timer_;
76
77 base::ThreadChecker thread_checker_;
78
79 DISALLOW_COPY_AND_ASSIGN(ElevatedNativeMessagingHost);
80 };
81
82 } // namespace remoting
83
84 #endif // REMOTING_HOST_WIN_ELEVATED_NATIVE_MESSAGING_HOST_H_
OLDNEW
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/host/win/elevated_native_messaging_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698