diff options
author | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-19 13:24:08 +0000 |
---|---|---|
committer | pneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-19 13:24:08 +0000 |
commit | bb4b5e6e6c6225f4d4a7350b42587a39b50be941 (patch) | |
tree | e93c8bedd12640e303ab6057017611fe65bdcce9 /chromeos | |
parent | b07c118b330e44e0d3716b1412ae37c100b7fdf3 (diff) | |
download | chromium_src-bb4b5e6e6c6225f4d4a7350b42587a39b50be941.zip chromium_src-bb4b5e6e6c6225f4d4a7350b42587a39b50be941.tar.gz chromium_src-bb4b5e6e6c6225f4d4a7350b42587a39b50be941.tar.bz2 |
Add ONC string expansion to NetworkConfigurationUpdaterImpl.
String expansion is currently done in NetworkLibrary::LoadOncNetworks.
That code will be replaced by ManagedNetworkConfigurationHandler, which resides in chromeos/ and cannot access User.
Thus, with this commit, strings are expanded before pushing ONC to ManagedNetworkConfigurationHandler, namely in NetworkConfigurationUpdaterImpl.
BUG=261152
TBR=joaodasilva@chromium.org
Review URL: https://codereview.chromium.org/19564002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/network/onc/onc_utils.cc | 12 | ||||
-rw-r--r-- | chromeos/network/onc/onc_utils.h | 9 | ||||
-rw-r--r-- | chromeos/network/onc/onc_utils_unittest.cc | 2 |
3 files changed, 21 insertions, 2 deletions
diff --git a/chromeos/network/onc/onc_utils.cc b/chromeos/network/onc/onc_utils.cc index ba31b04..7ae5aa8 100644 --- a/chromeos/network/onc/onc_utils.cc +++ b/chromeos/network/onc/onc_utils.cc @@ -224,6 +224,18 @@ void ExpandStringsInOncObject( } } +void ExpandStringsInNetworks(const StringSubstitution& substitution, + base::ListValue* network_configs) { + for (base::ListValue::iterator it = network_configs->begin(); + it != network_configs->end(); ++it) { + base::DictionaryValue* network = NULL; + (*it)->GetAsDictionary(&network); + DCHECK(network); + ExpandStringsInOncObject( + kNetworkConfigurationSignature, substitution, network); + } +} + namespace { class OncMaskValues : public Mapper { diff --git a/chromeos/network/onc/onc_utils.h b/chromeos/network/onc/onc_utils.h index 64f888a..2dc8783 100644 --- a/chromeos/network/onc/onc_utils.h +++ b/chromeos/network/onc/onc_utils.h @@ -60,8 +60,9 @@ class CHROMEOS_EXPORT StringSubstitution { // Returns the replacement string for |placeholder| in // |substitute|. Currently, substitutes::kLoginIDField and // substitutes::kEmailField are supported. - virtual bool GetSubstitute(std::string placeholder, + virtual bool GetSubstitute(const std::string& placeholder, std::string* substitute) const = 0; + private: DISALLOW_COPY_AND_ASSIGN(StringSubstitution); }; @@ -75,6 +76,12 @@ CHROMEOS_EXPORT void ExpandStringsInOncObject( const StringSubstitution& substitution, base::DictionaryValue* onc_object); +// Replaces expandable fields in the networks of |network_configs|, which must +// be a list of ONC NetworkConfigurations. See ExpandStringsInOncObject above. +CHROMEOS_EXPORT void ExpandStringsInNetworks( + const StringSubstitution& substitution, + base::ListValue* network_configs); + // Creates a copy of |onc_object| with all values of sensitive fields replaced // by |mask|. To find sensitive fields, signature and field name are checked // with the function FieldIsCredential(). diff --git a/chromeos/network/onc/onc_utils_unittest.cc b/chromeos/network/onc/onc_utils_unittest.cc index 4d63267..dc6d4d4 100644 --- a/chromeos/network/onc/onc_utils_unittest.cc +++ b/chromeos/network/onc/onc_utils_unittest.cc @@ -58,7 +58,7 @@ const char* kLoginEmail = "hans@my.domain.com"; class StringSubstitutionStub : public StringSubstitution { public: StringSubstitutionStub() {} - virtual bool GetSubstitute(std::string placeholder, + virtual bool GetSubstitute(const std::string& placeholder, std::string* substitute) const OVERRIDE { if (placeholder == substitutes::kLoginIDField) *substitute = kLoginId; |