| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 base::Value* value) { | 275 base::Value* value) { |
| 276 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); | 276 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); |
| 277 base::DictionaryValue properties; | 277 base::DictionaryValue properties; |
| 278 properties.SetWithoutPathExpansion(property, value); | 278 properties.SetWithoutPathExpansion(property, value); |
| 279 NetworkHandler::Get()->network_configuration_handler()->SetProperties( | 279 NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
| 280 service_path, properties, | 280 service_path, properties, |
| 281 base::Bind(&base::DoNothing), | 281 base::Bind(&base::DoNothing), |
| 282 base::Bind(&ShillError, "SetNetworkProperty")); | 282 base::Bind(&ShillError, "SetNetworkProperty")); |
| 283 } | 283 } |
| 284 | 284 |
| 285 const base::DictionaryValue* FindPolicyForActiveUser( | |
| 286 const NetworkState* network, | |
| 287 onc::ONCSource* onc_source) { | |
| 288 const User* user = UserManager::Get()->GetActiveUser(); | |
| 289 std::string username_hash = user ? user->username_hash() : std::string(); | |
| 290 return NetworkHandler::Get()->managed_network_configuration_handler() | |
| 291 ->FindPolicyByGUID(username_hash, network->guid(), onc_source); | |
| 292 } | |
| 293 | |
| 294 std::string ActivationStateString(const std::string& activation_state) { | 285 std::string ActivationStateString(const std::string& activation_state) { |
| 295 int id; | 286 int id; |
| 296 if (activation_state == flimflam::kActivationStateActivated) | 287 if (activation_state == flimflam::kActivationStateActivated) |
| 297 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; | 288 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; |
| 298 else if (activation_state == flimflam::kActivationStateActivating) | 289 else if (activation_state == flimflam::kActivationStateActivating) |
| 299 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; | 290 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; |
| 300 else if (activation_state == flimflam::kActivationStateNotActivated) | 291 else if (activation_state == flimflam::kActivationStateNotActivated) |
| 301 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; | 292 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; |
| 302 else if (activation_state == flimflam::kActivationStatePartiallyActivated) | 293 else if (activation_state == flimflam::kActivationStatePartiallyActivated) |
| 303 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; | 294 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 if (provider_type == flimflam::kProviderOpenVpn) { | 641 if (provider_type == flimflam::kProviderOpenVpn) { |
| 651 provider_properties->GetStringWithoutPathExpansion( | 642 provider_properties->GetStringWithoutPathExpansion( |
| 652 flimflam::kOpenVPNUserProperty, &username); | 643 flimflam::kOpenVPNUserProperty, &username); |
| 653 } else { | 644 } else { |
| 654 provider_properties->GetStringWithoutPathExpansion( | 645 provider_properties->GetStringWithoutPathExpansion( |
| 655 flimflam::kL2tpIpsecUserProperty, &username); | 646 flimflam::kL2tpIpsecUserProperty, &username); |
| 656 } | 647 } |
| 657 dictionary->SetString(kTagUsername, username); | 648 dictionary->SetString(kTagUsername, username); |
| 658 | 649 |
| 659 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 650 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
| 660 const base::DictionaryValue* onc = FindPolicyForActiveUser(vpn, &onc_source); | 651 const base::DictionaryValue* onc = |
| 652 network_connect::FindPolicyForActiveUser(vpn, &onc_source); |
| 661 | 653 |
| 662 NetworkPropertyUIData hostname_ui_data; | 654 NetworkPropertyUIData hostname_ui_data; |
| 663 hostname_ui_data.ParseOncProperty( | 655 hostname_ui_data.ParseOncProperty( |
| 664 onc_source, | 656 onc_source, |
| 665 onc, | 657 onc, |
| 666 base::StringPrintf("%s.%s", onc::network_config::kVPN, onc::vpn::kHost)); | 658 base::StringPrintf("%s.%s", onc::network_config::kVPN, onc::vpn::kHost)); |
| 667 std::string provider_host; | 659 std::string provider_host; |
| 668 provider_properties->GetStringWithoutPathExpansion( | 660 provider_properties->GetStringWithoutPathExpansion( |
| 669 flimflam::kHostProperty, &provider_host); | 661 flimflam::kHostProperty, &provider_host); |
| 670 SetValueDictionary(dictionary, kTagServerHostname, | 662 SetValueDictionary(dictionary, kTagServerHostname, |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 } | 1150 } |
| 1159 | 1151 |
| 1160 void InternetOptionsHandler::CarrierStatusCallback() { | 1152 void InternetOptionsHandler::CarrierStatusCallback() { |
| 1161 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 1153 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 1162 const DeviceState* device = | 1154 const DeviceState* device = |
| 1163 handler->GetDeviceStateByType(flimflam::kTypeCellular); | 1155 handler->GetDeviceStateByType(flimflam::kTypeCellular); |
| 1164 if (device && (device->carrier() == shill::kCarrierSprint)) { | 1156 if (device && (device->carrier() == shill::kCarrierSprint)) { |
| 1165 const NetworkState* network = | 1157 const NetworkState* network = |
| 1166 handler->FirstNetworkByType(flimflam::kTypeCellular); | 1158 handler->FirstNetworkByType(flimflam::kTypeCellular); |
| 1167 if (network) { | 1159 if (network) { |
| 1168 chromeos::network_connect::ActivateCellular(network->path()); | 1160 ash::network_connect::ActivateCellular(network->path()); |
| 1169 UpdateConnectionData(network->path()); | 1161 UpdateConnectionData(network->path()); |
| 1170 } | 1162 } |
| 1171 } | 1163 } |
| 1172 UpdateCarrier(); | 1164 UpdateCarrier(); |
| 1173 } | 1165 } |
| 1174 | 1166 |
| 1175 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { | 1167 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { |
| 1176 std::string service_path; | 1168 std::string service_path; |
| 1177 std::string carrier; | 1169 std::string carrier; |
| 1178 if (args->GetSize() != 2 || | 1170 if (args->GetSize() != 2 || |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 const std::string& service_path, | 1432 const std::string& service_path, |
| 1441 const base::DictionaryValue& shill_properties) { | 1433 const base::DictionaryValue& shill_properties) { |
| 1442 const NetworkState* network = GetNetworkState(service_path); | 1434 const NetworkState* network = GetNetworkState(service_path); |
| 1443 if (!network) { | 1435 if (!network) { |
| 1444 LOG(ERROR) << "Network properties not found: " << service_path; | 1436 LOG(ERROR) << "Network properties not found: " << service_path; |
| 1445 return; | 1437 return; |
| 1446 } | 1438 } |
| 1447 | 1439 |
| 1448 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1440 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
| 1449 const base::DictionaryValue* onc = | 1441 const base::DictionaryValue* onc = |
| 1450 FindPolicyForActiveUser(network, &onc_source); | 1442 network_connect::FindPolicyForActiveUser(network, &onc_source); |
| 1451 const NetworkPropertyUIData property_ui_data(onc_source); | 1443 const NetworkPropertyUIData property_ui_data(onc_source); |
| 1452 | 1444 |
| 1453 base::DictionaryValue dictionary; | 1445 base::DictionaryValue dictionary; |
| 1454 | 1446 |
| 1455 // Device hardware address | 1447 // Device hardware address |
| 1456 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> | 1448 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> |
| 1457 GetDeviceState(network->device_path()); | 1449 GetDeviceState(network->device_path()); |
| 1458 if (device) | 1450 if (device) |
| 1459 dictionary.SetString(kTagHardwareAddress, device->mac_address()); | 1451 dictionary.SetString(kTagHardwareAddress, device->mac_address()); |
| 1460 | 1452 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 | 1677 |
| 1686 // Device settings. | 1678 // Device settings. |
| 1687 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> | 1679 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> |
| 1688 GetDeviceState(cellular->device_path()); | 1680 GetDeviceState(cellular->device_path()); |
| 1689 if (device) { | 1681 if (device) { |
| 1690 // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that | 1682 // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that |
| 1691 // to retrieve the complete dictionary of device properties, instead of | 1683 // to retrieve the complete dictionary of device properties, instead of |
| 1692 // caching them (will be done for the new UI). | 1684 // caching them (will be done for the new UI). |
| 1693 const base::DictionaryValue& device_properties = device->properties(); | 1685 const base::DictionaryValue& device_properties = device->properties(); |
| 1694 const NetworkPropertyUIData cellular_property_ui_data( | 1686 const NetworkPropertyUIData cellular_property_ui_data( |
| 1695 cellular->onc_source()); | 1687 cellular->ui_data().onc_source()); |
| 1696 CopyStringFromDictionary(device_properties, flimflam::kManufacturerProperty, | 1688 CopyStringFromDictionary(device_properties, flimflam::kManufacturerProperty, |
| 1697 kTagManufacturer, dictionary); | 1689 kTagManufacturer, dictionary); |
| 1698 CopyStringFromDictionary(device_properties, flimflam::kModelIDProperty, | 1690 CopyStringFromDictionary(device_properties, flimflam::kModelIDProperty, |
| 1699 kTagModelId, dictionary); | 1691 kTagModelId, dictionary); |
| 1700 CopyStringFromDictionary(device_properties, | 1692 CopyStringFromDictionary(device_properties, |
| 1701 flimflam::kFirmwareRevisionProperty, | 1693 flimflam::kFirmwareRevisionProperty, |
| 1702 kTagFirmwareRevision, dictionary); | 1694 kTagFirmwareRevision, dictionary); |
| 1703 CopyStringFromDictionary(device_properties, | 1695 CopyStringFromDictionary(device_properties, |
| 1704 flimflam::kHardwareRevisionProperty, | 1696 flimflam::kHardwareRevisionProperty, |
| 1705 kTagHardwareRevision, dictionary); | 1697 kTagHardwareRevision, dictionary); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1843 base::Bind(&base::DoNothing), | 1835 base::Bind(&base::DoNothing), |
| 1844 base::Bind(&ShillError, "NetworkCommand: " + command)); | 1836 base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1845 } | 1837 } |
| 1846 } else if (command == kTagOptions) { | 1838 } else if (command == kTagOptions) { |
| 1847 NetworkHandler::Get()->network_configuration_handler()->GetProperties( | 1839 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1848 service_path, | 1840 service_path, |
| 1849 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1841 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
| 1850 weak_factory_.GetWeakPtr()), | 1842 weak_factory_.GetWeakPtr()), |
| 1851 base::Bind(&ShillError, "NetworkCommand: " + command)); | 1843 base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1852 } else if (command == kTagConnect) { | 1844 } else if (command == kTagConnect) { |
| 1853 network_connect::ConnectToNetwork( | 1845 ash::network_connect::ConnectToNetwork(service_path, GetNativeWindow()); |
| 1854 service_path, GetNativeWindow()); | |
| 1855 } else if (command == kTagDisconnect) { | 1846 } else if (command == kTagDisconnect) { |
| 1856 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( | 1847 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( |
| 1857 service_path, | 1848 service_path, |
| 1858 base::Bind(&base::DoNothing), | 1849 base::Bind(&base::DoNothing), |
| 1859 base::Bind(&ShillError, "NetworkCommand: " + command)); | 1850 base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1860 } else if (command == kTagConfigure) { | 1851 } else if (command == kTagConfigure) { |
| 1861 NetworkConfigView::ShowForPath(service_path, GetNativeWindow()); | 1852 NetworkConfigView::Show(service_path, GetNativeWindow()); |
| 1862 } else if (command == kTagActivate && type == flimflam::kTypeCellular) { | 1853 } else if (command == kTagActivate && type == flimflam::kTypeCellular) { |
| 1863 network_connect::ActivateCellular(service_path); | 1854 ash::network_connect::ActivateCellular(service_path); |
| 1864 // Activation may update network properties (e.g. ActivationState), so | 1855 // Activation may update network properties (e.g. ActivationState), so |
| 1865 // request them here in case they change. | 1856 // request them here in case they change. |
| 1866 UpdateConnectionData(service_path); | 1857 UpdateConnectionData(service_path); |
| 1867 } else { | 1858 } else { |
| 1868 VLOG(1) << "Unknown command: " << command; | 1859 VLOG(1) << "Unknown command: " << command; |
| 1869 NOTREACHED(); | 1860 NOTREACHED(); |
| 1870 } | 1861 } |
| 1871 } | 1862 } |
| 1872 | 1863 |
| 1873 void InternetOptionsHandler::AddConnection(const std::string& type) { | 1864 void InternetOptionsHandler::AddConnection(const std::string& type) { |
| 1874 if (type == flimflam::kTypeWifi) | 1865 if (type == flimflam::kTypeWifi) |
| 1875 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, GetNativeWindow()); | 1866 NetworkConfigView::ShowForType(flimflam::kTypeWifi, GetNativeWindow()); |
| 1876 else if (type == flimflam::kTypeVPN) | 1867 else if (type == flimflam::kTypeVPN) |
| 1877 NetworkConfigView::ShowForType(chromeos::TYPE_VPN, GetNativeWindow()); | 1868 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow()); |
| 1878 else if (type == flimflam::kTypeCellular) | 1869 else if (type == flimflam::kTypeCellular) |
| 1879 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 1870 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); |
| 1880 else | 1871 else |
| 1881 NOTREACHED(); | 1872 NOTREACHED(); |
| 1882 } | 1873 } |
| 1883 | 1874 |
| 1884 base::ListValue* InternetOptionsHandler::GetWiredList() { | 1875 base::ListValue* InternetOptionsHandler::GetWiredList() { |
| 1885 base::ListValue* list = new base::ListValue(); | 1876 base::ListValue* list = new base::ListValue(); |
| 1886 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | 1877 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 1887 FirstNetworkByType(flimflam::kTypeEthernet); | 1878 FirstNetworkByType(flimflam::kTypeEthernet); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1975 cellular && cellular->support_network_scan()); | 1966 cellular && cellular->support_network_scan()); |
| 1976 | 1967 |
| 1977 dictionary->SetBoolean(kTagWimaxAvailable, | 1968 dictionary->SetBoolean(kTagWimaxAvailable, |
| 1978 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); | 1969 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); |
| 1979 dictionary->SetBoolean(kTagWimaxEnabled, | 1970 dictionary->SetBoolean(kTagWimaxEnabled, |
| 1980 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); | 1971 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); |
| 1981 } | 1972 } |
| 1982 | 1973 |
| 1983 } // namespace options | 1974 } // namespace options |
| 1984 } // namespace chromeos | 1975 } // namespace chromeos |
| OLD | NEW |