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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 base::Value* value) { | 274 base::Value* value) { |
275 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); | 275 NET_LOG_EVENT("SetNetworkProperty: " + property, service_path); |
276 base::DictionaryValue properties; | 276 base::DictionaryValue properties; |
277 properties.SetWithoutPathExpansion(property, value); | 277 properties.SetWithoutPathExpansion(property, value); |
278 NetworkHandler::Get()->network_configuration_handler()->SetProperties( | 278 NetworkHandler::Get()->network_configuration_handler()->SetProperties( |
279 service_path, properties, | 279 service_path, properties, |
280 base::Bind(&base::DoNothing), | 280 base::Bind(&base::DoNothing), |
281 base::Bind(&ShillError, "SetNetworkProperty")); | 281 base::Bind(&ShillError, "SetNetworkProperty")); |
282 } | 282 } |
283 | 283 |
284 const base::DictionaryValue* FindPolicyForActiveUser( | |
285 const NetworkState* network, | |
286 onc::ONCSource* onc_source) { | |
287 const User* user = UserManager::Get()->GetActiveUser(); | |
288 std::string username_hash = user ? user->username_hash() : std::string(); | |
289 return NetworkHandler::Get()->managed_network_configuration_handler() | |
290 ->FindPolicyByGUID(username_hash, network->guid(), onc_source); | |
291 } | |
292 | |
293 std::string ActivationStateString(const std::string& activation_state) { | 284 std::string ActivationStateString(const std::string& activation_state) { |
294 int id; | 285 int id; |
295 if (activation_state == flimflam::kActivationStateActivated) | 286 if (activation_state == flimflam::kActivationStateActivated) |
296 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; | 287 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATED; |
297 else if (activation_state == flimflam::kActivationStateActivating) | 288 else if (activation_state == flimflam::kActivationStateActivating) |
298 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; | 289 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_ACTIVATING; |
299 else if (activation_state == flimflam::kActivationStateNotActivated) | 290 else if (activation_state == flimflam::kActivationStateNotActivated) |
300 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; | 291 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_NOT_ACTIVATED; |
301 else if (activation_state == flimflam::kActivationStatePartiallyActivated) | 292 else if (activation_state == flimflam::kActivationStatePartiallyActivated) |
302 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; | 293 id = IDS_CHROMEOS_NETWORK_ACTIVATION_STATE_PARTIALLY_ACTIVATED; |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 if (provider_type == flimflam::kProviderOpenVpn) { | 640 if (provider_type == flimflam::kProviderOpenVpn) { |
650 provider_properties->GetStringWithoutPathExpansion( | 641 provider_properties->GetStringWithoutPathExpansion( |
651 flimflam::kOpenVPNUserProperty, &username); | 642 flimflam::kOpenVPNUserProperty, &username); |
652 } else { | 643 } else { |
653 provider_properties->GetStringWithoutPathExpansion( | 644 provider_properties->GetStringWithoutPathExpansion( |
654 flimflam::kL2tpIpsecUserProperty, &username); | 645 flimflam::kL2tpIpsecUserProperty, &username); |
655 } | 646 } |
656 dictionary->SetString(kTagUsername, username); | 647 dictionary->SetString(kTagUsername, username); |
657 | 648 |
658 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 649 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
659 const base::DictionaryValue* onc = FindPolicyForActiveUser(vpn, &onc_source); | 650 const base::DictionaryValue* onc = |
| 651 network_connect::FindPolicyForActiveUser(vpn, &onc_source); |
660 | 652 |
661 NetworkPropertyUIData hostname_ui_data; | 653 NetworkPropertyUIData hostname_ui_data; |
662 hostname_ui_data.ParseOncProperty( | 654 hostname_ui_data.ParseOncProperty( |
663 onc_source, | 655 onc_source, |
664 onc, | 656 onc, |
665 base::StringPrintf("%s.%s", onc::network_config::kVPN, onc::vpn::kHost)); | 657 base::StringPrintf("%s.%s", onc::network_config::kVPN, onc::vpn::kHost)); |
666 std::string provider_host; | 658 std::string provider_host; |
667 provider_properties->GetStringWithoutPathExpansion( | 659 provider_properties->GetStringWithoutPathExpansion( |
668 flimflam::kHostProperty, &provider_host); | 660 flimflam::kHostProperty, &provider_host); |
669 SetValueDictionary(dictionary, kTagServerHostname, | 661 SetValueDictionary(dictionary, kTagServerHostname, |
(...skipping 488 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 |