Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / host / pairing_registry_delegate_win.h
blobf7cf832b335dbf6388745a83d50d6915e74f6aeb
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.
5 #ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_
6 #define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/win/registry.h"
14 #include "remoting/protocol/pairing_registry.h"
16 namespace base {
17 class ListValue;
18 } // namespace base
20 namespace remoting {
22 #if defined(OFFICIAL_BUILD)
23 const wchar_t kPairingRegistryKeyName[] =
24 L"SOFTWARE\\Google\\Chrome Remote Desktop\\paired-clients";
25 #else
26 const wchar_t kPairingRegistryKeyName[] =
27 L"SOFTWARE\\Chromoting\\paired-clients";
28 #endif
30 const wchar_t kPairingRegistryClientsKeyName[] = L"clients";
31 const wchar_t kPairingRegistrySecretsKeyName[] = L"secrets";
33 // Stores client pairing information in Windows registry. Two separate registry
34 // keys are used:
35 // - |privileged| - contains the shared secrets of all pairings. This key must
36 // be protected by a strong ACL denying access to unprivileged
37 // code.
38 // - |unprivileged| - contains the rest of pairing state.
40 // Creator of this object is responsible for passing the registry key handles
41 // with appropriate access. |privileged| may be nullptr if read-only access is
42 // sufficient. Shared secrets will not be returned in such a case.
43 class PairingRegistryDelegateWin
44 : public protocol::PairingRegistry::Delegate {
45 public:
46 PairingRegistryDelegateWin();
47 ~PairingRegistryDelegateWin() override;
49 // Passes the root keys to be used to access the pairing registry store.
50 // |privileged| is optional and may be nullptr. The caller retains ownership
51 // of the passed handles.
52 bool SetRootKeys(HKEY privileged, HKEY unprivileged);
54 // PairingRegistry::Delegate interface
55 scoped_ptr<base::ListValue> LoadAll() override;
56 bool DeleteAll() override;
57 protocol::PairingRegistry::Pairing Load(
58 const std::string& client_id) override;
59 bool Save(const protocol::PairingRegistry::Pairing& pairing) override;
60 bool Delete(const std::string& client_id) override;
62 private:
63 base::win::RegKey privileged_;
64 base::win::RegKey unprivileged_;
66 DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateWin);
69 } // namespace remoting
71 #endif // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_