- add sources.
[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 // Stores client pairing information in Windows registry. Two separate registry
23 // keys are used:
24 //  - |privileged| - contains the shared secrets of all pairings. This key must
25 //                   be protected by a strong ACL denying access to unprivileged
26 //                   code.
27 //  - |unprivileged| - contains the rest of pairing state.
28 //
29 // Creator of this object is responsible for passing the registry key handles
30 // with appropriate access. |privileged| may be NULL if read-only access is
31 // sufficient. Shared secrets will not be returned in such a case.
32 class PairingRegistryDelegateWin
33     : public protocol::PairingRegistry::Delegate {
34  public:
35   PairingRegistryDelegateWin();
36   virtual ~PairingRegistryDelegateWin();
37
38   // Passes the root keys to be used to access the pairing registry store.
39   // |privileged| is optional and may be NULL. The caller retains ownership of
40   // the passed handles.
41   bool SetRootKeys(HKEY privileged, HKEY unprivileged);
42
43   // PairingRegistry::Delegate interface
44   virtual scoped_ptr<base::ListValue> LoadAll() OVERRIDE;
45   virtual bool DeleteAll() OVERRIDE;
46   virtual protocol::PairingRegistry::Pairing Load(
47       const std::string& client_id) OVERRIDE;
48   virtual bool Save(const protocol::PairingRegistry::Pairing& pairing) OVERRIDE;
49   virtual bool Delete(const std::string& client_id) OVERRIDE;
50
51  private:
52   base::win::RegKey privileged_;
53   base::win::RegKey unprivileged_;
54
55   DISALLOW_COPY_AND_ASSIGN(PairingRegistryDelegateWin);
56 };
57
58 }  // namespace remoting
59
60 #endif  // REMOTING_PROTOCOL_PAIRING_REGISTRY_DELEGATE_WIN_H_