Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore check VPN PassphraseRequred Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 } 1149 }
1158 1150
1159 void InternetOptionsHandler::CarrierStatusCallback() { 1151 void InternetOptionsHandler::CarrierStatusCallback() {
1160 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1152 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1161 const DeviceState* device = 1153 const DeviceState* device =
1162 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1154 handler->GetDeviceStateByType(flimflam::kTypeCellular);
1163 if (device && (device->carrier() == shill::kCarrierSprint)) { 1155 if (device && (device->carrier() == shill::kCarrierSprint)) {
1164 const NetworkState* network = 1156 const NetworkState* network =
1165 handler->FirstNetworkByType(flimflam::kTypeCellular); 1157 handler->FirstNetworkByType(flimflam::kTypeCellular);
1166 if (network) { 1158 if (network) {
1167 chromeos::network_connect::ActivateCellular(network->path()); 1159 ash::network_connect::ActivateCellular(network->path());
1168 UpdateConnectionData(network->path()); 1160 UpdateConnectionData(network->path());
1169 } 1161 }
1170 } 1162 }
1171 UpdateCarrier(); 1163 UpdateCarrier();
1172 } 1164 }
1173 1165
1174 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 1166 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
1175 std::string service_path; 1167 std::string service_path;
1176 std::string carrier; 1168 std::string carrier;
1177 if (args->GetSize() != 2 || 1169 if (args->GetSize() != 2 ||
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 const std::string& service_path, 1431 const std::string& service_path,
1440 const base::DictionaryValue& shill_properties) { 1432 const base::DictionaryValue& shill_properties) {
1441 const NetworkState* network = GetNetworkState(service_path); 1433 const NetworkState* network = GetNetworkState(service_path);
1442 if (!network) { 1434 if (!network) {
1443 LOG(ERROR) << "Network properties not found: " << service_path; 1435 LOG(ERROR) << "Network properties not found: " << service_path;
1444 return; 1436 return;
1445 } 1437 }
1446 1438
1447 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; 1439 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE;
1448 const base::DictionaryValue* onc = 1440 const base::DictionaryValue* onc =
1449 FindPolicyForActiveUser(network, &onc_source); 1441 network_connect::FindPolicyForActiveUser(network, &onc_source);
1450 const NetworkPropertyUIData property_ui_data(onc_source); 1442 const NetworkPropertyUIData property_ui_data(onc_source);
1451 1443
1452 base::DictionaryValue dictionary; 1444 base::DictionaryValue dictionary;
1453 1445
1454 // Device hardware address 1446 // Device hardware address
1455 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 1447 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
1456 GetDeviceState(network->device_path()); 1448 GetDeviceState(network->device_path());
1457 if (device) 1449 if (device)
1458 dictionary.SetString(kTagHardwareAddress, device->mac_address()); 1450 dictionary.SetString(kTagHardwareAddress, device->mac_address());
1459 1451
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 1676
1685 // Device settings. 1677 // Device settings.
1686 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 1678 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
1687 GetDeviceState(cellular->device_path()); 1679 GetDeviceState(cellular->device_path());
1688 if (device) { 1680 if (device) {
1689 // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that 1681 // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that
1690 // to retrieve the complete dictionary of device properties, instead of 1682 // to retrieve the complete dictionary of device properties, instead of
1691 // caching them (will be done for the new UI). 1683 // caching them (will be done for the new UI).
1692 const base::DictionaryValue& device_properties = device->properties(); 1684 const base::DictionaryValue& device_properties = device->properties();
1693 const NetworkPropertyUIData cellular_property_ui_data( 1685 const NetworkPropertyUIData cellular_property_ui_data(
1694 cellular->onc_source()); 1686 cellular->ui_data().onc_source());
1695 CopyStringFromDictionary(device_properties, flimflam::kManufacturerProperty, 1687 CopyStringFromDictionary(device_properties, flimflam::kManufacturerProperty,
1696 kTagManufacturer, dictionary); 1688 kTagManufacturer, dictionary);
1697 CopyStringFromDictionary(device_properties, flimflam::kModelIDProperty, 1689 CopyStringFromDictionary(device_properties, flimflam::kModelIDProperty,
1698 kTagModelId, dictionary); 1690 kTagModelId, dictionary);
1699 CopyStringFromDictionary(device_properties, 1691 CopyStringFromDictionary(device_properties,
1700 flimflam::kFirmwareRevisionProperty, 1692 flimflam::kFirmwareRevisionProperty,
1701 kTagFirmwareRevision, dictionary); 1693 kTagFirmwareRevision, dictionary);
1702 CopyStringFromDictionary(device_properties, 1694 CopyStringFromDictionary(device_properties,
1703 flimflam::kHardwareRevisionProperty, 1695 flimflam::kHardwareRevisionProperty,
1704 kTagHardwareRevision, dictionary); 1696 kTagHardwareRevision, dictionary);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 base::Bind(&base::DoNothing), 1834 base::Bind(&base::DoNothing),
1843 base::Bind(&ShillError, "NetworkCommand: " + command)); 1835 base::Bind(&ShillError, "NetworkCommand: " + command));
1844 } 1836 }
1845 } else if (command == kTagOptions) { 1837 } else if (command == kTagOptions) {
1846 NetworkHandler::Get()->network_configuration_handler()->GetProperties( 1838 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
1847 service_path, 1839 service_path,
1848 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, 1840 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback,
1849 weak_factory_.GetWeakPtr()), 1841 weak_factory_.GetWeakPtr()),
1850 base::Bind(&ShillError, "NetworkCommand: " + command)); 1842 base::Bind(&ShillError, "NetworkCommand: " + command));
1851 } else if (command == kTagConnect) { 1843 } else if (command == kTagConnect) {
1852 network_connect::ConnectToNetwork( 1844 ash::network_connect::ConnectToNetwork(service_path, GetNativeWindow());
1853 service_path, GetNativeWindow());
1854 } else if (command == kTagDisconnect) { 1845 } else if (command == kTagDisconnect) {
1855 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( 1846 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork(
1856 service_path, 1847 service_path,
1857 base::Bind(&base::DoNothing), 1848 base::Bind(&base::DoNothing),
1858 base::Bind(&ShillError, "NetworkCommand: " + command)); 1849 base::Bind(&ShillError, "NetworkCommand: " + command));
1859 } else if (command == kTagActivate && type == flimflam::kTypeCellular) { 1850 } else if (command == kTagActivate && type == flimflam::kTypeCellular) {
1860 network_connect::ActivateCellular(service_path); 1851 ash::network_connect::ActivateCellular(service_path);
1861 // Activation may update network properties (e.g. ActivationState), so 1852 // Activation may update network properties (e.g. ActivationState), so
1862 // request them here in case they change. 1853 // request them here in case they change.
1863 UpdateConnectionData(service_path); 1854 UpdateConnectionData(service_path);
1864 } else { 1855 } else {
1865 VLOG(1) << "Unknown command: " << command; 1856 VLOG(1) << "Unknown command: " << command;
1866 NOTREACHED(); 1857 NOTREACHED();
1867 } 1858 }
1868 } 1859 }
1869 1860
1870 void InternetOptionsHandler::AddConnection(const std::string& type) { 1861 void InternetOptionsHandler::AddConnection(const std::string& type) {
1871 if (type == flimflam::kTypeWifi) 1862 if (type == flimflam::kTypeWifi)
1872 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, GetNativeWindow()); 1863 NetworkConfigView::ShowForType(flimflam::kTypeWifi, GetNativeWindow());
1873 else if (type == flimflam::kTypeVPN) 1864 else if (type == flimflam::kTypeVPN)
1874 NetworkConfigView::ShowForType(chromeos::TYPE_VPN, GetNativeWindow()); 1865 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
1875 else if (type == flimflam::kTypeCellular) 1866 else if (type == flimflam::kTypeCellular)
1876 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 1867 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
1877 else 1868 else
1878 NOTREACHED(); 1869 NOTREACHED();
1879 } 1870 }
1880 1871
1881 base::ListValue* InternetOptionsHandler::GetWiredList() { 1872 base::ListValue* InternetOptionsHandler::GetWiredList() {
1882 base::ListValue* list = new base::ListValue(); 1873 base::ListValue* list = new base::ListValue();
1883 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 1874 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
1884 FirstNetworkByType(flimflam::kTypeEthernet); 1875 FirstNetworkByType(flimflam::kTypeEthernet);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1972 cellular && cellular->support_network_scan()); 1963 cellular && cellular->support_network_scan());
1973 1964
1974 dictionary->SetBoolean(kTagWimaxAvailable, 1965 dictionary->SetBoolean(kTagWimaxAvailable,
1975 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); 1966 handler->IsTechnologyAvailable(flimflam::kTypeWimax));
1976 dictionary->SetBoolean(kTagWimaxEnabled, 1967 dictionary->SetBoolean(kTagWimaxEnabled,
1977 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); 1968 handler->IsTechnologyEnabled(flimflam::kTypeWimax));
1978 } 1969 }
1979 1970
1980 } // namespace options 1971 } // namespace options
1981 } // namespace chromeos 1972 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698