| 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/ui/webui/options/chromeos/internet_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 chromeos::CrosRequestNetworkServiceProperties( | 1220 chromeos::CrosRequestNetworkServiceProperties( |
| 1221 network->service_path(), | 1221 network->service_path(), |
| 1222 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1222 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
| 1223 weak_factory_.GetWeakPtr(), network)); | 1223 weak_factory_.GetWeakPtr(), network)); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback( | 1226 void InternetOptionsHandler::PopulateDictionaryDetailsCallback( |
| 1227 const chromeos::Network* network, | 1227 const chromeos::Network* network, |
| 1228 const std::string& service_path, | 1228 const std::string& service_path, |
| 1229 const base::DictionaryValue* shill_properties) { | 1229 const base::DictionaryValue* shill_properties) { |
| 1230 // Have to copy the properties because the object will be out of scope when |
| 1231 // this function call completes (it's owned by the calling function). |
| 1232 base::DictionaryValue* shill_props_copy = shill_properties->DeepCopy(); |
| 1233 chromeos::CrosListIPConfigs( |
| 1234 network->device_path(), |
| 1235 base::Bind(&InternetOptionsHandler::PopulateIPConfigsCallback, |
| 1236 weak_factory_.GetWeakPtr(), |
| 1237 network, |
| 1238 base::Owned(shill_props_copy))); |
| 1239 } |
| 1240 |
| 1241 void InternetOptionsHandler::PopulateIPConfigsCallback( |
| 1242 const chromeos::Network* network, |
| 1243 base::DictionaryValue* shill_properties, |
| 1244 const chromeos::NetworkIPConfigVector& ipconfigs, |
| 1245 const std::string& hardware_address) { |
| 1230 if (VLOG_IS_ON(2)) { | 1246 if (VLOG_IS_ON(2)) { |
| 1231 std::string properties_json; | 1247 std::string properties_json; |
| 1232 base::JSONWriter::WriteWithOptions(shill_properties, | 1248 base::JSONWriter::WriteWithOptions(shill_properties, |
| 1233 base::JSONWriter::OPTIONS_PRETTY_PRINT, | 1249 base::JSONWriter::OPTIONS_PRETTY_PRINT, |
| 1234 &properties_json); | 1250 &properties_json); |
| 1235 VLOG(2) << "Shill Properties: " << std::endl << properties_json; | 1251 VLOG(2) << "Shill Properties: " << std::endl << properties_json; |
| 1236 } | 1252 } |
| 1237 | 1253 |
| 1238 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork( | 1254 Profile::FromWebUI(web_ui())->GetProxyConfigTracker()->UISetCurrentNetwork( |
| 1239 network->service_path()); | 1255 network->service_path()); |
| 1240 | 1256 |
| 1241 const chromeos::NetworkUIData& ui_data = network->ui_data(); | 1257 const chromeos::NetworkUIData& ui_data = network->ui_data(); |
| 1242 const chromeos::NetworkPropertyUIData property_ui_data(ui_data); | 1258 const chromeos::NetworkPropertyUIData property_ui_data(ui_data); |
| 1243 const base::DictionaryValue* onc = | 1259 const base::DictionaryValue* onc = |
| 1244 cros_->FindOncForNetwork(network->unique_id()); | 1260 cros_->FindOncForNetwork(network->unique_id()); |
| 1245 | 1261 |
| 1246 base::DictionaryValue dictionary; | 1262 base::DictionaryValue dictionary; |
| 1247 std::string hardware_address; | |
| 1248 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | |
| 1249 network->device_path(), &hardware_address, | |
| 1250 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | |
| 1251 if (!hardware_address.empty()) | 1263 if (!hardware_address.empty()) |
| 1252 dictionary.SetString(kTagHardwareAddress, hardware_address); | 1264 dictionary.SetString(kTagHardwareAddress, hardware_address); |
| 1253 | 1265 |
| 1254 // The DHCP IPConfig contains the values that are actually in use at the | 1266 // The DHCP IPConfig contains the values that are actually in use at the |
| 1255 // moment, even if some are overridden by static IP values. | 1267 // moment, even if some are overridden by static IP values. |
| 1256 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue); | 1268 scoped_ptr<DictionaryValue> ipconfig_dhcp(new DictionaryValue); |
| 1257 std::string ipconfig_name_servers; | 1269 std::string ipconfig_name_servers; |
| 1258 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 1270 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 1259 it != ipconfigs.end(); ++it) { | 1271 it != ipconfigs.end(); ++it) { |
| 1260 const chromeos::NetworkIPConfig& ipconfig = *it; | 1272 const chromeos::NetworkIPConfig& ipconfig = *it; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 name_server_type = kNameServerTypeUser; | 1309 name_server_type = kNameServerTypeUser; |
| 1298 } | 1310 } |
| 1299 if (ipconfig_name_servers == kGoogleNameServers) { | 1311 if (ipconfig_name_servers == kGoogleNameServers) { |
| 1300 name_server_type = kNameServerTypeGoogle; | 1312 name_server_type = kNameServerTypeGoogle; |
| 1301 } | 1313 } |
| 1302 SetValueDictionary(&dictionary, | 1314 SetValueDictionary(&dictionary, |
| 1303 kDictionaryStaticIp, | 1315 kDictionaryStaticIp, |
| 1304 static_ip_dict.release(), | 1316 static_ip_dict.release(), |
| 1305 property_ui_data); | 1317 property_ui_data); |
| 1306 } else { | 1318 } else { |
| 1307 LOG(ERROR) << "Unable to fetch IP configuration for " << service_path; | 1319 LOG(ERROR) << "Unable to fetch IP configuration for " |
| 1320 << network->service_path(); |
| 1308 // If we were unable to fetch shill_properties for some reason, | 1321 // If we were unable to fetch shill_properties for some reason, |
| 1309 // then just go with some defaults. | 1322 // then just go with some defaults. |
| 1310 dictionary.SetBoolean(kIpConfigAutoConfig, false); | 1323 dictionary.SetBoolean(kIpConfigAutoConfig, false); |
| 1311 dictionary.Set(kDictionarySavedIp, new DictionaryValue); | 1324 dictionary.Set(kDictionarySavedIp, new DictionaryValue); |
| 1312 SetValueDictionary(&dictionary, kDictionaryStaticIp, new DictionaryValue, | 1325 SetValueDictionary(&dictionary, kDictionaryStaticIp, new DictionaryValue, |
| 1313 property_ui_data); | 1326 property_ui_data); |
| 1314 } | 1327 } |
| 1315 | 1328 |
| 1316 chromeos::ConnectionType type = network->type(); | 1329 chromeos::ConnectionType type = network->type(); |
| 1317 dictionary.SetInteger(kTagType, type); | 1330 dictionary.SetInteger(kTagType, type); |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 | 1825 |
| 1813 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); | 1826 dictionary->SetBoolean(kTagWimaxEnabled, cros_->wimax_enabled()); |
| 1814 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); | 1827 dictionary->SetBoolean(kTagWimaxAvailable, cros_->wimax_available()); |
| 1815 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); | 1828 dictionary->SetBoolean(kTagWimaxBusy, cros_->wimax_busy()); |
| 1816 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once | 1829 // TODO(kevers): The use of 'offline_mode' is not quite correct. Update once |
| 1817 // we have proper back-end support. | 1830 // we have proper back-end support. |
| 1818 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); | 1831 dictionary->SetBoolean(kTagAirplaneMode, cros_->offline_mode()); |
| 1819 } | 1832 } |
| 1820 | 1833 |
| 1821 } // namespace options | 1834 } // namespace options |
| OLD | NEW |