blob: 05df334bd5aab5188aa30a01a903a82b07f099c3 [file] [log] [blame]
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/win/registry.h"
#include "remoting/protocol/pairing_registry.h"
namespace base {
class ListValue;
} // namespace base
namespace remoting {
#if defined(OFFICIAL_BUILD)
const wchar_t kPairingRegistryKeyName[] =
L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
const wchar_t kPairingRegistryKeyName[] =
const wchar_t kPairingRegistryClientsKeyName[] = L"clients";
const wchar_t kPairingRegistrySecretsKeyName[] = L"secrets";
// Stores client pairing information in Windows registry. Two separate registry
// keys are used:
// - |privileged| - contains the shared secrets of all pairings. This key must
// be protected by a strong ACL denying access to unprivileged
// code.
// - |unprivileged| - contains the rest of pairing state.
// Creator of this object is responsible for passing the registry key handles
// with appropriate access. |privileged| may be nullptr if read-only access is
// sufficient. Shared secrets will not be returned in such a case.
class PairingRegistryDelegateWin
: public protocol::PairingRegistry::Delegate {
~PairingRegistryDelegateWin() override;
// Passes the root keys to be used to access the pairing registry store.
// |privileged| is optional and may be nullptr. The caller retains ownership
// of the passed handles.
bool SetRootKeys(HKEY privileged, HKEY unprivileged);
// PairingRegistry::Delegate interface
std::unique_ptr<base::ListValue> LoadAll() override;
bool DeleteAll() override;
protocol::PairingRegistry::Pairing Load(
const std::string& client_id) override;
bool Save(const protocol::PairingRegistry::Pairing& pairing) override;
bool Delete(const std::string& client_id) override;
base::win::RegKey privileged_;
base::win::RegKey unprivileged_;
} // namespace remoting