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

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

Issue 11962048: This adds Cellular to the Shill to ONC translation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing broken unit test Created 7 years, 11 months 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/network_library_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/network_library_impl_base.h" 5 #include "chrome/browser/chromeos/cros/network_library_impl_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 scoped_ptr<base::DictionaryValue> root_dict = 1084 scoped_ptr<base::DictionaryValue> root_dict =
1085 onc::ReadDictionaryFromJson(onc_blob); 1085 onc::ReadDictionaryFromJson(onc_blob);
1086 if (root_dict.get() == NULL) { 1086 if (root_dict.get() == NULL) {
1087 LOG(ERROR) << "ONC loaded from " << onc::GetSourceAsString(source) 1087 LOG(ERROR) << "ONC loaded from " << onc::GetSourceAsString(source)
1088 << " is not a valid JSON dictionary."; 1088 << " is not a valid JSON dictionary.";
1089 return false; 1089 return false;
1090 } 1090 }
1091 1091
1092 // Check and see if this is an encrypted ONC file. If so, decrypt it. 1092 // Check and see if this is an encrypted ONC file. If so, decrypt it.
1093 std::string onc_type; 1093 std::string onc_type;
1094 root_dict->GetStringWithoutPathExpansion(onc::kType, &onc_type); 1094 root_dict->GetStringWithoutPathExpansion(onc::network_config::kType,
1095 if (onc_type == onc::kEncryptedConfiguration) { 1095 &onc_type);
1096 if (onc_type == onc::toplevel_config::kEncryptedConfiguration) {
1096 root_dict = onc::Decrypt(passphrase, *root_dict); 1097 root_dict = onc::Decrypt(passphrase, *root_dict);
1097 if (root_dict.get() == NULL) { 1098 if (root_dict.get() == NULL) {
1098 LOG(ERROR) << "Couldn't decrypt the ONC from " 1099 LOG(ERROR) << "Couldn't decrypt the ONC from "
1099 << onc::GetSourceAsString(source); 1100 << onc::GetSourceAsString(source);
1100 return false; 1101 return false;
1101 } 1102 }
1102 } 1103 }
1103 1104
1104 // Validate the ONC dictionary. We are liberal and ignore unknown field 1105 // Validate the ONC dictionary. We are liberal and ignore unknown field
1105 // names and ignore invalid field names in kRecommended arrays. 1106 // names and ignore invalid field names in kRecommended arrays.
(...skipping 21 matching lines...) Expand all
1127 success = false; 1128 success = false;
1128 } else if (validation_result == onc::Validator::INVALID || 1129 } else if (validation_result == onc::Validator::INVALID ||
1129 root_dict == NULL) { 1130 root_dict == NULL) {
1130 LOG(ERROR) << "ONC from " << onc::GetSourceAsString(source) 1131 LOG(ERROR) << "ONC from " << onc::GetSourceAsString(source)
1131 << " is invalid and couldn't be repaired."; 1132 << " is invalid and couldn't be repaired.";
1132 return false; 1133 return false;
1133 } 1134 }
1134 1135
1135 const base::ListValue* certificates; 1136 const base::ListValue* certificates;
1136 bool has_certificates = 1137 bool has_certificates =
1137 root_dict->GetListWithoutPathExpansion(onc::kCertificates, &certificates); 1138 root_dict->GetListWithoutPathExpansion(
1139 onc::toplevel_config::kCertificates,
1140 &certificates);
1138 1141
1139 const base::ListValue* network_configs; 1142 const base::ListValue* network_configs;
1140 bool has_network_configurations = root_dict->GetListWithoutPathExpansion( 1143 bool has_network_configurations = root_dict->GetListWithoutPathExpansion(
1141 onc::kNetworkConfigurations, 1144 onc::toplevel_config::kNetworkConfigurations,
1142 &network_configs); 1145 &network_configs);
1143 1146
1144 if (has_certificates) { 1147 if (has_certificates) {
1145 VLOG(2) << "ONC file has " << certificates->GetSize() << " certificates"; 1148 VLOG(2) << "ONC file has " << certificates->GetSize() << " certificates";
1146 1149
1147 onc::CertificateImporter cert_importer(source, allow_web_trust_from_policy); 1150 onc::CertificateImporter cert_importer(source, allow_web_trust_from_policy);
1148 if (cert_importer.ParseAndStoreCertificates(*certificates) != 1151 if (cert_importer.ParseAndStoreCertificates(*certificates) !=
1149 onc::CertificateImporter::IMPORT_OK) { 1152 onc::CertificateImporter::IMPORT_OK) {
1150 LOG(ERROR) << "Cannot parse some of the certificates in the ONC from " 1153 LOG(ERROR) << "Cannot parse some of the certificates in the ONC from "
1151 << onc::GetSourceAsString(source); 1154 << onc::GetSourceAsString(source);
1152 success = false; 1155 success = false;
1153 } 1156 }
1154 } 1157 }
1155 1158
1156 std::set<std::string> removal_ids; 1159 std::set<std::string> removal_ids;
1157 std::set<std::string>& network_ids(network_source_map_[source]); 1160 std::set<std::string>& network_ids(network_source_map_[source]);
1158 network_ids.clear(); 1161 network_ids.clear();
1159 if (has_network_configurations) { 1162 if (has_network_configurations) {
1160 VLOG(2) << "ONC file has " << network_configs->GetSize() << " networks"; 1163 VLOG(2) << "ONC file has " << network_configs->GetSize() << " networks";
1161 for (base::ListValue::const_iterator it(network_configs->begin()); 1164 for (base::ListValue::const_iterator it(network_configs->begin());
1162 it != network_configs->end(); ++it) { 1165 it != network_configs->end(); ++it) {
1163 const base::DictionaryValue* network; 1166 const base::DictionaryValue* network;
1164 (*it)->GetAsDictionary(&network); 1167 (*it)->GetAsDictionary(&network);
1165 1168
1166 bool marked_for_removal = false; 1169 bool marked_for_removal = false;
1167 network->GetBooleanWithoutPathExpansion(onc::kRemove, 1170 network->GetBooleanWithoutPathExpansion(onc::kRemove,
1168 &marked_for_removal); 1171 &marked_for_removal);
1169 1172
1170 std::string type; 1173 std::string type;
1171 network->GetStringWithoutPathExpansion(onc::kType, &type); 1174 network->GetStringWithoutPathExpansion(onc::network_config::kType, &type);
1172 1175
1173 std::string guid; 1176 std::string guid;
1174 network->GetStringWithoutPathExpansion(onc::kGUID, &guid); 1177 network->GetStringWithoutPathExpansion(onc::network_config::kGUID, &guid);
1175 1178
1176 if (source == onc::ONC_SOURCE_USER_IMPORT && marked_for_removal) { 1179 if (source == onc::ONC_SOURCE_USER_IMPORT && marked_for_removal) {
1177 // User import supports the removal of networks by ID. 1180 // User import supports the removal of networks by ID.
1178 removal_ids.insert(guid); 1181 removal_ids.insert(guid);
1179 continue; 1182 continue;
1180 } 1183 }
1181 1184
1182 // Don't configure a network that is supposed to be removed. For 1185 // Don't configure a network that is supposed to be removed. For
1183 // policy-managed networks, the "remove" functionality of ONC is 1186 // policy-managed networks, the "remove" functionality of ONC is
1184 // irrelevant. Instead, in general, all previously configured networks 1187 // irrelevant. Instead, in general, all previously configured networks
(...skipping 20 matching lines...) Expand all
1205 *expanded_network); 1208 *expanded_network);
1206 1209
1207 // Configure the network. 1210 // Configure the network.
1208 scoped_ptr<base::DictionaryValue> shill_dict = 1211 scoped_ptr<base::DictionaryValue> shill_dict =
1209 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, 1212 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature,
1210 *normalized_network); 1213 *normalized_network);
1211 1214
1212 // Set the ProxyConfig. 1215 // Set the ProxyConfig.
1213 const base::DictionaryValue* proxy_settings; 1216 const base::DictionaryValue* proxy_settings;
1214 if (normalized_network->GetDictionaryWithoutPathExpansion( 1217 if (normalized_network->GetDictionaryWithoutPathExpansion(
1215 onc::kProxySettings, 1218 onc::network_config::kProxySettings,
1216 &proxy_settings)) { 1219 &proxy_settings)) {
1217 scoped_ptr<base::DictionaryValue> proxy_config = 1220 scoped_ptr<base::DictionaryValue> proxy_config =
1218 onc::ConvertOncProxySettingsToProxyConfig(*proxy_settings); 1221 onc::ConvertOncProxySettingsToProxyConfig(*proxy_settings);
1219 std::string proxy_json; 1222 std::string proxy_json;
1220 base::JSONWriter::Write(proxy_config.get(), &proxy_json); 1223 base::JSONWriter::Write(proxy_config.get(), &proxy_json);
1221 shill_dict->SetStringWithoutPathExpansion( 1224 shill_dict->SetStringWithoutPathExpansion(
1222 flimflam::kProxyConfigProperty, 1225 flimflam::kProxyConfigProperty,
1223 proxy_json); 1226 proxy_json);
1224 } 1227 }
1225 1228
1226 // Set the UIData. 1229 // Set the UIData.
1227 scoped_ptr<NetworkUIData> ui_data = 1230 scoped_ptr<NetworkUIData> ui_data =
1228 onc::CreateUIData(source, *normalized_network); 1231 onc::CreateUIData(source, *normalized_network);
1229 base::DictionaryValue ui_data_dict; 1232 base::DictionaryValue ui_data_dict;
1230 ui_data->FillDictionary(&ui_data_dict); 1233 ui_data->FillDictionary(&ui_data_dict);
1231 std::string ui_data_json; 1234 std::string ui_data_json;
1232 base::JSONWriter::Write(&ui_data_dict, &ui_data_json); 1235 base::JSONWriter::Write(&ui_data_dict, &ui_data_json);
1233 shill_dict->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, 1236 shill_dict->SetStringWithoutPathExpansion(flimflam::kUIDataProperty,
1234 ui_data_json); 1237 ui_data_json);
1235 1238
1236 // Set the appropriate profile for |source|. 1239 // Set the appropriate profile for |source|.
1237 if (profile != NULL) { 1240 if (profile != NULL) {
1238 shill_dict->SetStringWithoutPathExpansion(flimflam::kProfileProperty, 1241 shill_dict->SetStringWithoutPathExpansion(flimflam::kProfileProperty,
1239 profile->path); 1242 profile->path);
1240 } 1243 }
1241 1244
1242 // For Ethernet networks, apply them to the current Ethernet service. 1245 // For Ethernet networks, apply them to the current Ethernet service.
1243 if (type == onc::kEthernet) { 1246 if (type == onc::network_type::kEthernet) {
1244 const EthernetNetwork* ethernet = ethernet_network(); 1247 const EthernetNetwork* ethernet = ethernet_network();
1245 if (ethernet) { 1248 if (ethernet) {
1246 CallConfigureService(ethernet->unique_id(), shill_dict.get()); 1249 CallConfigureService(ethernet->unique_id(), shill_dict.get());
1247 } else { 1250 } else {
1248 LOG(WARNING) << "Tried to import ONC with an Ethernet network when " 1251 LOG(WARNING) << "Tried to import ONC with an Ethernet network when "
1249 << "there is no active Ethernet connection."; 1252 << "there is no active Ethernet connection.";
1250 } 1253 }
1251 } else { 1254 } else {
1252 CallConfigureService(guid, shill_dict.get()); 1255 CallConfigureService(guid, shill_dict.get());
1253 } 1256 }
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 GetTpmInfo(); 1789 GetTpmInfo();
1787 return tpm_slot_; 1790 return tpm_slot_;
1788 } 1791 }
1789 1792
1790 const std::string& NetworkLibraryImplBase::GetTpmPin() { 1793 const std::string& NetworkLibraryImplBase::GetTpmPin() {
1791 GetTpmInfo(); 1794 GetTpmInfo();
1792 return tpm_pin_; 1795 return tpm_pin_;
1793 } 1796 }
1794 1797
1795 } // namespace chromeos 1798 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros/network_library_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698