OLD | NEW |
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/network_library.h" | 5 #include "chrome/browser/chromeos/cros/network_library.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 DCHECK(prop); | 1279 DCHECK(prop); |
1280 if (!EnsureCrosLoaded()) | 1280 if (!EnsureCrosLoaded()) |
1281 return; | 1281 return; |
1282 chromeos::ClearNetworkServiceProperty(service_path_.c_str(), prop); | 1282 chromeos::ClearNetworkServiceProperty(service_path_.c_str(), prop); |
1283 } | 1283 } |
1284 | 1284 |
1285 void Network::SetStringProperty( | 1285 void Network::SetStringProperty( |
1286 const char* prop, const std::string& str, std::string* dest) { | 1286 const char* prop, const std::string& str, std::string* dest) { |
1287 if (dest) | 1287 if (dest) |
1288 *dest = str; | 1288 *dest = str; |
1289 scoped_ptr<Value> value(Value::CreateStringValue(str)); | 1289 scoped_ptr<Value> value(base::StringValue::New(str)); |
1290 SetValueProperty(prop, value.get()); | 1290 SetValueProperty(prop, value.get()); |
1291 } | 1291 } |
1292 | 1292 |
1293 void Network::SetOrClearStringProperty(const char* prop, | 1293 void Network::SetOrClearStringProperty(const char* prop, |
1294 const std::string& str, | 1294 const std::string& str, |
1295 std::string* dest) { | 1295 std::string* dest) { |
1296 if (str.empty()) { | 1296 if (str.empty()) { |
1297 ClearProperty(prop); | 1297 ClearProperty(prop); |
1298 if (dest) | 1298 if (dest) |
1299 dest->clear(); | 1299 dest->clear(); |
1300 } else { | 1300 } else { |
1301 SetStringProperty(prop, str, dest); | 1301 SetStringProperty(prop, str, dest); |
1302 } | 1302 } |
1303 } | 1303 } |
1304 | 1304 |
1305 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { | 1305 void Network::SetBooleanProperty(const char* prop, bool b, bool* dest) { |
1306 if (dest) | 1306 if (dest) |
1307 *dest = b; | 1307 *dest = b; |
1308 scoped_ptr<Value> value(Value::CreateBooleanValue(b)); | 1308 scoped_ptr<Value> value(base::BooleanValue::New(b)); |
1309 SetValueProperty(prop, value.get()); | 1309 SetValueProperty(prop, value.get()); |
1310 } | 1310 } |
1311 | 1311 |
1312 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { | 1312 void Network::SetIntegerProperty(const char* prop, int i, int* dest) { |
1313 if (dest) | 1313 if (dest) |
1314 *dest = i; | 1314 *dest = i; |
1315 scoped_ptr<Value> value(Value::CreateIntegerValue(i)); | 1315 scoped_ptr<Value> value(base::NumberValue::New(i)); |
1316 SetValueProperty(prop, value.get()); | 1316 SetValueProperty(prop, value.get()); |
1317 } | 1317 } |
1318 | 1318 |
1319 void Network::SetPreferred(bool preferred) { | 1319 void Network::SetPreferred(bool preferred) { |
1320 if (preferred) { | 1320 if (preferred) { |
1321 SetIntegerProperty(kPriorityProperty, kPriorityPreferred, &priority_); | 1321 SetIntegerProperty(kPriorityProperty, kPriorityPreferred, &priority_); |
1322 } else { | 1322 } else { |
1323 ClearProperty(kPriorityProperty); | 1323 ClearProperty(kPriorityProperty); |
1324 priority_ = kPriorityNotSet; | 1324 priority_ = kPriorityNotSet; |
1325 } | 1325 } |
(...skipping 3409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4735 // but not UI doesn't assume such notification so just ignore result. | 4735 // but not UI doesn't assume such notification so just ignore result. |
4736 } | 4736 } |
4737 | 4737 |
4738 void NetworkLibraryImplCros::SetCellularDataRoamingAllowed(bool new_value) { | 4738 void NetworkLibraryImplCros::SetCellularDataRoamingAllowed(bool new_value) { |
4739 const NetworkDevice* cellular = FindCellularDevice(); | 4739 const NetworkDevice* cellular = FindCellularDevice(); |
4740 if (!cellular) { | 4740 if (!cellular) { |
4741 NOTREACHED() << "Calling SetCellularDataRoamingAllowed method " | 4741 NOTREACHED() << "Calling SetCellularDataRoamingAllowed method " |
4742 "w/o cellular device."; | 4742 "w/o cellular device."; |
4743 return; | 4743 return; |
4744 } | 4744 } |
4745 scoped_ptr<Value> value(Value::CreateBooleanValue(new_value)); | 4745 scoped_ptr<Value> value(base::BooleanValue::New(new_value)); |
4746 chromeos::SetNetworkDeviceProperty(cellular->device_path().c_str(), | 4746 chromeos::SetNetworkDeviceProperty(cellular->device_path().c_str(), |
4747 kCellularAllowRoamingProperty, | 4747 kCellularAllowRoamingProperty, |
4748 value.get()); | 4748 value.get()); |
4749 } | 4749 } |
4750 | 4750 |
4751 void NetworkLibraryImplCros::RequestNetworkScan() { | 4751 void NetworkLibraryImplCros::RequestNetworkScan() { |
4752 if (wifi_enabled()) { | 4752 if (wifi_enabled()) { |
4753 wifi_scanning_ = true; // Cleared when updates are received. | 4753 wifi_scanning_ = true; // Cleared when updates are received. |
4754 chromeos::RequestNetworkScan(kTypeWifi); | 4754 chromeos::RequestNetworkScan(kTypeWifi); |
4755 } | 4755 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4881 if (ipconfig_status2) { | 4881 if (ipconfig_status2) { |
4882 for (int i = 0; i < ipconfig_status2->size; ++i) { | 4882 for (int i = 0; i < ipconfig_status2->size; ++i) { |
4883 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) | 4883 if (ipconfig_status2->ips[i].type == chromeos::IPCONFIG_TYPE_IPV4) |
4884 ipconfig_static = &ipconfig_status2->ips[i]; | 4884 ipconfig_static = &ipconfig_status2->ips[i]; |
4885 } | 4885 } |
4886 } | 4886 } |
4887 } | 4887 } |
4888 if (ipconfig_static) { | 4888 if (ipconfig_static) { |
4889 // Save any changed details. | 4889 // Save any changed details. |
4890 if (ipconfig.address != ipconfig_static->address) { | 4890 if (ipconfig.address != ipconfig_static->address) { |
4891 scoped_ptr<Value> value(Value::CreateStringValue(ipconfig.address)); | 4891 scoped_ptr<Value> value(base::StringValue::New(ipconfig.address)); |
4892 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, | 4892 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, |
4893 kAddressProperty, | 4893 kAddressProperty, |
4894 value.get()); | 4894 value.get()); |
4895 } | 4895 } |
4896 if (ipconfig.netmask != ipconfig_static->netmask) { | 4896 if (ipconfig.netmask != ipconfig_static->netmask) { |
4897 int32 prefixlen = ipconfig.GetPrefixLength(); | 4897 int32 prefixlen = ipconfig.GetPrefixLength(); |
4898 if (prefixlen == -1) { | 4898 if (prefixlen == -1) { |
4899 VLOG(1) << "IP config prefixlen is invalid for netmask " | 4899 VLOG(1) << "IP config prefixlen is invalid for netmask " |
4900 << ipconfig.netmask; | 4900 << ipconfig.netmask; |
4901 } else { | 4901 } else { |
4902 scoped_ptr<Value> value(Value::CreateIntegerValue(prefixlen)); | 4902 scoped_ptr<Value> value(base::NumberValue::New(prefixlen)); |
4903 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, | 4903 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, |
4904 kPrefixlenProperty, | 4904 kPrefixlenProperty, |
4905 value.get()); | 4905 value.get()); |
4906 } | 4906 } |
4907 } | 4907 } |
4908 if (ipconfig.gateway != ipconfig_static->gateway) { | 4908 if (ipconfig.gateway != ipconfig_static->gateway) { |
4909 scoped_ptr<Value> value(Value::CreateStringValue(ipconfig.gateway)); | 4909 scoped_ptr<Value> value(base::StringValue::New(ipconfig.gateway)); |
4910 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, | 4910 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, |
4911 kGatewayProperty, | 4911 kGatewayProperty, |
4912 value.get()); | 4912 value.get()); |
4913 } | 4913 } |
4914 if (ipconfig.name_servers != ipconfig_static->name_servers) { | 4914 if (ipconfig.name_servers != ipconfig_static->name_servers) { |
4915 scoped_ptr<Value> value( | 4915 scoped_ptr<Value> value( |
4916 Value::CreateStringValue(ipconfig.name_servers)); | 4916 base::StringValue::New(ipconfig.name_servers)); |
4917 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, | 4917 chromeos::SetNetworkIPConfigProperty(ipconfig_static->path, |
4918 kNameServersProperty, | 4918 kNameServersProperty, |
4919 value.get()); | 4919 value.get()); |
4920 } | 4920 } |
4921 // Remove dhcp ip config if there is one. | 4921 // Remove dhcp ip config if there is one. |
4922 if (ipconfig_dhcp) | 4922 if (ipconfig_dhcp) |
4923 chromeos::RemoveIPConfig(ipconfig_dhcp); | 4923 chromeos::RemoveIPConfig(ipconfig_dhcp); |
4924 } | 4924 } |
4925 } | 4925 } |
4926 | 4926 |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5606 is_locked_ = false; | 5606 is_locked_ = false; |
5607 | 5607 |
5608 // Devices | 5608 // Devices |
5609 int devices = | 5609 int devices = |
5610 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR); | 5610 (1 << TYPE_ETHERNET) | (1 << TYPE_WIFI) | (1 << TYPE_CELLULAR); |
5611 available_devices_ = devices; | 5611 available_devices_ = devices; |
5612 enabled_devices_ = devices; | 5612 enabled_devices_ = devices; |
5613 connected_devices_ = devices; | 5613 connected_devices_ = devices; |
5614 | 5614 |
5615 NetworkDevice* cellular = new NetworkDevice("cellular"); | 5615 NetworkDevice* cellular = new NetworkDevice("cellular"); |
5616 scoped_ptr<Value> cellular_type(Value::CreateStringValue(kTypeCellular)); | 5616 scoped_ptr<Value> cellular_type(base::StringValue::New(kTypeCellular)); |
5617 cellular->ParseValue(PROPERTY_INDEX_TYPE, cellular_type.get()); | 5617 cellular->ParseValue(PROPERTY_INDEX_TYPE, cellular_type.get()); |
5618 cellular->IMSI_ = "123456789012345"; | 5618 cellular->IMSI_ = "123456789012345"; |
5619 device_map_["cellular"] = cellular; | 5619 device_map_["cellular"] = cellular; |
5620 | 5620 |
5621 // Networks | 5621 // Networks |
5622 DeleteNetworks(); | 5622 DeleteNetworks(); |
5623 | 5623 |
5624 ethernet_ = new EthernetNetwork("eth1"); | 5624 ethernet_ = new EthernetNetwork("eth1"); |
5625 ethernet_->set_connected(true); | 5625 ethernet_->set_connected(true); |
5626 AddNetwork(ethernet_); | 5626 AddNetwork(ethernet_); |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5873 return network_library; | 5873 return network_library; |
5874 } | 5874 } |
5875 | 5875 |
5876 ///////////////////////////////////////////////////////////////////////////// | 5876 ///////////////////////////////////////////////////////////////////////////// |
5877 | 5877 |
5878 } // namespace chromeos | 5878 } // namespace chromeos |
5879 | 5879 |
5880 // Allows InvokeLater without adding refcounting. This class is a Singleton and | 5880 // Allows InvokeLater without adding refcounting. This class is a Singleton and |
5881 // won't be deleted until it's last InvokeLater is run. | 5881 // won't be deleted until it's last InvokeLater is run. |
5882 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); | 5882 DISABLE_RUNNABLE_METHOD_REFCOUNT(chromeos::NetworkLibraryImplBase); |
OLD | NEW |