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

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: Fixed unit test in Debug. 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
« no previous file with comments | « chrome/browser/ui/webui/help/help_utils_chromeos.cc ('k') | chromeos/chromeos.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 : service_path_(network->path()), 458 : service_path_(network->path()),
458 name_(network->name()), 459 name_(network->name()),
459 connecting_(network->IsConnectingState()), 460 connecting_(network->IsConnectingState()),
460 connected_(network->IsConnectedState()), 461 connected_(network->IsConnectedState()),
461 connectable_(network->connectable()), 462 connectable_(network->connectable()),
462 connection_type_(network->type()), 463 connection_type_(network->type()),
463 remembered_(false), 464 remembered_(false),
464 shared_(false), 465 shared_(false),
465 activation_state_(network->activation_state()), 466 activation_state_(network->activation_state()),
466 policy_managed_(network->IsManaged()) { 467 policy_managed_(network->IsManaged()) {
467 if (network->type() == flimflam::kTypeEthernet) 468 if (network->Matches(NetworkTypePattern::Ethernet()))
468 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 469 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
469 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork( 470 gfx::ImageSkia icon = ash::network_icon::GetImageForNetwork(
470 network, ash::network_icon::ICON_TYPE_LIST); 471 network, ash::network_icon::ICON_TYPE_LIST);
471 SetIcon(icon, icon_scale_factor); 472 SetIcon(icon, icon_scale_factor);
472 } 473 }
473 474
474 NetworkInfoDictionary::NetworkInfoDictionary(const FavoriteState* favorite, 475 NetworkInfoDictionary::NetworkInfoDictionary(const FavoriteState* favorite,
475 ui::ScaleFactor icon_scale_factor) 476 ui::ScaleFactor icon_scale_factor)
476 : service_path_(favorite->path()), 477 : service_path_(favorite->path()),
477 name_(favorite->name()), 478 name_(favorite->name()),
478 connecting_(false), 479 connecting_(false),
479 connected_(false), 480 connected_(false),
480 connectable_(false), 481 connectable_(false),
481 connection_type_(favorite->type()), 482 connection_type_(favorite->type()),
482 remembered_(true), 483 remembered_(true),
483 shared_(!favorite->IsPrivate()), 484 shared_(!favorite->IsPrivate()),
484 policy_managed_(favorite->IsManaged()) { 485 policy_managed_(favorite->IsManaged()) {
485 if (favorite->type() == flimflam::kTypeEthernet) 486 if (favorite->Matches(NetworkTypePattern::Ethernet()))
486 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET); 487 name_ = l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
487 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork( 488 gfx::ImageSkia icon = ash::network_icon::GetImageForDisconnectedNetwork(
488 ash::network_icon::ICON_TYPE_LIST, favorite->type()); 489 ash::network_icon::ICON_TYPE_LIST, favorite->type());
489 SetIcon(icon, icon_scale_factor); 490 SetIcon(icon, icon_scale_factor);
490 } 491 }
491 492
492 base::DictionaryValue* NetworkInfoDictionary::BuildDictionary() { 493 base::DictionaryValue* NetworkInfoDictionary::BuildDictionary() {
493 std::string status; 494 std::string status;
494 if (remembered_) { 495 if (remembered_) {
495 if (shared_) 496 if (shared_)
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 std::string provider_host; 690 std::string provider_host;
690 provider_properties->GetStringWithoutPathExpansion( 691 provider_properties->GetStringWithoutPathExpansion(
691 flimflam::kHostProperty, &provider_host); 692 flimflam::kHostProperty, &provider_host);
692 SetValueDictionary(dictionary, kTagServerHostname, 693 SetValueDictionary(dictionary, kTagServerHostname,
693 new base::StringValue(provider_host), 694 new base::StringValue(provider_host),
694 hostname_ui_data); 695 hostname_ui_data);
695 696
696 // Disable 'Connect' for VPN unless connected to a non-VPN network. 697 // Disable 'Connect' for VPN unless connected to a non-VPN network.
697 const NetworkState* connected_network = 698 const NetworkState* connected_network =
698 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 699 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
699 NetworkStateHandler::kMatchTypeNonVirtual); 700 NetworkTypePattern::NonVirtual());
700 dictionary->SetBoolean(kTagDisableConnectButton, !connected_network); 701 dictionary->SetBoolean(kTagDisableConnectButton, !connected_network);
701 } 702 }
702 703
703 // Given a list of supported carrier's by the device, return the index of 704 // Given a list of supported carrier's by the device, return the index of
704 // the carrier the device is currently using. 705 // the carrier the device is currently using.
705 int FindCurrentCarrierIndex(const base::ListValue* carriers, 706 int FindCurrentCarrierIndex(const base::ListValue* carriers,
706 const DeviceState* device) { 707 const DeviceState* device) {
707 DCHECK(carriers); 708 DCHECK(carriers);
708 DCHECK(device); 709 DCHECK(device);
709 bool gsm = (device->technology_family() == flimflam::kTechnologyFamilyGsm); 710 bool gsm = (device->technology_family() == flimflam::kTechnologyFamilyGsm);
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 web_ui()->RegisterMessageCallback(kChangePinMessage, 1053 web_ui()->RegisterMessageCallback(kChangePinMessage,
1053 base::Bind(&InternetOptionsHandler::ChangePinCallback, 1054 base::Bind(&InternetOptionsHandler::ChangePinCallback,
1054 base::Unretained(this))); 1055 base::Unretained(this)));
1055 web_ui()->RegisterMessageCallback(kSetServerHostname, 1056 web_ui()->RegisterMessageCallback(kSetServerHostname,
1056 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback, 1057 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback,
1057 base::Unretained(this))); 1058 base::Unretained(this)));
1058 } 1059 }
1059 1060
1060 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) { 1061 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) {
1061 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1062 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1062 flimflam::kTypeWifi, true, 1063 NetworkTypePattern::WiFi(), true,
1063 base::Bind(&ShillError, "EnableWifiCallback")); 1064 base::Bind(&ShillError, "EnableWifiCallback"));
1064 } 1065 }
1065 1066
1066 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) { 1067 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) {
1067 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1068 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1068 flimflam::kTypeWifi, false, 1069 NetworkTypePattern::WiFi(), false,
1069 base::Bind(&ShillError, "DisableWifiCallback")); 1070 base::Bind(&ShillError, "DisableWifiCallback"));
1070 } 1071 }
1071 1072
1072 void InternetOptionsHandler::EnableCellularCallback( 1073 void InternetOptionsHandler::EnableCellularCallback(
1073 const base::ListValue* args) { 1074 const base::ListValue* args) {
1074 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1075 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1075 const DeviceState* device = 1076 const DeviceState* device =
1076 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1077 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1077 if (!device) { 1078 if (!device) {
1078 LOG(ERROR) << "Mobile device not found."; 1079 LOG(ERROR) << "Mobile device not found.";
1079 return; 1080 return;
1080 } 1081 }
1081 if (!device->sim_lock_type().empty()) { 1082 if (!device->sim_lock_type().empty()) {
1082 SimDialogDelegate::ShowDialog(GetNativeWindow(), 1083 SimDialogDelegate::ShowDialog(GetNativeWindow(),
1083 SimDialogDelegate::SIM_DIALOG_UNLOCK); 1084 SimDialogDelegate::SIM_DIALOG_UNLOCK);
1084 return; 1085 return;
1085 } 1086 }
1086 if (!handler->IsTechnologyEnabled(flimflam::kTypeCellular)) { 1087 if (!handler->IsTechnologyEnabled(NetworkTypePattern::Cellular())) {
1087 handler->SetTechnologyEnabled( 1088 handler->SetTechnologyEnabled(
1088 flimflam::kTypeCellular, true, 1089 NetworkTypePattern::Cellular(), true,
1089 base::Bind(&ShillError, "EnableCellularCallback")); 1090 base::Bind(&ShillError, "EnableCellularCallback"));
1090 return; 1091 return;
1091 } 1092 }
1092 if (device->IsSimAbsent()) { 1093 if (device->IsSimAbsent()) {
1093 MobileConfig* config = MobileConfig::GetInstance(); 1094 MobileConfig* config = MobileConfig::GetInstance();
1094 if (config->IsReady()) { 1095 if (config->IsReady()) {
1095 const MobileConfig::LocaleConfig* locale_config = 1096 const MobileConfig::LocaleConfig* locale_config =
1096 config->GetLocaleConfig(); 1097 config->GetLocaleConfig();
1097 if (locale_config) { 1098 if (locale_config) {
1098 std::string setup_url = locale_config->setup_url(); 1099 std::string setup_url = locale_config->setup_url();
1099 if (!setup_url.empty()) { 1100 if (!setup_url.empty()) {
1100 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url)); 1101 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url));
1101 return; 1102 return;
1102 } 1103 }
1103 } 1104 }
1104 } 1105 }
1105 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444 1106 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444
1106 } 1107 }
1107 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device"; 1108 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device";
1108 } 1109 }
1109 1110
1110 void InternetOptionsHandler::DisableCellularCallback( 1111 void InternetOptionsHandler::DisableCellularCallback(
1111 const base::ListValue* args) { 1112 const base::ListValue* args) {
1112 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1113 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1113 NetworkStateHandler::kMatchTypeMobile, false, 1114 NetworkTypePattern::Mobile(), false,
1114 base::Bind(&ShillError, "DisableCellularCallback")); 1115 base::Bind(&ShillError, "DisableCellularCallback"));
1115 } 1116 }
1116 1117
1117 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) { 1118 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) {
1118 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1119 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1119 flimflam::kTypeWimax, true, 1120 NetworkTypePattern::Wimax(), true,
1120 base::Bind(&ShillError, "EnableWimaxCallback")); 1121 base::Bind(&ShillError, "EnableWimaxCallback"));
1121 } 1122 }
1122 1123
1123 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) { 1124 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) {
1124 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1125 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1125 flimflam::kTypeWimax, false, 1126 NetworkTypePattern::Wimax(), false,
1126 base::Bind(&ShillError, "DisableWimaxCallback")); 1127 base::Bind(&ShillError, "DisableWimaxCallback"));
1127 } 1128 }
1128 1129
1129 void InternetOptionsHandler::ShowMorePlanInfoCallback( 1130 void InternetOptionsHandler::ShowMorePlanInfoCallback(
1130 const base::ListValue* args) { 1131 const base::ListValue* args) {
1131 if (!web_ui()) 1132 if (!web_ui())
1132 return; 1133 return;
1133 std::string service_path; 1134 std::string service_path;
1134 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 1135 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
1135 NOTREACHED(); 1136 NOTREACHED();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict); 1205 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict);
1205 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 1206 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
1206 service_path, properties, 1207 service_path, properties,
1207 base::Bind(&base::DoNothing), 1208 base::Bind(&base::DoNothing),
1208 base::Bind(&ShillError, "SetApnProperties")); 1209 base::Bind(&ShillError, "SetApnProperties"));
1209 } 1210 }
1210 1211
1211 void InternetOptionsHandler::CarrierStatusCallback() { 1212 void InternetOptionsHandler::CarrierStatusCallback() {
1212 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1213 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1213 const DeviceState* device = 1214 const DeviceState* device =
1214 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1215 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1215 if (device && (device->carrier() == shill::kCarrierSprint)) { 1216 if (device && (device->carrier() == shill::kCarrierSprint)) {
1216 const NetworkState* network = 1217 const NetworkState* network =
1217 handler->FirstNetworkByType(flimflam::kTypeCellular); 1218 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
1218 if (network) { 1219 if (network) {
1219 ash::network_connect::ActivateCellular(network->path()); 1220 ash::network_connect::ActivateCellular(network->path());
1220 UpdateConnectionData(network->path()); 1221 UpdateConnectionData(network->path());
1221 } 1222 }
1222 } 1223 }
1223 UpdateCarrier(); 1224 UpdateCarrier();
1224 } 1225 }
1225 1226
1226 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 1227 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
1227 std::string service_path; 1228 std::string service_path;
1228 std::string carrier; 1229 std::string carrier;
1229 if (args->GetSize() != 2 || 1230 if (args->GetSize() != 2 ||
1230 !args->GetString(0, &service_path) || 1231 !args->GetString(0, &service_path) ||
1231 !args->GetString(1, &carrier)) { 1232 !args->GetString(1, &carrier)) {
1232 NOTREACHED(); 1233 NOTREACHED();
1233 return; 1234 return;
1234 } 1235 }
1235 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 1236 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
1236 GetDeviceStateByType(flimflam::kTypeCellular); 1237 GetDeviceStateByType(NetworkTypePattern::Cellular());
1237 if (!device) { 1238 if (!device) {
1238 LOG(WARNING) << "SetCarrierCallback with no cellular device."; 1239 LOG(WARNING) << "SetCarrierCallback with no cellular device.";
1239 return; 1240 return;
1240 } 1241 }
1241 NetworkHandler::Get()->network_device_handler()->SetCarrier( 1242 NetworkHandler::Get()->network_device_handler()->SetCarrier(
1242 device->path(), 1243 device->path(),
1243 carrier, 1244 carrier,
1244 base::Bind(&InternetOptionsHandler::CarrierStatusCallback, 1245 base::Bind(&InternetOptionsHandler::CarrierStatusCallback,
1245 weak_factory_.GetWeakPtr()), 1246 weak_factory_.GetWeakPtr()),
1246 base::Bind(&ShillError, "SetCarrierCallback")); 1247 base::Bind(&ShillError, "SetCarrierCallback"));
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 std::string type = network->type(); 1591 std::string type = network->type();
1591 dictionary.SetString(kTagType, type); 1592 dictionary.SetString(kTagType, type);
1592 dictionary.SetString(kTagServicePath, network->path()); 1593 dictionary.SetString(kTagServicePath, network->path());
1593 dictionary.SetString(kTagNameServerType, name_server_type); 1594 dictionary.SetString(kTagNameServerType, name_server_type);
1594 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers); 1595 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers);
1595 1596
1596 // Only show proxy for remembered networks. 1597 // Only show proxy for remembered networks.
1597 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty()); 1598 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty());
1598 1599
1599 // Enable static ip config for ethernet. For wifi, enable if flag is set. 1600 // Enable static ip config for ethernet. For wifi, enable if flag is set.
1600 bool staticIPConfig = type == flimflam::kTypeEthernet || 1601 bool staticIPConfig = network->Matches(NetworkTypePattern::Ethernet()) ||
1601 (type == flimflam::kTypeWifi && 1602 (type == flimflam::kTypeWifi &&
1602 CommandLine::ForCurrentProcess()->HasSwitch( 1603 CommandLine::ForCurrentProcess()->HasSwitch(
1603 chromeos::switches::kEnableStaticIPConfig)); 1604 chromeos::switches::kEnableStaticIPConfig));
1604 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig); 1605 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig);
1605 1606
1606 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty()); 1607 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty());
1607 int priority = 0; 1608 int priority = 0;
1608 shill_properties.GetIntegerWithoutPathExpansion( 1609 shill_properties.GetIntegerWithoutPathExpansion(
1609 flimflam::kPriorityProperty, &priority); 1610 flimflam::kPriorityProperty, &priority);
1610 bool preferred = priority > 0; 1611 bool preferred = priority > 0;
1611 SetValueDictionary(&dictionary, kTagPreferred, 1612 SetValueDictionary(&dictionary, kTagPreferred,
1612 new base::FundamentalValue(preferred), 1613 new base::FundamentalValue(preferred),
1613 property_ui_data); 1614 property_ui_data);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 dictionary->SetString(kTagErrorState, 1658 dictionary->SetString(kTagErrorState,
1658 ash::network_connect::ErrorString(network->error())); 1659 ash::network_connect::ErrorString(network->error()));
1659 1660
1660 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); 1661 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty());
1661 bool shared = !network->IsPrivate(); 1662 bool shared = !network->IsPrivate();
1662 dictionary->SetBoolean(kTagShared, shared); 1663 dictionary->SetBoolean(kTagShared, shared);
1663 1664
1664 const std::string& type = network->type(); 1665 const std::string& type = network->type();
1665 const NetworkState* connected_network = 1666 const NetworkState* connected_network =
1666 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 1667 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
1667 type); 1668 NetworkTypePattern::Primitive(type));
1668 1669
1669 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); 1670 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL);
1670 1671
1671 if (type == flimflam::kTypeWifi) 1672 if (type == flimflam::kTypeWifi)
1672 PopulateWifiDetails(network, shill_properties, dictionary); 1673 PopulateWifiDetails(network, shill_properties, dictionary);
1673 else if (type == flimflam::kTypeWimax) 1674 else if (type == flimflam::kTypeWimax)
1674 PopulateWimaxDetails(network, shill_properties, dictionary); 1675 PopulateWimaxDetails(network, shill_properties, dictionary);
1675 else if (type == flimflam::kTypeCellular) 1676 else if (type == flimflam::kTypeCellular)
1676 PopulateCellularDetails(network, shill_properties, dictionary); 1677 PopulateCellularDetails(network, shill_properties, dictionary);
1677 else if (type == flimflam::kTypeVPN) 1678 else if (type == flimflam::kTypeVPN)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1981 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow()); 1982 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
1982 else if (type == flimflam::kTypeCellular) 1983 else if (type == flimflam::kTypeCellular)
1983 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 1984 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
1984 else 1985 else
1985 NOTREACHED(); 1986 NOTREACHED();
1986 } 1987 }
1987 1988
1988 base::ListValue* InternetOptionsHandler::GetWiredList() { 1989 base::ListValue* InternetOptionsHandler::GetWiredList() {
1989 base::ListValue* list = new base::ListValue(); 1990 base::ListValue* list = new base::ListValue();
1990 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 1991 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
1991 FirstNetworkByType(flimflam::kTypeEthernet); 1992 FirstNetworkByType(NetworkTypePattern::Ethernet());
1992 if (!network) 1993 if (!network)
1993 return list; 1994 return list;
1994 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor()); 1995 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor());
1995 list->Append(network_dict.BuildDictionary()); 1996 list->Append(network_dict.BuildDictionary());
1996 return list; 1997 return list;
1997 } 1998 }
1998 1999
1999 base::ListValue* InternetOptionsHandler::GetWirelessList() { 2000 base::ListValue* InternetOptionsHandler::GetWirelessList() {
2000 base::ListValue* list = new base::ListValue(); 2001 base::ListValue* list = new base::ListValue();
2001 2002
2002 NetworkStateHandler::NetworkStateList networks; 2003 NetworkStateHandler::NetworkStateList networks;
2003 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 2004 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
2005 NetworkTypePattern::Wireless(), &networks);
2004 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 2006 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
2005 networks.begin(); iter != networks.end(); ++iter) { 2007 networks.begin(); iter != networks.end(); ++iter) {
2006 const NetworkState* network = *iter; 2008 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
2007 if (network->type() != flimflam::kTypeWifi &&
2008 network->type() != flimflam::kTypeWimax &&
2009 network->type() != flimflam::kTypeCellular)
2010 continue;
2011 NetworkInfoDictionary network_dict(
2012 network, web_ui()->GetDeviceScaleFactor());
2013 list->Append(network_dict.BuildDictionary()); 2009 list->Append(network_dict.BuildDictionary());
2014 } 2010 }
2015 2011
2016 return list; 2012 return list;
2017 } 2013 }
2018 2014
2019 base::ListValue* InternetOptionsHandler::GetVPNList() { 2015 base::ListValue* InternetOptionsHandler::GetVPNList() {
2020 base::ListValue* list = new base::ListValue(); 2016 base::ListValue* list = new base::ListValue();
2021 2017
2022 NetworkStateHandler::NetworkStateList networks; 2018 NetworkStateHandler::NetworkStateList networks;
2023 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 2019 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
2020 NetworkTypePattern::VPN(), &networks);
2024 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 2021 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
2025 networks.begin(); iter != networks.end(); ++iter) { 2022 networks.begin(); iter != networks.end(); ++iter) {
2026 const NetworkState* network = *iter; 2023 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
2027 if (network->type() != flimflam::kTypeVPN)
2028 continue;
2029 NetworkInfoDictionary network_dict(
2030 network, web_ui()->GetDeviceScaleFactor());
2031 list->Append(network_dict.BuildDictionary()); 2024 list->Append(network_dict.BuildDictionary());
2032 } 2025 }
2033 2026
2034 return list; 2027 return list;
2035 } 2028 }
2036 2029
2037 base::ListValue* InternetOptionsHandler::GetRememberedList() { 2030 base::ListValue* InternetOptionsHandler::GetRememberedList() {
2038 base::ListValue* list = new base::ListValue(); 2031 base::ListValue* list = new base::ListValue();
2039 2032
2040 NetworkStateHandler::FavoriteStateList favorites; 2033 NetworkStateHandler::FavoriteStateList favorites;
(...skipping 13 matching lines...) Expand all
2054 } 2047 }
2055 2048
2056 void InternetOptionsHandler::FillNetworkInfo( 2049 void InternetOptionsHandler::FillNetworkInfo(
2057 base::DictionaryValue* dictionary) { 2050 base::DictionaryValue* dictionary) {
2058 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 2051 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
2059 dictionary->Set(kTagWiredList, GetWiredList()); 2052 dictionary->Set(kTagWiredList, GetWiredList());
2060 dictionary->Set(kTagWirelessList, GetWirelessList()); 2053 dictionary->Set(kTagWirelessList, GetWirelessList());
2061 dictionary->Set(kTagVpnList, GetVPNList()); 2054 dictionary->Set(kTagVpnList, GetVPNList());
2062 dictionary->Set(kTagRememberedList, GetRememberedList()); 2055 dictionary->Set(kTagRememberedList, GetRememberedList());
2063 2056
2064 dictionary->SetBoolean(kTagWifiAvailable, 2057 dictionary->SetBoolean(
2065 handler->IsTechnologyAvailable(flimflam::kTypeWifi)); 2058 kTagWifiAvailable,
2066 dictionary->SetBoolean(kTagWifiEnabled, 2059 handler->IsTechnologyAvailable(NetworkTypePattern::WiFi()));
2067 handler->IsTechnologyEnabled(flimflam::kTypeWifi)); 2060 dictionary->SetBoolean(
2061 kTagWifiEnabled,
2062 handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
2068 2063
2069 dictionary->SetBoolean(kTagCellularAvailable, 2064 dictionary->SetBoolean(
2070 handler->IsTechnologyAvailable( 2065 kTagCellularAvailable,
2071 NetworkStateHandler::kMatchTypeMobile)); 2066 handler->IsTechnologyAvailable(NetworkTypePattern::Mobile()));
2072 dictionary->SetBoolean(kTagCellularEnabled, 2067 dictionary->SetBoolean(
2073 handler->IsTechnologyEnabled( 2068 kTagCellularEnabled,
2074 NetworkStateHandler::kMatchTypeMobile)); 2069 handler->IsTechnologyEnabled(NetworkTypePattern::Mobile()));
2075 const DeviceState* cellular = 2070 const DeviceState* cellular =
2076 handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile); 2071 handler->GetDeviceStateByType(NetworkTypePattern::Mobile());
2077 dictionary->SetBoolean( 2072 dictionary->SetBoolean(
2078 kTagCellularSupportsScan, 2073 kTagCellularSupportsScan,
2079 cellular && cellular->support_network_scan()); 2074 cellular && cellular->support_network_scan());
2080 2075
2081 dictionary->SetBoolean(kTagWimaxAvailable, 2076 dictionary->SetBoolean(
2082 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); 2077 kTagWimaxAvailable,
2083 dictionary->SetBoolean(kTagWimaxEnabled, 2078 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
2084 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); 2079 dictionary->SetBoolean(
2080 kTagWimaxEnabled,
2081 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
2085 } 2082 }
2086 2083
2087 } // namespace options 2084 } // namespace options
2088 } // namespace chromeos 2085 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/help_utils_chromeos.cc ('k') | chromeos/chromeos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698