onc_normalizer.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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 CHROMEOS_NETWORK_ONC_ONC_NORMALIZER_H_ 6#define CHROMEOS_NETWORK_ONC_ONC_NORMALIZER_H_ 7 8#include "base/memory/scoped_ptr.h" 9#include "chromeos/chromeos_export.h" 10#include "chromeos/network/onc/onc_mapper.h" 11 12namespace chromeos { 13namespace onc { 14 15struct OncValueSignature; 16 17class CHROMEOS_EXPORT Normalizer : public Mapper { 18 public: 19 explicit Normalizer(bool remove_recommended_fields); 20 virtual ~Normalizer(); 21 22 // Removes all fields that are ignored/irrelevant because of the value of 23 // other fields. E.g. the "WiFi" field is irrelevant if the configurations 24 // type is "Ethernet". If |remove_recommended_fields| is true, kRecommended 25 // arrays are removed (the array itself and not the field names listed 26 // there). |object_signature| must point to one of the signatures in 27 // |onc_signature.h|. 28 scoped_ptr<base::DictionaryValue> NormalizeObject( 29 const OncValueSignature* object_signature, 30 const base::DictionaryValue& onc_object); 31 32 private: 33 // Dispatch to the right normalization function according to |signature|. 34 virtual scoped_ptr<base::DictionaryValue> MapObject( 35 const OncValueSignature& signature, 36 const base::DictionaryValue& onc_object, 37 bool* error) OVERRIDE; 38 39 void NormalizeCertificate(base::DictionaryValue* cert); 40 void NormalizeEAP(base::DictionaryValue* eap); 41 void NormalizeEthernet(base::DictionaryValue* ethernet); 42 void NormalizeIPsec(base::DictionaryValue* ipsec); 43 void NormalizeNetworkConfiguration(base::DictionaryValue* network); 44 void NormalizeOpenVPN(base::DictionaryValue* openvpn); 45 void NormalizeProxySettings(base::DictionaryValue* proxy); 46 void NormalizeVPN(base::DictionaryValue* vpn); 47 void NormalizeWiFi(base::DictionaryValue* wifi); 48 49 const bool remove_recommended_fields_; 50 51 DISALLOW_COPY_AND_ASSIGN(Normalizer); 52}; 53 54} // namespace onc 55} // namespace chromeos 56 57#endif // CHROMEOS_NETWORK_ONC_ONC_NORMALIZER_H_ 58