OLD | NEW |
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 Loading... |
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 &onc_type); |
1095 if (onc_type == onc::kEncryptedConfiguration) { | 1096 if (onc_type == onc::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 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 for (base::ListValue::const_iterator it(network_configs->begin()); | 1162 for (base::ListValue::const_iterator it(network_configs->begin()); |
1162 it != network_configs->end(); ++it) { | 1163 it != network_configs->end(); ++it) { |
1163 const base::DictionaryValue* network; | 1164 const base::DictionaryValue* network; |
1164 (*it)->GetAsDictionary(&network); | 1165 (*it)->GetAsDictionary(&network); |
1165 | 1166 |
1166 bool marked_for_removal = false; | 1167 bool marked_for_removal = false; |
1167 network->GetBooleanWithoutPathExpansion(onc::kRemove, | 1168 network->GetBooleanWithoutPathExpansion(onc::kRemove, |
1168 &marked_for_removal); | 1169 &marked_for_removal); |
1169 | 1170 |
1170 std::string type; | 1171 std::string type; |
1171 network->GetStringWithoutPathExpansion(onc::kType, &type); | 1172 network->GetStringWithoutPathExpansion(onc::network_config::kType, &type); |
1172 | 1173 |
1173 std::string guid; | 1174 std::string guid; |
1174 network->GetStringWithoutPathExpansion(onc::kGUID, &guid); | 1175 network->GetStringWithoutPathExpansion(onc::network_config::kGUID, &guid); |
1175 | 1176 |
1176 if (source == onc::ONC_SOURCE_USER_IMPORT && marked_for_removal) { | 1177 if (source == onc::ONC_SOURCE_USER_IMPORT && marked_for_removal) { |
1177 // User import supports the removal of networks by ID. | 1178 // User import supports the removal of networks by ID. |
1178 removal_ids.insert(guid); | 1179 removal_ids.insert(guid); |
1179 continue; | 1180 continue; |
1180 } | 1181 } |
1181 | 1182 |
1182 // Don't configure a network that is supposed to be removed. For | 1183 // Don't configure a network that is supposed to be removed. For |
1183 // policy-managed networks, the "remove" functionality of ONC is | 1184 // policy-managed networks, the "remove" functionality of ONC is |
1184 // irrelevant. Instead, in general, all previously configured networks | 1185 // irrelevant. Instead, in general, all previously configured networks |
(...skipping 20 matching lines...) Expand all Loading... |
1205 *expanded_network); | 1206 *expanded_network); |
1206 | 1207 |
1207 // Configure the network. | 1208 // Configure the network. |
1208 scoped_ptr<base::DictionaryValue> shill_dict = | 1209 scoped_ptr<base::DictionaryValue> shill_dict = |
1209 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, | 1210 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, |
1210 *normalized_network); | 1211 *normalized_network); |
1211 | 1212 |
1212 // Set the ProxyConfig. | 1213 // Set the ProxyConfig. |
1213 const base::DictionaryValue* proxy_settings; | 1214 const base::DictionaryValue* proxy_settings; |
1214 if (normalized_network->GetDictionaryWithoutPathExpansion( | 1215 if (normalized_network->GetDictionaryWithoutPathExpansion( |
1215 onc::kProxySettings, | 1216 onc::network_config::kProxySettings, |
1216 &proxy_settings)) { | 1217 &proxy_settings)) { |
1217 scoped_ptr<base::DictionaryValue> proxy_config = | 1218 scoped_ptr<base::DictionaryValue> proxy_config = |
1218 onc::ConvertOncProxySettingsToProxyConfig(*proxy_settings); | 1219 onc::ConvertOncProxySettingsToProxyConfig(*proxy_settings); |
1219 std::string proxy_json; | 1220 std::string proxy_json; |
1220 base::JSONWriter::Write(proxy_config.get(), &proxy_json); | 1221 base::JSONWriter::Write(proxy_config.get(), &proxy_json); |
1221 shill_dict->SetStringWithoutPathExpansion( | 1222 shill_dict->SetStringWithoutPathExpansion( |
1222 flimflam::kProxyConfigProperty, | 1223 flimflam::kProxyConfigProperty, |
1223 proxy_json); | 1224 proxy_json); |
1224 } | 1225 } |
1225 | 1226 |
1226 // Set the UIData. | 1227 // Set the UIData. |
1227 scoped_ptr<NetworkUIData> ui_data = | 1228 scoped_ptr<NetworkUIData> ui_data = |
1228 onc::CreateUIData(source, *normalized_network); | 1229 onc::CreateUIData(source, *normalized_network); |
1229 base::DictionaryValue ui_data_dict; | 1230 base::DictionaryValue ui_data_dict; |
1230 ui_data->FillDictionary(&ui_data_dict); | 1231 ui_data->FillDictionary(&ui_data_dict); |
1231 std::string ui_data_json; | 1232 std::string ui_data_json; |
1232 base::JSONWriter::Write(&ui_data_dict, &ui_data_json); | 1233 base::JSONWriter::Write(&ui_data_dict, &ui_data_json); |
1233 shill_dict->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, | 1234 shill_dict->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, |
1234 ui_data_json); | 1235 ui_data_json); |
1235 | 1236 |
1236 // Set the appropriate profile for |source|. | 1237 // Set the appropriate profile for |source|. |
1237 if (profile != NULL) { | 1238 if (profile != NULL) { |
1238 shill_dict->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 1239 shill_dict->SetStringWithoutPathExpansion(flimflam::kProfileProperty, |
1239 profile->path); | 1240 profile->path); |
1240 } | 1241 } |
1241 | 1242 |
1242 // For Ethernet networks, apply them to the current Ethernet service. | 1243 // For Ethernet networks, apply them to the current Ethernet service. |
1243 if (type == onc::kEthernet) { | 1244 if (type == onc::network_type::kEthernet) { |
1244 const EthernetNetwork* ethernet = ethernet_network(); | 1245 const EthernetNetwork* ethernet = ethernet_network(); |
1245 if (ethernet) { | 1246 if (ethernet) { |
1246 CallConfigureService(ethernet->unique_id(), shill_dict.get()); | 1247 CallConfigureService(ethernet->unique_id(), shill_dict.get()); |
1247 } else { | 1248 } else { |
1248 LOG(WARNING) << "Tried to import ONC with an Ethernet network when " | 1249 LOG(WARNING) << "Tried to import ONC with an Ethernet network when " |
1249 << "there is no active Ethernet connection."; | 1250 << "there is no active Ethernet connection."; |
1250 } | 1251 } |
1251 } else { | 1252 } else { |
1252 CallConfigureService(guid, shill_dict.get()); | 1253 CallConfigureService(guid, shill_dict.get()); |
1253 } | 1254 } |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1786 GetTpmInfo(); | 1787 GetTpmInfo(); |
1787 return tpm_slot_; | 1788 return tpm_slot_; |
1788 } | 1789 } |
1789 | 1790 |
1790 const std::string& NetworkLibraryImplBase::GetTpmPin() { | 1791 const std::string& NetworkLibraryImplBase::GetTpmPin() { |
1791 GetTpmInfo(); | 1792 GetTpmInfo(); |
1792 return tpm_pin_; | 1793 return tpm_pin_; |
1793 } | 1794 } |
1794 | 1795 |
1795 } // namespace chromeos | 1796 } // namespace chromeos |
OLD | NEW |