Home | History | Annotate | Download | only in host
      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 // Login used to authenticate in XMPP network.
     23 extern const char kXmppLoginConfigPath[];
     24 // Auth token used to authenticate to XMPP network.
     25 extern const char kXmppAuthTokenConfigPath[];
     26 // OAuth refresh token used to fetch an access token for the XMPP network.
     27 extern const char kOAuthRefreshTokenConfigPath[];
     28 // Auth service used to authenticate to XMPP network.
     29 extern const char kXmppAuthServiceConfigPath[];
     30 // Unique identifier of the host used to register the host in directory.
     31 // Normally a random UUID.
     32 extern const char kHostIdConfigPath[];
     33 // Readable host name.
     34 extern const char kHostNameConfigPath[];
     35 // Hash of the host secret used for authentication.
     36 extern const char kHostSecretHashConfigPath[];
     37 // Private keys used for host authentication.
     38 extern const char kPrivateKeyConfigPath[];
     39 // Whether consent is given for usage stats reporting.
     40 extern const char kUsageStatsConsentConfigPath[];
     41 
     42 // HostConfig interace provides read-only access to host configuration.
     43 class HostConfig {
     44  public:
     45   HostConfig() {}
     46   virtual ~HostConfig() {}
     47 
     48   virtual bool GetString(const std::string& path,
     49                          std::string* out_value) const = 0;
     50   virtual bool GetBoolean(const std::string& path, bool* out_value) const = 0;
     51 
     52  private:
     53   DISALLOW_COPY_AND_ASSIGN(HostConfig);
     54 };
     55 
     56 // MutableHostConfig extends HostConfig for mutability.
     57 class MutableHostConfig : public HostConfig {
     58  public:
     59   MutableHostConfig() {}
     60 
     61   // SetString() updates specified config value. Save() must be called to save
     62   // the changes on the disk.
     63   virtual void SetString(const std::string& path,
     64                          const std::string& in_value) = 0;
     65   virtual void SetBoolean(const std::string& path, bool in_value) = 0;
     66 
     67   // Copy configuration from specified |dictionary|. Returns false if the
     68   // |dictionary| contains some values that cannot be saved in the config. In
     69   // that case, all other values are still copied.
     70   virtual bool CopyFrom(const base::DictionaryValue* dictionary) = 0;
     71 
     72   // Saves changes.
     73   virtual bool Save() = 0;
     74 
     75   DISALLOW_COPY_AND_ASSIGN(MutableHostConfig);
     76 };
     77 
     78 }  // namespace remoting
     79 
     80 #endif  // REMOTING_HOST_HOST_CONFIG_H_
     81