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

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: Feedbac Round 2.2 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 487 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 == kTagConfigure) { 1850 } else if (command == kTagConfigure) {
1860 NetworkConfigView::ShowForPath(service_path, GetNativeWindow()); 1851 NetworkConfigView::Show(service_path, GetNativeWindow());
1861 } else if (command == kTagActivate && type == flimflam::kTypeCellular) { 1852 } else if (command == kTagActivate && type == flimflam::kTypeCellular) {
1862 network_connect::ActivateCellular(service_path); 1853 ash::network_connect::ActivateCellular(service_path);
1863 // Activation may update network properties (e.g. ActivationState), so 1854 // Activation may update network properties (e.g. ActivationState), so
1864 // request them here in case they change. 1855 // request them here in case they change.
1865 UpdateConnectionData(service_path); 1856 UpdateConnectionData(service_path);
1866 } else { 1857 } else {
1867 VLOG(1) << "Unknown command: " << command; 1858 VLOG(1) << "Unknown command: " << command;
1868 NOTREACHED(); 1859 NOTREACHED();
1869 } 1860 }
1870 } 1861 }
1871 1862
1872 void InternetOptionsHandler::AddConnection(const std::string& type) { 1863 void InternetOptionsHandler::AddConnection(const std::string& type) {
1873 if (type == flimflam::kTypeWifi) 1864 if (type == flimflam::kTypeWifi)
1874 NetworkConfigView::ShowForType(chromeos::TYPE_WIFI, GetNativeWindow()); 1865 NetworkConfigView::ShowForType(flimflam::kTypeWifi, GetNativeWindow());
1875 else if (type == flimflam::kTypeVPN) 1866 else if (type == flimflam::kTypeVPN)
1876 NetworkConfigView::ShowForType(chromeos::TYPE_VPN, GetNativeWindow()); 1867 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
1877 else if (type == flimflam::kTypeCellular) 1868 else if (type == flimflam::kTypeCellular)
1878 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 1869 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
1879 else 1870 else
1880 NOTREACHED(); 1871 NOTREACHED();
1881 } 1872 }
1882 1873
1883 base::ListValue* InternetOptionsHandler::GetWiredList() { 1874 base::ListValue* InternetOptionsHandler::GetWiredList() {
1884 base::ListValue* list = new base::ListValue(); 1875 base::ListValue* list = new base::ListValue();
1885 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 1876 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
1886 FirstNetworkByType(flimflam::kTypeEthernet); 1877 FirstNetworkByType(flimflam::kTypeEthernet);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 cellular && cellular->support_network_scan()); 1965 cellular && cellular->support_network_scan());
1975 1966
1976 dictionary->SetBoolean(kTagWimaxAvailable, 1967 dictionary->SetBoolean(kTagWimaxAvailable,
1977 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); 1968 handler->IsTechnologyAvailable(flimflam::kTypeWimax));
1978 dictionary->SetBoolean(kTagWimaxEnabled, 1969 dictionary->SetBoolean(kTagWimaxEnabled,
1979 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); 1970 handler->IsTechnologyEnabled(flimflam::kTypeWimax));
1980 } 1971 }
1981 1972
1982 } // namespace options 1973 } // namespace options
1983 } // namespace chromeos 1974 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698