#if defined(OS_WIN)
#include <commctrl.h>
+#include "base/win/registry.h"
#include "base/win/scoped_handle.h"
+#include "remoting/host/pairing_registry_delegate_win.h"
#include "remoting/host/win/session_desktop_environment.h"
#endif // defined(OS_WIN)
#include "ui/gfx/gtk_util.h"
#endif // defined(TOOLKIT_GTK)
+using remoting::protocol::PairingRegistry;
+
+namespace {
+
// This is used for tagging system event logs.
const char kApplicationName[] = "chromoting";
// from stdin.
const char kStdinConfigPath[] = "-";
+} // namespace
+
namespace remoting {
class HostProcess
// HostChangeNotificationListener::Listener overrides.
virtual void OnHostDeleted() OVERRIDE;
+ // Initializes the pairing registry on Windows.
+ void OnInitializePairingRegistry(
+ IPC::PlatformFileForTransit privileged_key,
+ IPC::PlatformFileForTransit unprivileged_key);
+
private:
enum HostState {
// Host process has just been started. Waiting for config and policies to be
bool curtain_required_;
ThirdPartyAuthConfig third_party_auth_config_;
+ scoped_ptr<OAuthTokenGetter> oauth_token_getter_;
scoped_ptr<XmppSignalStrategy> signal_strategy_;
scoped_ptr<SignalingConnector> signaling_connector_;
scoped_ptr<HeartbeatSender> heartbeat_sender_;
int* exit_code_out_;
bool signal_parent_;
+
+ scoped_ptr<PairingRegistry::Delegate> pairing_registry_delegate_;
};
HostProcess::HostProcess(scoped_ptr<ChromotingHostContext> context,
return;
}
- scoped_refptr<protocol::PairingRegistry> pairing_registry = NULL;
+ scoped_refptr<PairingRegistry> pairing_registry = NULL;
if (allow_pairing_) {
- pairing_registry = CreatePairingRegistry(context_->file_task_runner());
+ if (!pairing_registry_delegate_)
+ pairing_registry_delegate_ = CreatePairingRegistryDelegate();
+
+ if (pairing_registry_delegate_) {
+ pairing_registry = new PairingRegistry(context_->file_task_runner(),
+ pairing_registry_delegate_.Pass());
+ }
}
scoped_ptr<protocol::AuthenticatorFactory> factory;
IPC_MESSAGE_HANDLER(ChromotingDaemonMsg_Crash, OnCrash)
IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_Configuration,
OnConfigUpdated)
+ IPC_MESSAGE_HANDLER(ChromotingDaemonNetworkMsg_InitializePairingRegistry,
+ OnInitializePairingRegistry)
IPC_MESSAGE_FORWARD(
ChromotingDaemonNetworkMsg_DesktopAttached,
desktop_session_connector_,
ShutdownHost(kInvalidHostIdExitCode);
}
+void HostProcess::OnInitializePairingRegistry(
+ IPC::PlatformFileForTransit privileged_key,
+ IPC::PlatformFileForTransit unprivileged_key) {
+ DCHECK(!pairing_registry_delegate_);
+
+#if defined(OS_WIN)
+ // Initialize the pairing registry delegate.
+ scoped_ptr<PairingRegistryDelegateWin> delegate(
+ new PairingRegistryDelegateWin());
+ bool result = delegate->SetRootKeys(
+ reinterpret_cast<HKEY>(
+ IPC::PlatformFileForTransitToPlatformFile(privileged_key)),
+ reinterpret_cast<HKEY>(
+ IPC::PlatformFileForTransitToPlatformFile(unprivileged_key)));
+ if (!result)
+ return;
+
+ pairing_registry_delegate_ = delegate.PassAs<PairingRegistry::Delegate>();
+#else // !defined(OS_WIN)
+ NOTREACHED();
+#endif // !defined(OS_WIN)
+}
+
// Applies the host config, returning true if successful.
bool HostProcess::ApplyConfig(scoped_ptr<JsonHostConfig> config) {
DCHECK(context_->network_task_runner()->BelongsToCurrentThread());
signaling_connector_.reset(new SignalingConnector(
signal_strategy_.get(),
- context_->url_request_context_getter(),
dns_blackhole_checker.Pass(),
base::Bind(&HostProcess::OnAuthFailed, this)));
if (!oauth_refresh_token_.empty()) {
- scoped_ptr<SignalingConnector::OAuthCredentials> oauth_credentials(
- new SignalingConnector::OAuthCredentials(
+ scoped_ptr<OAuthTokenGetter::OAuthCredentials> oauth_credentials;
+ oauth_credentials.reset(
+ new OAuthTokenGetter::OAuthCredentials(
xmpp_server_config_.username, oauth_refresh_token_,
use_service_account_));
- signaling_connector_->EnableOAuth(oauth_credentials.Pass());
+
+ oauth_token_getter_.reset(new OAuthTokenGetter(
+ oauth_credentials.Pass(), context_->url_request_context_getter()));
+
+ signaling_connector_->EnableOAuth(oauth_token_getter_.get());
}
NetworkSettings network_settings(
host_status_sender_.reset();
host_change_notification_listener_.reset();
signaling_connector_.reset();
+ oauth_token_getter_.reset();
signal_strategy_.reset();
network_change_notifier_.reset();