- add sources.
[platform/framework/web/crosswalk.git] / src / remoting / host / host_config.h
1 // Copyright (c) 2012 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_HOST_HOST_CONFIG_H_
6 #define REMOTING_HOST_HOST_CONFIG_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11
12 namespace base {
13 class DictionaryValue;
14 }  // namespace base
15
16 namespace remoting {
17
18 // Following constants define names for configuration parameters.
19
20 // Status of the host, whether it is enabled or disabled.
21 extern const char kHostEnabledConfigPath[];
22 // Google account of the owner of this host.
23 extern const char kHostOwnerConfigPath[];
24 // Login used to authenticate in XMPP network.
25 extern const char kXmppLoginConfigPath[];
26 // Auth token used to authenticate to XMPP network.
27 extern const char kXmppAuthTokenConfigPath[];
28 // OAuth refresh token used to fetch an access token for the XMPP network.
29 extern const char kOAuthRefreshTokenConfigPath[];
30 // Auth service used to authenticate to XMPP network.
31 extern const char kXmppAuthServiceConfigPath[];
32 // Unique identifier of the host used to register the host in directory.
33 // Normally a random UUID.
34 extern const char kHostIdConfigPath[];
35 // Readable host name.
36 extern const char kHostNameConfigPath[];
37 // Hash of the host secret used for authentication.
38 extern const char kHostSecretHashConfigPath[];
39 // Private keys used for host authentication.
40 extern const char kPrivateKeyConfigPath[];
41 // Whether consent is given for usage stats reporting.
42 extern const char kUsageStatsConsentConfigPath[];
43
44 // HostConfig interace provides read-only access to host configuration.
45 class HostConfig {
46  public:
47   HostConfig() {}
48   virtual ~HostConfig() {}
49
50   virtual bool GetString(const std::string& path,
51                          std::string* out_value) const = 0;
52   virtual bool GetBoolean(const std::string& path, bool* out_value) const = 0;
53
54  private:
55   DISALLOW_COPY_AND_ASSIGN(HostConfig);
56 };
57
58 // MutableHostConfig extends HostConfig for mutability.
59 class MutableHostConfig : public HostConfig {
60  public:
61   MutableHostConfig() {}
62
63   // SetString() updates specified config value. Save() must be called to save
64   // the changes on the disk.
65   virtual void SetString(const std::string& path,
66                          const std::string& in_value) = 0;
67   virtual void SetBoolean(const std::string& path, bool in_value) = 0;
68
69   // Copy configuration from specified |dictionary|. Returns false if the
70   // |dictionary| contains some values that cannot be saved in the config. In
71   // that case, all other values are still copied.
72   virtual bool CopyFrom(const base::DictionaryValue* dictionary) = 0;
73
74   // Saves changes.
75   virtual bool Save() = 0;
76
77   DISALLOW_COPY_AND_ASSIGN(MutableHostConfig);
78 };
79
80 }  // namespace remoting
81
82 #endif  // REMOTING_HOST_HOST_CONFIG_H_