Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(702)

Side by Side Diff: chromeos/network/onc/onc_utils.h

Issue 11664005: Extending the translation from ONC to Shill. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/network/onc/onc_translator_unittest.cc ('k') | chromeos/network/onc/onc_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ 5 #ifndef CHROMEOS_NETWORK_ONC_ONC_UTILS_H_
6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ 6 #define CHROMEOS_NETWORK_ONC_ONC_UTILS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "chromeos/chromeos_export.h" 12 #include "chromeos/chromeos_export.h"
12 #include "chromeos/network/onc/onc_constants.h" 13 #include "chromeos/network/onc/onc_constants.h"
14 #include "chromeos/network/onc/onc_signature.h"
13 15
14 namespace base { 16 namespace base {
15 class DictionaryValue; 17 class DictionaryValue;
16 } 18 }
17 19
18 namespace chromeos { 20 namespace chromeos {
19 namespace onc { 21 namespace onc {
20 22
21 // A valid but empty (no networks and no certificates) and unencrypted 23 // A valid but empty (no networks and no certificates) and unencrypted
22 // configuration. 24 // configuration.
23 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[]; 25 CHROMEOS_EXPORT extern const char kEmptyUnencryptedConfiguration[];
24 26
25 // Parses |json| according to the JSON format. If |json| is a JSON formatted 27 // Parses |json| according to the JSON format. If |json| is a JSON formatted
26 // dictionary, the function returns the dictionary as a DictionaryValue. 28 // dictionary, the function returns the dictionary as a DictionaryValue.
27 // Otherwise returns NULL. 29 // Otherwise returns NULL.
28 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( 30 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson(
29 const std::string& json); 31 const std::string& json);
30 32
31 // Decrypt the given EncryptedConfiguration |onc| (see the ONC specification) 33 // Decrypts the given EncryptedConfiguration |onc| (see the ONC specification)
32 // using |passphrase|. The resulting UnencryptedConfiguration is returned. If an 34 // using |passphrase|. The resulting UnencryptedConfiguration is returned. If an
33 // error occurs, returns NULL. 35 // error occurs, returns NULL.
34 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> Decrypt( 36 CHROMEOS_EXPORT scoped_ptr<base::DictionaryValue> Decrypt(
35 const std::string& passphrase, 37 const std::string& passphrase,
36 const base::DictionaryValue& onc); 38 const base::DictionaryValue& onc);
37 39
38 // For logging only: strings not user facing. 40 // For logging only: strings not user facing.
39 CHROMEOS_EXPORT std::string GetSourceAsString(ONCSource source); 41 CHROMEOS_EXPORT std::string GetSourceAsString(ONCSource source);
40 42
41 } // chromeos 43 // Used for string expansion with function ExpandStringInOncObject(...).
42 } // onc 44 class CHROMEOS_EXPORT StringSubstitution {
45 public:
46 StringSubstitution() {}
47 virtual ~StringSubstitution() {}
48
49 // Returns the replacement string for |placeholder| in
50 // |substitute|. Currently, onc::substitutes::kLoginIDField and
51 // onc::substitutes::kEmailField are supported.
52 virtual bool GetSubstitute(std::string placeholder,
53 std::string* substitute) const = 0;
54 private:
55 DISALLOW_COPY_AND_ASSIGN(StringSubstitution);
56 };
57
58 // Replaces all expandable fields that are mentioned in the ONC
59 // specification. The object of |onc_object| is modified in place. Currently
60 // onc::substitutes::kLoginIDField and onc::substitutes::kEmailField are
61 // expanded. The replacement strings are obtained from |substitution|.
62 CHROMEOS_EXPORT void ExpandStringsInOncObject(
63 const OncValueSignature& signature,
64 const StringSubstitution& substitution,
65 base::DictionaryValue* onc_object);
66
67 } // namespace onc
68 } // namespace chromeos
43 69
44 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_ 70 #endif // CHROMEOS_NETWORK_ONC_ONC_UTILS_H_
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_translator_unittest.cc ('k') | chromeos/network/onc/onc_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698