Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / remoting / host / pairing_registry_delegate_win.h
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
5 #ifndef REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_
6 #define REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_
7
8 #include <string>
9
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"
15
16 namespace base {
17 class ListValue;
18 }  // namespace base
19
20 namespace remoting {
21
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
29
30 const wchar_t kPairingRegistryClientsKeyName[] = L"secrets";
31 const wchar_t kPairingRegistrySecretsKeyName[] = L"clients";
32
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.
39 //
40 // Creator of this object is responsible for passing the registry key handles
41 // with appropriate access. |privileged| may be NULL 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   virtual ~PairingRegistryDelegateWin();
48
49   // Passes the root keys to be used to access the pairing registry store.
50   // |privileged| is optional and may be NULL. The caller retains ownership of
51   // the passed handles.
52   bool SetRootKeys(HKEY privileged, HKEY unprivileged);
53
54   // PairingRegistry::Delegate interface
55   virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
56   virtual bool DeleteAll() OVERRIDE;
57   virtual protocol::PairingRegistry::Pairing Load(
58       const std::string& client_id) OVERRIDE;
59   virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
60   virtual bool Delete(const std::string& client_id) OVERRIDE;
61
62  private:
63   base::win::RegKey privileged_;
64   base::win::RegKey unprivileged_;
65
66   DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateWin);
67 };
68
69 }  // namespace remoting
70
71 #endif  // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_