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

Unified Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 8883046: Show parse errors in the UI when loading ONC files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/cros/onc_network_parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/cros/network_library.cc
===================================================================
--- chrome/browser/chromeos/cros/network_library.cc (revision 114539)
+++ chrome/browser/chromeos/cros/network_library.cc (working copy)
@@ -1745,7 +1745,8 @@
// virtual SetIPConfig implemented in derived classes.
virtual void SwitchToPreferredNetwork() OVERRIDE;
virtual bool LoadOncNetworks(const std::string& onc_blob,
- const std::string& passcode) OVERRIDE;
+ const std::string& passcode,
+ std::string* error) OVERRIDE;
virtual bool SetActiveNetwork(ConnectionType type,
const std::string& service_path) OVERRIDE;
@@ -2834,14 +2835,23 @@
}
bool NetworkLibraryImplBase::LoadOncNetworks(const std::string& onc_blob,
- const std::string& passcode) {
+ const std::string& passcode,
+ std::string* error) {
// TODO(gspencer): Add support for decrypting onc files. crbug.com/19397
OncNetworkParser parser(onc_blob);
+ if (!parser.parse_error().empty()) {
+ if (error)
+ *error = parser.parse_error();
+ return false;
+ }
+
for (int i = 0; i < parser.GetCertificatesSize(); i++) {
// Insert each of the available certs into the certificate DB.
if (parser.ParseCertificate(i).get() == NULL) {
DLOG(WARNING) << "Cannot parse certificate in ONC file";
+ if (error)
+ *error = parser.parse_error();
return false;
}
}
@@ -2851,6 +2861,8 @@
scoped_ptr<Network> network(parser.ParseNetwork(i));
if (!network.get()) {
DLOG(WARNING) << "Cannot parse network in ONC file";
+ if (error)
+ *error = parser.parse_error();
return false;
}
@@ -2868,8 +2880,15 @@
CallConfigureService(network->unique_id(), &dict);
}
- return (parser.GetNetworkConfigsSize() != 0 ||
- parser.GetCertificatesSize() != 0);
+
+ if (parser.GetNetworkConfigsSize() != 0 ||
+ parser.GetCertificatesSize() != 0) {
+ if (error)
+ *error = l10n_util::GetStringUTF8(
+ IDS_NETWORK_CONFIG_ERROR_NETWORK_IMPORT);
+ return false;
+ }
+ return true;
}
////////////////////////////////////////////////////////////////////////////
@@ -5102,7 +5121,7 @@
" ],"
" \"Certificates\": []"
"}");
- LoadOncNetworks(test_blob, "");
+ LoadOncNetworks(test_blob, "", NULL);
}
////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « chrome/browser/chromeos/cros/network_library.h ('k') | chrome/browser/chromeos/cros/onc_network_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698