pairing_registry_delegate_win.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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
  3. // found in the LICENSE file.
  4. #ifndef REMOTING_HOST_PAIRING_REGISTRY_DELEGATE_WIN_H_
  5. #define REMOTING_HOST_PAIRING_REGISTRY_DELEGATE_WIN_H_
  6. #include <string>
  7. #include "base/compiler_specific.h"
  8. #include "base/win/registry.h"
  9. #include "remoting/protocol/pairing_registry.h"
  10. namespace remoting {
  11. #if defined(OFFICIAL_BUILD)
  12. const wchar_t kPairingRegistryKeyName[] =
  13. L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
  14. #else
  15. const wchar_t kPairingRegistryKeyName[] =
  16. L"SOFTWARE\\Chromoting\\paired-clients";
  17. #endif
  18. const wchar_t kPairingRegistryClientsKeyName[] = L"clients";
  19. const wchar_t kPairingRegistrySecretsKeyName[] = L"secrets";
  20. // Stores client pairing information in Windows registry. Two separate registry
  21. // keys are used:
  22. // - |privileged| - contains the shared secrets of all pairings. This key must
  23. // be protected by a strong ACL denying access to unprivileged
  24. // code.
  25. // - |unprivileged| - contains the rest of pairing state.
  26. //
  27. // Creator of this object is responsible for passing the registry key handles
  28. // with appropriate access. |privileged| may be nullptr if read-only access is
  29. // sufficient. Shared secrets will not be returned in such a case.
  30. class PairingRegistryDelegateWin
  31. : public protocol::PairingRegistry::Delegate {
  32. public:
  33. PairingRegistryDelegateWin();
  34. PairingRegistryDelegateWin(const PairingRegistryDelegateWin&) = delete;
  35. PairingRegistryDelegateWin& operator=(const PairingRegistryDelegateWin&) =
  36. delete;
  37. ~PairingRegistryDelegateWin() override;
  38. // Passes the root keys to be used to access the pairing registry store.
  39. // |privileged| is optional and may be nullptr. The caller retains ownership
  40. // of the passed handles.
  41. bool SetRootKeys(HKEY privileged, HKEY unprivileged);
  42. // PairingRegistry::Delegate interface
  43. base::Value::List LoadAll() override;
  44. bool DeleteAll() override;
  45. protocol::PairingRegistry::Pairing Load(
  46. const std::string& client_id) override;
  47. bool Save(const protocol::PairingRegistry::Pairing& pairing) override;
  48. bool Delete(const std::string& client_id) override;
  49. private:
  50. base::win::RegKey privileged_;
  51. base::win::RegKey unprivileged_;
  52. };
  53. } // namespace remoting
  54. #endif // REMOTING_HOST_PAIRING_REGISTRY_DELEGATE_WIN_H_