OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/browser/chromeos/cros/onc_network_parser.h" | 5 #include "chrome/browser/chromeos/cros/onc_network_parser.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_value_serializer.h" | 8 #include "base/json/json_value_serializer.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 } // namespace | 66 } // namespace |
67 | 67 |
68 // -------------------- OncNetworkParser -------------------- | 68 // -------------------- OncNetworkParser -------------------- |
69 | 69 |
70 OncNetworkParser::OncNetworkParser(const std::string& onc_blob) | 70 OncNetworkParser::OncNetworkParser(const std::string& onc_blob) |
71 : NetworkParser(get_onc_mapper()), | 71 : NetworkParser(get_onc_mapper()), |
72 network_configs_(NULL), | 72 network_configs_(NULL), |
73 certificates_(NULL) { | 73 certificates_(NULL) { |
74 JSONStringValueSerializer deserializer(onc_blob); | 74 JSONStringValueSerializer deserializer(onc_blob); |
75 deserializer.set_allow_trailing_comma(true); | 75 deserializer.set_allow_trailing_comma(true); |
76 std::string error_msg; | 76 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &parse_error_)); |
77 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error_msg)); | |
78 | 77 |
79 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { | 78 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { |
80 LOG(WARNING) << "OncNetworkParser received bad ONC file: " << error_msg; | 79 LOG(WARNING) << "OncNetworkParser received bad ONC file: " << parse_error_; |
81 } else { | 80 } else { |
82 root_dict_.reset(static_cast<DictionaryValue*>(root.release())); | 81 root_dict_.reset(static_cast<DictionaryValue*>(root.release())); |
83 // At least one of NetworkConfigurations or Certificates is required. | 82 // At least one of NetworkConfigurations or Certificates is required. |
84 if (!root_dict_->GetList("NetworkConfigurations", &network_configs_) && | 83 if (!root_dict_->GetList("NetworkConfigurations", &network_configs_) && |
85 !root_dict_->GetList("Certificates", &certificates_)) { | 84 !root_dict_->GetList("Certificates", &certificates_)) { |
86 LOG(WARNING) << "ONC file has no NetworkConfigurations or Certificates."; | 85 LOG(WARNING) << "ONC file has no NetworkConfigurations or Certificates."; |
87 } | 86 } |
88 } | 87 } |
89 } | 88 } |
90 | 89 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 static EnumMapper<ProviderType>::Pair table[] = { | 633 static EnumMapper<ProviderType>::Pair table[] = { |
635 { flimflam::kProviderL2tpIpsec, PROVIDER_TYPE_L2TP_IPSEC_PSK }, | 634 { flimflam::kProviderL2tpIpsec, PROVIDER_TYPE_L2TP_IPSEC_PSK }, |
636 { flimflam::kProviderOpenVpn, PROVIDER_TYPE_OPEN_VPN }, | 635 { flimflam::kProviderOpenVpn, PROVIDER_TYPE_OPEN_VPN }, |
637 }; | 636 }; |
638 static EnumMapper<ProviderType> parser( | 637 static EnumMapper<ProviderType> parser( |
639 table, arraysize(table), PROVIDER_TYPE_MAX); | 638 table, arraysize(table), PROVIDER_TYPE_MAX); |
640 return parser.Get(type); | 639 return parser.Get(type); |
641 } | 640 } |
642 | 641 |
643 } // namespace chromeos | 642 } // namespace chromeos |
OLD | NEW |