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

Side by Side Diff: chrome/browser/chromeos/cros/onc_network_parser.cc

Issue 8480003: Surface error messages from ONC parsing in about:policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Only compile unit test for chromium os. Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/json/json_value_serializer.h" 9 #include "base/json/json_value_serializer.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } // namespace 132 } // namespace
133 133
134 // -------------------- OncNetworkParser -------------------- 134 // -------------------- OncNetworkParser --------------------
135 135
136 OncNetworkParser::OncNetworkParser(const std::string& onc_blob) 136 OncNetworkParser::OncNetworkParser(const std::string& onc_blob)
137 : NetworkParser(get_onc_mapper()), 137 : NetworkParser(get_onc_mapper()),
138 network_configs_(NULL), 138 network_configs_(NULL),
139 certificates_(NULL) { 139 certificates_(NULL) {
140 JSONStringValueSerializer deserializer(onc_blob); 140 JSONStringValueSerializer deserializer(onc_blob);
141 deserializer.set_allow_trailing_comma(true); 141 deserializer.set_allow_trailing_comma(true);
142 std::string error_msg; 142 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &parse_error_));
143 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error_msg));
144 143
145 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) { 144 if (!root.get() || root->GetType() != base::Value::TYPE_DICTIONARY) {
146 LOG(WARNING) << "OncNetworkParser received bad ONC file: " << error_msg; 145 LOG(WARNING) << "OncNetworkParser received bad ONC file: " << parse_error_;
147 } else { 146 } else {
148 root_dict_.reset(static_cast<DictionaryValue*>(root.release())); 147 root_dict_.reset(static_cast<DictionaryValue*>(root.release()));
149 // At least one of NetworkConfigurations or Certificates is required. 148 // At least one of NetworkConfigurations or Certificates is required.
150 if (!root_dict_->GetList("NetworkConfigurations", &network_configs_) && 149 if (!root_dict_->GetList("NetworkConfigurations", &network_configs_) &&
151 !root_dict_->GetList("Certificates", &certificates_)) { 150 !root_dict_->GetList("Certificates", &certificates_)) {
152 LOG(WARNING) << "ONC file has no NetworkConfigurations or Certificates."; 151 LOG(WARNING) << "ONC file has no NetworkConfigurations or Certificates.";
153 } 152 }
154 } 153 }
155 } 154 }
156 155
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 static EnumMapper<ProviderType>::Pair table[] = { 729 static EnumMapper<ProviderType>::Pair table[] = {
731 { flimflam::kProviderL2tpIpsec, PROVIDER_TYPE_L2TP_IPSEC_PSK }, 730 { flimflam::kProviderL2tpIpsec, PROVIDER_TYPE_L2TP_IPSEC_PSK },
732 { flimflam::kProviderOpenVpn, PROVIDER_TYPE_OPEN_VPN }, 731 { flimflam::kProviderOpenVpn, PROVIDER_TYPE_OPEN_VPN },
733 }; 732 };
734 static EnumMapper<ProviderType> parser( 733 static EnumMapper<ProviderType> parser(
735 table, arraysize(table), PROVIDER_TYPE_MAX); 734 table, arraysize(table), PROVIDER_TYPE_MAX);
736 return parser.Get(type); 735 return parser.Get(type);
737 } 736 }
738 737
739 } // namespace chromeos 738 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698