• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // Whether to offer VP9 encoding to clients.
44 extern const char kEnableVp9ConfigPath[];
45 
46 // HostConfig interace provides read-only access to host configuration.
47 class HostConfig {
48  public:
HostConfig()49   HostConfig() {}
~HostConfig()50   virtual ~HostConfig() {}
51 
52   virtual bool GetString(const std::string& path,
53                          std::string* out_value) const = 0;
54   virtual bool GetBoolean(const std::string& path, bool* out_value) const = 0;
55 
56  private:
57   DISALLOW_COPY_AND_ASSIGN(HostConfig);
58 };
59 
60 // MutableHostConfig extends HostConfig for mutability.
61 class MutableHostConfig : public HostConfig {
62  public:
MutableHostConfig()63   MutableHostConfig() {}
64 
65   // SetString() updates specified config value. Save() must be called to save
66   // the changes on the disk.
67   virtual void SetString(const std::string& path,
68                          const std::string& in_value) = 0;
69   virtual void SetBoolean(const std::string& path, bool in_value) = 0;
70 
71   // Copy configuration from specified |dictionary|. Returns false if the
72   // |dictionary| contains some values that cannot be saved in the config. In
73   // that case, all other values are still copied.
74   virtual bool CopyFrom(const base::DictionaryValue* dictionary) = 0;
75 
76   // Saves changes.
77   virtual bool Save() = 0;
78 
79   DISALLOW_COPY_AND_ASSIGN(MutableHostConfig);
80 };
81 
82 }  // namespace remoting
83 
84 #endif  // REMOTING_HOST_HOST_CONFIG_H_
85