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

Unified Diff: remoting/host/setup/me2me_native_messaging_host_main.cc

Issue 143303007: Enable pairing registry in me2me native messaging host on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pairing
Patch Set: Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/setup/me2me_native_messaging_host_main.cc
diff --git a/remoting/host/setup/me2me_native_messaging_host_main.cc b/remoting/host/setup/me2me_native_messaging_host_main.cc
index 638b15be44b7756e3c8a12630ca3ca3c98b466d8..ac929b86559e9f776b3457bfc2a59acbc95c7f11 100644
--- a/remoting/host/setup/me2me_native_messaging_host_main.cc
+++ b/remoting/host/setup/me2me_native_messaging_host_main.cc
@@ -14,9 +14,13 @@
#include "remoting/host/setup/me2me_native_messaging_host.h"
#if defined(OS_WIN)
+#include "base/win/registry.h"
#include "base/win/windows_version.h"
+#include "remoting/host/pairing_registry_delegate_win.h"
#endif // defined(OS_WIN)
+using remoting::protocol::PairingRegistry;
+
namespace {
const char kParentWindowSwitchName[] = "parent-window";
@@ -140,14 +144,61 @@ int Me2MeNativeMessagingHostMain() {
net::URLFetcher::SetIgnoreCertificateRequests(true);
- // Create the pairing registry and native messaging host.
- scoped_refptr<protocol::PairingRegistry> pairing_registry =
+ // Create the pairing registry.
+ scoped_refptr<PairingRegistry> pairing_registry;
+
+#if defined(OS_WIN)
+ base::win::RegKey root;
+ LONG result = root.Open(HKEY_LOCAL_MACHINE, kPairingRegistryKeyName,
+ KEY_READ);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName;
+ return kInitializationFailed;
+ }
+
+ base::win::RegKey unprivileged;
+ result = unprivileged.Open(root.Handle(), kPairingRegistrySecretsKeyName,
+ needs_elevation ? KEY_READ : KEY_READ | KEY_WRITE);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistrySecretsKeyName
+ << "\\" << kPairingRegistrySecretsKeyName;
+ return kInitializationFailed;
+ }
+
+ // Only try to open the privileged key if the current process is elevated.
+ base::win::RegKey privileged;
+ if (!needs_elevation) {
+ result = privileged.Open(root.Handle(), kPairingRegistryClientsKeyName,
+ KEY_READ | KEY_WRITE);
+ if (result != ERROR_SUCCESS) {
+ SetLastError(result);
+ PLOG(ERROR) << "Failed to open HKLM\\" << kPairingRegistryKeyName << "\\"
+ << kPairingRegistryClientsKeyName;
+ return kInitializationFailed;
+ }
+ }
+
+ // Initialize the pairing registry delegate and set the root keys.
+ scoped_ptr<PairingRegistryDelegateWin> delegate(
+ new PairingRegistryDelegateWin());
+ if (!delegate->SetRootKeys(privileged.Take(), unprivileged.Take()))
+ return kInitializationFailed;
+
+ pairing_registry = new PairingRegistry(
+ io_thread.message_loop_proxy(),
+ delegate.PassAs<PairingRegistry::Delegate>());
+#else // defined(OS_WIN)
+ pairing_registry =
CreatePairingRegistry(io_thread.message_loop_proxy());
+#endif // !defined(OS_WIN)
// Set up the native messaging channel.
scoped_ptr<NativeMessagingChannel> channel(
new NativeMessagingChannel(read_file, write_file));
+ // Create the native messaging host.
scoped_ptr<Me2MeNativeMessagingHost> host(
new Me2MeNativeMessagingHost(
needs_elevation,
« no previous file with comments | « remoting/host/setup/me2me_native_messaging_host.cc ('k') | remoting/remoting_host.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698