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

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

Issue 23712002: Cleanup network type matching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests and rebased. Created 7 years, 3 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "chromeos/network/network_device_handler.h" 56 #include "chromeos/network/network_device_handler.h"
57 #include "chromeos/network/network_event_log.h" 57 #include "chromeos/network/network_event_log.h"
58 #include "chromeos/network/network_ip_config.h" 58 #include "chromeos/network/network_ip_config.h"
59 #include "chromeos/network/network_profile.h" 59 #include "chromeos/network/network_profile.h"
60 #include "chromeos/network/network_profile_handler.h" 60 #include "chromeos/network/network_profile_handler.h"
61 #include "chromeos/network/network_state.h" 61 #include "chromeos/network/network_state.h"
62 #include "chromeos/network/network_state_handler.h" 62 #include "chromeos/network/network_state_handler.h"
63 #include "chromeos/network/network_ui_data.h" 63 #include "chromeos/network/network_ui_data.h"
64 #include "chromeos/network/network_util.h" 64 #include "chromeos/network/network_util.h"
65 #include "chromeos/network/onc/onc_constants.h" 65 #include "chromeos/network/onc/onc_constants.h"
66 #include "chromeos/network/shill_property_util.h"
66 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
67 #include "content/public/browser/web_contents.h" 68 #include "content/public/browser/web_contents.h"
68 #include "content/public/browser/web_contents_view.h" 69 #include "content/public/browser/web_contents_view.h"
69 #include "content/public/browser/web_ui.h" 70 #include "content/public/browser/web_ui.h"
70 #include "grit/ash_resources.h" 71 #include "grit/ash_resources.h"
71 #include "grit/ash_strings.h" 72 #include "grit/ash_strings.h"
72 #include "grit/chromium_strings.h" 73 #include "grit/chromium_strings.h"
73 #include "grit/generated_resources.h" 74 #include "grit/generated_resources.h"
74 #include "grit/locale_settings.h" 75 #include "grit/locale_settings.h"
75 #include "grit/theme_resources.h" 76 #include "grit/theme_resources.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 : service_path_(network->path()), 432 : service_path_(network->path()),
432 name_(network->name()), 433 name_(network->name()),
433 connecting_(network->IsConnectingState()), 434 connecting_(network->IsConnectingState()),
434 connected_(network->IsConnectedState()), 435 connected_(network->IsConnectedState()),
435 connectable_(network->connectable()), 436 connectable_(network->connectable()),
436 connection_type_(network->type()), 437 connection_type_(network->type()),
437 remembered_(false), 438 remembered_(false),
438 shared_(false), 439 shared_(false),
439 activation_state_(network->activation_state()), 440 activation_state_(network->activation_state()),
440 policy_managed_(network->IsManaged()) { 441 policy_managed_(network->IsManaged()) {
441 if (network->type() == flimflam::kTypeEthernet) 442 if (network->Matches(NetworkTypePattern::Ethernet()))
442 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 443 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
443 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( 444 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork(
444 network, ash::network_icon::ICON_TYPE_LIST); 445 network, ash::network_icon::ICON_TYPE_LIST);
445 SetIcon(icon, icon_scale_factor); 446 SetIcon(icon, icon_scale_factor);
446 } 447 }
447 448
448 NetworkInfoDictionary::NetworkInfoDictionary(const FavoriteState* favorite, 449 NetworkInfoDictionary::NetworkInfoDictionary(const FavoriteState* favorite,
449 ui::ScaleFactor icon_scale_factor) 450 ui::ScaleFactor icon_scale_factor)
450 : service_path_(favorite->path()), 451 : service_path_(favorite->path()),
451 name_(favorite->name()), 452 name_(favorite->name()),
452 connecting_(false), 453 connecting_(false),
453 connected_(false), 454 connected_(false),
454 connectable_(false), 455 connectable_(false),
455 connection_type_(favorite->type()), 456 connection_type_(favorite->type()),
456 remembered_(true), 457 remembered_(true),
457 shared_(!favorite->IsPrivate()), 458 shared_(!favorite->IsPrivate()),
458 policy_managed_(favorite->IsManaged()) { 459 policy_managed_(favorite->IsManaged()) {
459 if (favorite->type() == flimflam::kTypeEthernet) 460 if (favorite->Matches(NetworkTypePattern::Ethernet()))
460 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 461 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
461 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( 462 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork(
462 ash::network_icon::ICON_TYPE_LIST, favorite->type()); 463 ash::network_icon::ICON_TYPE_LIST, favorite->type());
463 SetIcon(icon, icon_scale_factor); 464 SetIcon(icon, icon_scale_factor);
464 } 465 }
465 466
466 base::DictionaryValue* NetworkInfoDictionary::BuildDictionary() { 467 base::DictionaryValue* NetworkInfoDictionary::BuildDictionary() {
467 std::string status; 468 std::string status;
468 if (remembered_) { 469 if (remembered_) {
469 if (shared_) 470 if (shared_)
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 std::string provider_host; 664 std::string provider_host;
664 provider_properties->GetStringWithoutPathExpansion( 665 provider_properties->GetStringWithoutPathExpansion(
665 flimflam::kHostProperty, &provider_host); 666 flimflam::kHostProperty, &provider_host);
666 SetValueDictionary(dictionary, kTagServerHostname, 667 SetValueDictionary(dictionary, kTagServerHostname,
667 new base::StringValue(provider_host), 668 new base::StringValue(provider_host),
668 hostname_ui_data); 669 hostname_ui_data);
669 670
670 // Disable 'Connect' for VPN unless connected to a non-VPN network. 671 // Disable 'Connect' for VPN unless connected to a non-VPN network.
671 const NetworkState* connected_network = 672 const NetworkState* connected_network =
672 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 673 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
673 NetworkStateHandler::kMatchTypeNonVirtual); 674 NetworkTypePattern::NonVirtual());
674 dictionary->SetBoolean(kTagDisableConnectButton, !connected_network); 675 dictionary->SetBoolean(kTagDisableConnectButton, !connected_network);
675 } 676 }
676 677
677 // Given a list of supported carrier's by the device, return the index of 678 // Given a list of supported carrier's by the device, return the index of
678 // the carrier the device is currently using. 679 // the carrier the device is currently using.
679 int FindCurrentCarrierIndex(const base::ListValue* carriers, 680 int FindCurrentCarrierIndex(const base::ListValue* carriers,
680 const DeviceState* device) { 681 const DeviceState* device) {
681 DCHECK(carriers); 682 DCHECK(carriers);
682 DCHECK(device); 683 DCHECK(device);
683 bool gsm = (device->technology_family() == flimflam::kTechnologyFamilyGsm); 684 bool gsm = (device->technology_family() == flimflam::kTechnologyFamilyGsm);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 web_ui()->RegisterMessageCallback(kChangePinMessage, 1023 web_ui()->RegisterMessageCallback(kChangePinMessage,
1023 base::Bind(&InternetOptionsHandler::ChangePinCallback, 1024 base::Bind(&InternetOptionsHandler::ChangePinCallback,
1024 base::Unretained(this))); 1025 base::Unretained(this)));
1025 web_ui()->RegisterMessageCallback(kSetServerHostname, 1026 web_ui()->RegisterMessageCallback(kSetServerHostname,
1026 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback, 1027 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback,
1027 base::Unretained(this))); 1028 base::Unretained(this)));
1028 } 1029 }
1029 1030
1030 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) { 1031 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) {
1031 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1032 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1032 flimflam::kTypeWifi, true, 1033 NetworkTypePattern::WiFi(), true,
1033 base::Bind(&ShillError, "EnableWifiCallback")); 1034 base::Bind(&ShillError, "EnableWifiCallback"));
1034 } 1035 }
1035 1036
1036 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) { 1037 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) {
1037 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1038 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1038 flimflam::kTypeWifi, false, 1039 NetworkTypePattern::WiFi(), false,
1039 base::Bind(&ShillError, "DisableWifiCallback")); 1040 base::Bind(&ShillError, "DisableWifiCallback"));
1040 } 1041 }
1041 1042
1042 void InternetOptionsHandler::EnableCellularCallback( 1043 void InternetOptionsHandler::EnableCellularCallback(
1043 const base::ListValue* args) { 1044 const base::ListValue* args) {
1044 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1045 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1045 const DeviceState* device = 1046 const DeviceState* device =
1046 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1047 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1047 if (!device) { 1048 if (!device) {
1048 LOG(ERROR) << "Mobile device not found."; 1049 LOG(ERROR) << "Mobile device not found.";
1049 return; 1050 return;
1050 } 1051 }
1051 if (!device->sim_lock_type().empty()) { 1052 if (!device->sim_lock_type().empty()) {
1052 SimDialogDelegate::ShowDialog(GetNativeWindow(), 1053 SimDialogDelegate::ShowDialog(GetNativeWindow(),
1053 SimDialogDelegate::SIM_DIALOG_UNLOCK); 1054 SimDialogDelegate::SIM_DIALOG_UNLOCK);
1054 return; 1055 return;
1055 } 1056 }
1056 if (!handler->IsTechnologyEnabled(flimflam::kTypeCellular)) { 1057 if (!handler->IsTechnologyEnabled(NetworkTypePattern::Cellular())) {
1057 handler->SetTechnologyEnabled( 1058 handler->SetTechnologyEnabled(
1058 flimflam::kTypeCellular, true, 1059 NetworkTypePattern::Cellular(), true,
1059 base::Bind(&ShillError, "EnableCellularCallback")); 1060 base::Bind(&ShillError, "EnableCellularCallback"));
1060 return; 1061 return;
1061 } 1062 }
1062 if (device->IsSimAbsent()) { 1063 if (device->IsSimAbsent()) {
1063 MobileConfig* config = MobileConfig::GetInstance(); 1064 MobileConfig* config = MobileConfig::GetInstance();
1064 if (config->IsReady()) { 1065 if (config->IsReady()) {
1065 const MobileConfig::LocaleConfig* locale_config = 1066 const MobileConfig::LocaleConfig* locale_config =
1066 config->GetLocaleConfig(); 1067 config->GetLocaleConfig();
1067 if (locale_config) { 1068 if (locale_config) {
1068 std::string setup_url = locale_config->setup_url(); 1069 std::string setup_url = locale_config->setup_url();
1069 if (!setup_url.empty()) { 1070 if (!setup_url.empty()) {
1070 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url)); 1071 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url));
1071 return; 1072 return;
1072 } 1073 }
1073 } 1074 }
1074 } 1075 }
1075 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444 1076 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444
1076 } 1077 }
1077 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device"; 1078 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device";
1078 } 1079 }
1079 1080
1080 void InternetOptionsHandler::DisableCellularCallback( 1081 void InternetOptionsHandler::DisableCellularCallback(
1081 const base::ListValue* args) { 1082 const base::ListValue* args) {
1082 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1083 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1083 NetworkStateHandler::kMatchTypeMobile, false, 1084 NetworkTypePattern::Mobile(), false,
1084 base::Bind(&ShillError, "DisableCellularCallback")); 1085 base::Bind(&ShillError, "DisableCellularCallback"));
1085 } 1086 }
1086 1087
1087 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) { 1088 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) {
1088 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1089 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1089 flimflam::kTypeWimax, true, 1090 NetworkTypePattern::Wimax(), true,
1090 base::Bind(&ShillError, "EnableWimaxCallback")); 1091 base::Bind(&ShillError, "EnableWimaxCallback"));
1091 } 1092 }
1092 1093
1093 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) { 1094 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) {
1094 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1095 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1095 flimflam::kTypeWimax, false, 1096 NetworkTypePattern::Wimax(), false,
1096 base::Bind(&ShillError, "DisableWimaxCallback")); 1097 base::Bind(&ShillError, "DisableWimaxCallback"));
1097 } 1098 }
1098 1099
1099 void InternetOptionsHandler::ShowMorePlanInfoCallback( 1100 void InternetOptionsHandler::ShowMorePlanInfoCallback(
1100 const base::ListValue* args) { 1101 const base::ListValue* args) {
1101 if (!web_ui()) 1102 if (!web_ui())
1102 return; 1103 return;
1103 std::string service_path; 1104 std::string service_path;
1104 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 1105 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
1105 NOTREACHED(); 1106 NOTREACHED();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict); 1175 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict);
1175 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 1176 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
1176 service_path, properties, 1177 service_path, properties,
1177 base::Bind(&base::DoNothing), 1178 base::Bind(&base::DoNothing),
1178 base::Bind(&ShillError, "SetApnProperties")); 1179 base::Bind(&ShillError, "SetApnProperties"));
1179 } 1180 }
1180 1181
1181 void InternetOptionsHandler::CarrierStatusCallback() { 1182 void InternetOptionsHandler::CarrierStatusCallback() {
1182 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1183 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1183 const DeviceState* device = 1184 const DeviceState* device =
1184 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1185 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1185 if (device && (device->carrier() == shill::kCarrierSprint)) { 1186 if (device && (device->carrier() == shill::kCarrierSprint)) {
1186 const NetworkState* network = 1187 const NetworkState* network =
1187 handler->FirstNetworkByType(flimflam::kTypeCellular); 1188 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
1188 if (network) { 1189 if (network) {
1189 ash::network_connect::ActivateCellular(network->path()); 1190 ash::network_connect::ActivateCellular(network->path());
1190 UpdateConnectionData(network->path()); 1191 UpdateConnectionData(network->path());
1191 } 1192 }
1192 } 1193 }
1193 UpdateCarrier(); 1194 UpdateCarrier();
1194 } 1195 }
1195 1196
1196 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 1197 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
1197 std::string service_path; 1198 std::string service_path;
1198 std::string carrier; 1199 std::string carrier;
1199 if (args->GetSize() != 2 || 1200 if (args->GetSize() != 2 ||
1200 !args->GetString(0, &service_path) || 1201 !args->GetString(0, &service_path) ||
1201 !args->GetString(1, &carrier)) { 1202 !args->GetString(1, &carrier)) {
1202 NOTREACHED(); 1203 NOTREACHED();
1203 return; 1204 return;
1204 } 1205 }
1205 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 1206 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
1206 GetDeviceStateByType(flimflam::kTypeCellular); 1207 GetDeviceStateByType(NetworkTypePattern::Cellular());
1207 if (!device) { 1208 if (!device) {
1208 LOG(WARNING) << "SetCarrierCallback with no cellular device."; 1209 LOG(WARNING) << "SetCarrierCallback with no cellular device.";
1209 return; 1210 return;
1210 } 1211 }
1211 NetworkHandler::Get()->network_device_handler()->SetCarrier( 1212 NetworkHandler::Get()->network_device_handler()->SetCarrier(
1212 device->path(), 1213 device->path(),
1213 carrier, 1214 carrier,
1214 base::Bind(&InternetOptionsHandler::CarrierStatusCallback, 1215 base::Bind(&InternetOptionsHandler::CarrierStatusCallback,
1215 weak_factory_.GetWeakPtr()), 1216 weak_factory_.GetWeakPtr()),
1216 base::Bind(&ShillError, "SetCarrierCallback")); 1217 base::Bind(&ShillError, "SetCarrierCallback"));
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 std::string type = network->type(); 1547 std::string type = network->type();
1547 dictionary.SetString(kTagType, type); 1548 dictionary.SetString(kTagType, type);
1548 dictionary.SetString(kTagServicePath, network->path()); 1549 dictionary.SetString(kTagServicePath, network->path());
1549 dictionary.SetString(kTagNameServerType, name_server_type); 1550 dictionary.SetString(kTagNameServerType, name_server_type);
1550 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers); 1551 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers);
1551 1552
1552 // Only show proxy for remembered networks. 1553 // Only show proxy for remembered networks.
1553 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty()); 1554 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty());
1554 1555
1555 // Enable static ip config for ethernet. For wifi, enable if flag is set. 1556 // Enable static ip config for ethernet. For wifi, enable if flag is set.
1556 bool staticIPConfig = type == flimflam::kTypeEthernet || 1557 bool staticIPConfig = network->Matches(NetworkTypePattern::Ethernet()) ||
1557 (type == flimflam::kTypeWifi && 1558 (type == flimflam::kTypeWifi &&
1558 CommandLine::ForCurrentProcess()->HasSwitch( 1559 CommandLine::ForCurrentProcess()->HasSwitch(
1559 chromeos::switches::kEnableStaticIPConfig)); 1560 chromeos::switches::kEnableStaticIPConfig));
1560 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig); 1561 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig);
1561 1562
1562 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty()); 1563 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty());
1563 bool preferred = network->priority() > 0; 1564 bool preferred = network->priority() > 0;
1564 SetValueDictionary(&dictionary, kTagPreferred, 1565 SetValueDictionary(&dictionary, kTagPreferred,
1565 new base::FundamentalValue(preferred), 1566 new base::FundamentalValue(preferred),
1566 property_ui_data); 1567 property_ui_data);
1567 1568
1568 NetworkPropertyUIData auto_connect_ui_data(onc_source); 1569 NetworkPropertyUIData auto_connect_ui_data(onc_source);
1569 std::string onc_path_to_auto_connect; 1570 std::string onc_path_to_auto_connect;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 dictionary->SetString(kTagErrorState, 1608 dictionary->SetString(kTagErrorState,
1608 ash::network_connect::ErrorString(network->error())); 1609 ash::network_connect::ErrorString(network->error()));
1609 1610
1610 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); 1611 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty());
1611 bool shared = !network->IsPrivate(); 1612 bool shared = !network->IsPrivate();
1612 dictionary->SetBoolean(kTagShared, shared); 1613 dictionary->SetBoolean(kTagShared, shared);
1613 1614
1614 const std::string& type = network->type(); 1615 const std::string& type = network->type();
1615 const NetworkState* connected_network = 1616 const NetworkState* connected_network =
1616 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 1617 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
1617 type); 1618 NetworkTypePattern::Primitive(type));
1618 1619
1619 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); 1620 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL);
1620 1621
1621 if (type == flimflam::kTypeWifi) 1622 if (type == flimflam::kTypeWifi)
1622 PopulateWifiDetails(network, shill_properties, dictionary); 1623 PopulateWifiDetails(network, shill_properties, dictionary);
1623 else if (type == flimflam::kTypeWimax) 1624 else if (type == flimflam::kTypeWimax)
1624 PopulateWimaxDetails(network, shill_properties, dictionary); 1625 PopulateWimaxDetails(network, shill_properties, dictionary);
1625 else if (type == flimflam::kTypeCellular) 1626 else if (type == flimflam::kTypeCellular)
1626 PopulateCellularDetails(network, shill_properties, dictionary); 1627 PopulateCellularDetails(network, shill_properties, dictionary);
1627 else if (type == flimflam::kTypeVPN) 1628 else if (type == flimflam::kTypeVPN)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow()); 1932 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
1932 else if (type == flimflam::kTypeCellular) 1933 else if (type == flimflam::kTypeCellular)
1933 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 1934 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
1934 else 1935 else
1935 NOTREACHED(); 1936 NOTREACHED();
1936 } 1937 }
1937 1938
1938 base::ListValue* InternetOptionsHandler::GetWiredList() { 1939 base::ListValue* InternetOptionsHandler::GetWiredList() {
1939 base::ListValue* list = new base::ListValue(); 1940 base::ListValue* list = new base::ListValue();
1940 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 1941 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
1941 FirstNetworkByType(flimflam::kTypeEthernet); 1942 FirstNetworkByType(NetworkTypePattern::Ethernet());
1942 if (!network) 1943 if (!network)
1943 return list; 1944 return list;
1944 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor()); 1945 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor());
1945 list->Append(network_dict.BuildDictionary()); 1946 list->Append(network_dict.BuildDictionary());
1946 return list; 1947 return list;
1947 } 1948 }
1948 1949
1949 base::ListValue* InternetOptionsHandler::GetWirelessList() { 1950 base::ListValue* InternetOptionsHandler::GetWirelessList() {
1950 base::ListValue* list = new base::ListValue(); 1951 base::ListValue* list = new base::ListValue();
1951 1952
1952 NetworkStateHandler::NetworkStateList networks; 1953 NetworkStateHandler::NetworkStateList networks;
1953 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 1954 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
1955 NetworkTypePattern::Wireless(), &networks);
1954 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 1956 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
1955 networks.begin(); iter != networks.end(); ++iter) { 1957 networks.begin(); iter != networks.end(); ++iter) {
1956 const NetworkState* network = *iter; 1958 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
1957 if (network->type() != flimflam::kTypeWifi &&
1958 network->type() != flimflam::kTypeWimax &&
1959 network->type() != flimflam::kTypeCellular)
1960 continue;
1961 NetworkInfoDictionary network_dict(
1962 network, web_ui()->GetDeviceScaleFactor());
1963 list->Append(network_dict.BuildDictionary()); 1959 list->Append(network_dict.BuildDictionary());
1964 } 1960 }
1965 1961
1966 return list; 1962 return list;
1967 } 1963 }
1968 1964
1969 base::ListValue* InternetOptionsHandler::GetVPNList() { 1965 base::ListValue* InternetOptionsHandler::GetVPNList() {
1970 base::ListValue* list = new base::ListValue(); 1966 base::ListValue* list = new base::ListValue();
1971 1967
1972 NetworkStateHandler::NetworkStateList networks; 1968 NetworkStateHandler::NetworkStateList networks;
1973 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 1969 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
1970 NetworkTypePattern::VPN(), &networks);
1974 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 1971 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
1975 networks.begin(); iter != networks.end(); ++iter) { 1972 networks.begin(); iter != networks.end(); ++iter) {
1976 const NetworkState* network = *iter; 1973 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
1977 if (network->type() != flimflam::kTypeVPN)
1978 continue;
1979 NetworkInfoDictionary network_dict(
1980 network, web_ui()->GetDeviceScaleFactor());
1981 list->Append(network_dict.BuildDictionary()); 1974 list->Append(network_dict.BuildDictionary());
1982 } 1975 }
1983 1976
1984 return list; 1977 return list;
1985 } 1978 }
1986 1979
1987 base::ListValue* InternetOptionsHandler::GetRememberedList() { 1980 base::ListValue* InternetOptionsHandler::GetRememberedList() {
1988 base::ListValue* list = new base::ListValue(); 1981 base::ListValue* list = new base::ListValue();
1989 1982
1990 NetworkStateHandler::FavoriteStateList favorites; 1983 NetworkStateHandler::FavoriteStateList favorites;
(...skipping 13 matching lines...) Expand all
2004 } 1997 }
2005 1998
2006 void InternetOptionsHandler::FillNetworkInfo( 1999 void InternetOptionsHandler::FillNetworkInfo(
2007 base::DictionaryValue* dictionary) { 2000 base::DictionaryValue* dictionary) {
2008 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 2001 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
2009 dictionary->Set(kTagWiredList, GetWiredList()); 2002 dictionary->Set(kTagWiredList, GetWiredList());
2010 dictionary->Set(kTagWirelessList, GetWirelessList()); 2003 dictionary->Set(kTagWirelessList, GetWirelessList());
2011 dictionary->Set(kTagVpnList, GetVPNList()); 2004 dictionary->Set(kTagVpnList, GetVPNList());
2012 dictionary->Set(kTagRememberedList, GetRememberedList()); 2005 dictionary->Set(kTagRememberedList, GetRememberedList());
2013 2006
2014 dictionary->SetBoolean(kTagWifiAvailable, 2007 dictionary->SetBoolean(
2015 handler->IsTechnologyAvailable(flimflam::kTypeWifi)); 2008 kTagWifiAvailable,
2016 dictionary->SetBoolean(kTagWifiEnabled, 2009 handler->IsTechnologyAvailable(NetworkTypePattern::WiFi()));
2017 handler->IsTechnologyEnabled(flimflam::kTypeWifi)); 2010 dictionary->SetBoolean(
2011 kTagWifiEnabled,
2012 handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
2018 2013
2019 dictionary->SetBoolean(kTagCellularAvailable, 2014 dictionary->SetBoolean(
2020 handler->IsTechnologyAvailable( 2015 kTagCellularAvailable,
2021 NetworkStateHandler::kMatchTypeMobile)); 2016 handler->IsTechnologyAvailable(NetworkTypePattern::Mobile()));
2022 dictionary->SetBoolean(kTagCellularEnabled, 2017 dictionary->SetBoolean(
2023 handler->IsTechnologyEnabled( 2018 kTagCellularEnabled,
2024 NetworkStateHandler::kMatchTypeMobile)); 2019 handler->IsTechnologyEnabled(NetworkTypePattern::Mobile()));
2025 const DeviceState* cellular = 2020 const DeviceState* cellular =
2026 handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile); 2021 handler->GetDeviceStateByType(NetworkTypePattern::Mobile());
2027 dictionary->SetBoolean( 2022 dictionary->SetBoolean(
2028 kTagCellularSupportsScan, 2023 kTagCellularSupportsScan,
2029 cellular && cellular->support_network_scan()); 2024 cellular && cellular->support_network_scan());
2030 2025
2031 dictionary->SetBoolean(kTagWimaxAvailable, 2026 dictionary->SetBoolean(
2032 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); 2027 kTagWimaxAvailable,
2033 dictionary->SetBoolean(kTagWimaxEnabled, 2028 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
2034 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); 2029 dictionary->SetBoolean(
2030 kTagWimaxEnabled,
2031 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
2035 } 2032 }
2036 2033
2037 } // namespace options 2034 } // namespace options
2038 } // namespace chromeos 2035 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698