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

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: Generalized network type matching. 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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 web_ui()->RegisterMessageCallback(kChangePinMessage, 1017 web_ui()->RegisterMessageCallback(kChangePinMessage,
1017 base::Bind(&InternetOptionsHandler::ChangePinCallback, 1018 base::Bind(&InternetOptionsHandler::ChangePinCallback,
1018 base::Unretained(this))); 1019 base::Unretained(this)));
1019 web_ui()->RegisterMessageCallback(kSetServerHostname, 1020 web_ui()->RegisterMessageCallback(kSetServerHostname,
1020 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback, 1021 base::Bind(&InternetOptionsHandler::SetServerHostnameCallback,
1021 base::Unretained(this))); 1022 base::Unretained(this)));
1022 } 1023 }
1023 1024
1024 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) { 1025 void InternetOptionsHandler::EnableWifiCallback(const base::ListValue* args) {
1025 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1026 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1026 flimflam::kTypeWifi, true, 1027 NetworkTypePattern::WiFi(), true,
1027 base::Bind(&ShillError, "EnableWifiCallback")); 1028 base::Bind(&ShillError, "EnableWifiCallback"));
1028 } 1029 }
1029 1030
1030 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) { 1031 void InternetOptionsHandler::DisableWifiCallback(const base::ListValue* args) {
1031 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1032 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1032 flimflam::kTypeWifi, false, 1033 NetworkTypePattern::WiFi(), false,
1033 base::Bind(&ShillError, "DisableWifiCallback")); 1034 base::Bind(&ShillError, "DisableWifiCallback"));
1034 } 1035 }
1035 1036
1036 void InternetOptionsHandler::EnableCellularCallback( 1037 void InternetOptionsHandler::EnableCellularCallback(
1037 const base::ListValue* args) { 1038 const base::ListValue* args) {
1038 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1039 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1039 const DeviceState* device = 1040 const DeviceState* device =
1040 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1041 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1041 if (!device) { 1042 if (!device) {
1042 LOG(ERROR) << "Mobile device not found."; 1043 LOG(ERROR) << "Mobile device not found.";
1043 return; 1044 return;
1044 } 1045 }
1045 if (!device->sim_lock_type().empty()) { 1046 if (!device->sim_lock_type().empty()) {
1046 SimDialogDelegate::ShowDialog(GetNativeWindow(), 1047 SimDialogDelegate::ShowDialog(GetNativeWindow(),
1047 SimDialogDelegate::SIM_DIALOG_UNLOCK); 1048 SimDialogDelegate::SIM_DIALOG_UNLOCK);
1048 return; 1049 return;
1049 } 1050 }
1050 if (!handler->IsTechnologyEnabled(flimflam::kTypeCellular)) { 1051 if (!handler->IsTechnologyEnabled(NetworkTypePattern::Cellular())) {
1051 handler->SetTechnologyEnabled( 1052 handler->SetTechnologyEnabled(
1052 flimflam::kTypeCellular, true, 1053 NetworkTypePattern::Cellular(), true,
1053 base::Bind(&ShillError, "EnableCellularCallback")); 1054 base::Bind(&ShillError, "EnableCellularCallback"));
1054 return; 1055 return;
1055 } 1056 }
1056 if (device->IsSimAbsent()) { 1057 if (device->IsSimAbsent()) {
1057 MobileConfig* config = MobileConfig::GetInstance(); 1058 MobileConfig* config = MobileConfig::GetInstance();
1058 if (config->IsReady()) { 1059 if (config->IsReady()) {
1059 const MobileConfig::LocaleConfig* locale_config = 1060 const MobileConfig::LocaleConfig* locale_config =
1060 config->GetLocaleConfig(); 1061 config->GetLocaleConfig();
1061 if (locale_config) { 1062 if (locale_config) {
1062 std::string setup_url = locale_config->setup_url(); 1063 std::string setup_url = locale_config->setup_url();
1063 if (!setup_url.empty()) { 1064 if (!setup_url.empty()) {
1064 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url)); 1065 chrome::ShowSingletonTab(GetAppropriateBrowser(), GURL(setup_url));
1065 return; 1066 return;
1066 } 1067 }
1067 } 1068 }
1068 } 1069 }
1069 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444 1070 // TODO(nkostylev): Show generic error message. http://crosbug.com/15444
1070 } 1071 }
1071 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device"; 1072 LOG(ERROR) << "EnableCellularCallback called for enabled mobile device";
1072 } 1073 }
1073 1074
1074 void InternetOptionsHandler::DisableCellularCallback( 1075 void InternetOptionsHandler::DisableCellularCallback(
1075 const base::ListValue* args) { 1076 const base::ListValue* args) {
1076 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1077 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1077 NetworkStateHandler::kMatchTypeMobile, false, 1078 NetworkTypePattern::Mobile(), false,
1078 base::Bind(&ShillError, "DisableCellularCallback")); 1079 base::Bind(&ShillError, "DisableCellularCallback"));
1079 } 1080 }
1080 1081
1081 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) { 1082 void InternetOptionsHandler::EnableWimaxCallback(const base::ListValue* args) {
1082 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1083 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1083 flimflam::kTypeWimax, true, 1084 NetworkTypePattern::Wimax(), true,
1084 base::Bind(&ShillError, "EnableWimaxCallback")); 1085 base::Bind(&ShillError, "EnableWimaxCallback"));
1085 } 1086 }
1086 1087
1087 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) { 1088 void InternetOptionsHandler::DisableWimaxCallback(const base::ListValue* args) {
1088 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled( 1089 NetworkHandler::Get()->network_state_handler()->SetTechnologyEnabled(
1089 flimflam::kTypeWimax, false, 1090 NetworkTypePattern::Wimax(), false,
1090 base::Bind(&ShillError, "DisableWimaxCallback")); 1091 base::Bind(&ShillError, "DisableWimaxCallback"));
1091 } 1092 }
1092 1093
1093 void InternetOptionsHandler::ShowMorePlanInfoCallback( 1094 void InternetOptionsHandler::ShowMorePlanInfoCallback(
1094 const base::ListValue* args) { 1095 const base::ListValue* args) {
1095 if (!web_ui()) 1096 if (!web_ui())
1096 return; 1097 return;
1097 std::string service_path; 1098 std::string service_path;
1098 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 1099 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
1099 NOTREACHED(); 1100 NOTREACHED();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict); 1169 properties.SetWithoutPathExpansion(flimflam::kCellularApnProperty, apn_dict);
1169 NetworkHandler::Get()->network_configuration_handler()->SetProperties( 1170 NetworkHandler::Get()->network_configuration_handler()->SetProperties(
1170 service_path, properties, 1171 service_path, properties,
1171 base::Bind(&base::DoNothing), 1172 base::Bind(&base::DoNothing),
1172 base::Bind(&ShillError, "SetApnProperties")); 1173 base::Bind(&ShillError, "SetApnProperties"));
1173 } 1174 }
1174 1175
1175 void InternetOptionsHandler::CarrierStatusCallback() { 1176 void InternetOptionsHandler::CarrierStatusCallback() {
1176 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1177 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1177 const DeviceState* device = 1178 const DeviceState* device =
1178 handler->GetDeviceStateByType(flimflam::kTypeCellular); 1179 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
1179 if (device && (device->carrier() == shill::kCarrierSprint)) { 1180 if (device && (device->carrier() == shill::kCarrierSprint)) {
1180 const NetworkState* network = 1181 const NetworkState* network =
1181 handler->FirstNetworkByType(flimflam::kTypeCellular); 1182 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
1182 if (network) { 1183 if (network) {
1183 ash::network_connect::ActivateCellular(network->path()); 1184 ash::network_connect::ActivateCellular(network->path());
1184 UpdateConnectionData(network->path()); 1185 UpdateConnectionData(network->path());
1185 } 1186 }
1186 } 1187 }
1187 UpdateCarrier(); 1188 UpdateCarrier();
1188 } 1189 }
1189 1190
1190 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 1191 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
1191 std::string service_path; 1192 std::string service_path;
1192 std::string carrier; 1193 std::string carrier;
1193 if (args->GetSize() != 2 || 1194 if (args->GetSize() != 2 ||
1194 !args->GetString(0, &service_path) || 1195 !args->GetString(0, &service_path) ||
1195 !args->GetString(1, &carrier)) { 1196 !args->GetString(1, &carrier)) {
1196 NOTREACHED(); 1197 NOTREACHED();
1197 return; 1198 return;
1198 } 1199 }
1199 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 1200 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
1200 GetDeviceStateByType(flimflam::kTypeCellular); 1201 GetDeviceStateByType(NetworkTypePattern::Cellular());
1201 if (!device) { 1202 if (!device) {
1202 LOG(WARNING) << "SetCarrierCallback with no cellular device."; 1203 LOG(WARNING) << "SetCarrierCallback with no cellular device.";
1203 return; 1204 return;
1204 } 1205 }
1205 NetworkHandler::Get()->network_device_handler()->SetCarrier( 1206 NetworkHandler::Get()->network_device_handler()->SetCarrier(
1206 device->path(), 1207 device->path(),
1207 carrier, 1208 carrier,
1208 base::Bind(&InternetOptionsHandler::CarrierStatusCallback, 1209 base::Bind(&InternetOptionsHandler::CarrierStatusCallback,
1209 weak_factory_.GetWeakPtr()), 1210 weak_factory_.GetWeakPtr()),
1210 base::Bind(&ShillError, "SetCarrierCallback")); 1211 base::Bind(&ShillError, "SetCarrierCallback"));
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 std::string type = network->type(); 1529 std::string type = network->type();
1529 dictionary.SetString(kTagType, type); 1530 dictionary.SetString(kTagType, type);
1530 dictionary.SetString(kTagServicePath, network->path()); 1531 dictionary.SetString(kTagServicePath, network->path());
1531 dictionary.SetString(kTagNameServerType, name_server_type); 1532 dictionary.SetString(kTagNameServerType, name_server_type);
1532 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers); 1533 dictionary.SetString(kTagNameServersGoogle, kGoogleNameServers);
1533 1534
1534 // Only show proxy for remembered networks. 1535 // Only show proxy for remembered networks.
1535 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty()); 1536 dictionary.SetBoolean(kTagShowProxy, !network->profile_path().empty());
1536 1537
1537 // Enable static ip config for ethernet. For wifi, enable if flag is set. 1538 // Enable static ip config for ethernet. For wifi, enable if flag is set.
1538 bool staticIPConfig = type == flimflam::kTypeEthernet || 1539 bool staticIPConfig = network->Matches(NetworkTypePattern::Ethernet()) ||
1539 (type == flimflam::kTypeWifi && 1540 (type == flimflam::kTypeWifi &&
1540 CommandLine::ForCurrentProcess()->HasSwitch( 1541 CommandLine::ForCurrentProcess()->HasSwitch(
1541 chromeos::switches::kEnableStaticIPConfig)); 1542 chromeos::switches::kEnableStaticIPConfig));
1542 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig); 1543 dictionary.SetBoolean(kTagShowStaticIPConfig, staticIPConfig);
1543 1544
1544 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty()); 1545 dictionary.SetBoolean(kTagShowPreferred, !network->profile_path().empty());
1545 bool preferred = network->priority() > 0; 1546 bool preferred = network->priority() > 0;
1546 SetValueDictionary(&dictionary, kTagPreferred, 1547 SetValueDictionary(&dictionary, kTagPreferred,
1547 new base::FundamentalValue(preferred), 1548 new base::FundamentalValue(preferred),
1548 property_ui_data); 1549 property_ui_data);
1549 1550
1550 NetworkPropertyUIData auto_connect_ui_data(onc_source); 1551 NetworkPropertyUIData auto_connect_ui_data(onc_source);
1551 std::string onc_path_to_auto_connect; 1552 std::string onc_path_to_auto_connect;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 dictionary->SetString(kTagErrorState, 1590 dictionary->SetString(kTagErrorState,
1590 ash::network_connect::ErrorString(network->error())); 1591 ash::network_connect::ErrorString(network->error()));
1591 1592
1592 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); 1593 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty());
1593 bool shared = !network->IsPrivate(); 1594 bool shared = !network->IsPrivate();
1594 dictionary->SetBoolean(kTagShared, shared); 1595 dictionary->SetBoolean(kTagShared, shared);
1595 1596
1596 const std::string& type = network->type(); 1597 const std::string& type = network->type();
1597 const NetworkState* connected_network = 1598 const NetworkState* connected_network =
1598 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 1599 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
1599 type); 1600 NetworkTypePattern::Primitive(type));
1600 1601
1601 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); 1602 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL);
1602 1603
1603 if (type == flimflam::kTypeWifi) 1604 if (type == flimflam::kTypeWifi)
1604 PopulateWifiDetails(network, shill_properties, dictionary); 1605 PopulateWifiDetails(network, shill_properties, dictionary);
1605 else if (type == flimflam::kTypeWimax) 1606 else if (type == flimflam::kTypeWimax)
1606 PopulateWimaxDetails(network, shill_properties, dictionary); 1607 PopulateWimaxDetails(network, shill_properties, dictionary);
1607 else if (type == flimflam::kTypeCellular) 1608 else if (type == flimflam::kTypeCellular)
1608 PopulateCellularDetails(network, shill_properties, dictionary); 1609 PopulateCellularDetails(network, shill_properties, dictionary);
1609 else if (type == flimflam::kTypeVPN) 1610 else if (type == flimflam::kTypeVPN)
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow()); 1914 NetworkConfigView::ShowForType(flimflam::kTypeVPN, GetNativeWindow());
1914 else if (type == flimflam::kTypeCellular) 1915 else if (type == flimflam::kTypeCellular)
1915 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 1916 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
1916 else 1917 else
1917 NOTREACHED(); 1918 NOTREACHED();
1918 } 1919 }
1919 1920
1920 base::ListValue* InternetOptionsHandler::GetWiredList() { 1921 base::ListValue* InternetOptionsHandler::GetWiredList() {
1921 base::ListValue* list = new base::ListValue(); 1922 base::ListValue* list = new base::ListValue();
1922 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 1923 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
1923 FirstNetworkByType(flimflam::kTypeEthernet); 1924 FirstNetworkByType(NetworkTypePattern::Ethernet());
1924 if (!network) 1925 if (!network)
1925 return list; 1926 return list;
1926 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor()); 1927 NetworkInfoDictionary network_dict(network, web_ui()->GetDeviceScaleFactor());
1927 list->Append(network_dict.BuildDictionary()); 1928 list->Append(network_dict.BuildDictionary());
1928 return list; 1929 return list;
1929 } 1930 }
1930 1931
1931 base::ListValue* InternetOptionsHandler::GetWirelessList() { 1932 base::ListValue* InternetOptionsHandler::GetWirelessList() {
1932 base::ListValue* list = new base::ListValue(); 1933 base::ListValue* list = new base::ListValue();
1933 1934
1934 NetworkStateHandler::NetworkStateList networks; 1935 NetworkStateHandler::NetworkStateList networks;
1935 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 1936 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
1937 NetworkTypePattern::Wireless(), &networks);
1936 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 1938 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
1937 networks.begin(); iter != networks.end(); ++iter) { 1939 networks.begin(); iter != networks.end(); ++iter) {
1938 const NetworkState* network = *iter; 1940 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
1939 if (network->type() != flimflam::kTypeWifi &&
1940 network->type() != flimflam::kTypeWimax &&
1941 network->type() != flimflam::kTypeCellular)
1942 continue;
1943 NetworkInfoDictionary network_dict(
1944 network, web_ui()->GetDeviceScaleFactor());
1945 list->Append(network_dict.BuildDictionary()); 1941 list->Append(network_dict.BuildDictionary());
1946 } 1942 }
1947 1943
1948 return list; 1944 return list;
1949 } 1945 }
1950 1946
1951 base::ListValue* InternetOptionsHandler::GetVPNList() { 1947 base::ListValue* InternetOptionsHandler::GetVPNList() {
1952 base::ListValue* list = new base::ListValue(); 1948 base::ListValue* list = new base::ListValue();
1953 1949
1954 NetworkStateHandler::NetworkStateList networks; 1950 NetworkStateHandler::NetworkStateList networks;
1955 NetworkHandler::Get()->network_state_handler()->GetNetworkList(&networks); 1951 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
1952 NetworkTypePattern::VPN(), &networks);
1956 for (NetworkStateHandler::NetworkStateList::const_iterator iter = 1953 for (NetworkStateHandler::NetworkStateList::const_iterator iter =
1957 networks.begin(); iter != networks.end(); ++iter) { 1954 networks.begin(); iter != networks.end(); ++iter) {
1958 const NetworkState* network = *iter; 1955 NetworkInfoDictionary network_dict(*iter, web_ui()->GetDeviceScaleFactor());
1959 if (network->type() != flimflam::kTypeVPN)
1960 continue;
1961 NetworkInfoDictionary network_dict(
1962 network, web_ui()->GetDeviceScaleFactor());
1963 list->Append(network_dict.BuildDictionary()); 1956 list->Append(network_dict.BuildDictionary());
1964 } 1957 }
1965 1958
1966 return list; 1959 return list;
1967 } 1960 }
1968 1961
1969 base::ListValue* InternetOptionsHandler::GetRememberedList() { 1962 base::ListValue* InternetOptionsHandler::GetRememberedList() {
1970 base::ListValue* list = new base::ListValue(); 1963 base::ListValue* list = new base::ListValue();
1971 1964
1972 NetworkStateHandler::FavoriteStateList favorites; 1965 NetworkStateHandler::FavoriteStateList favorites;
(...skipping 13 matching lines...) Expand all
1986 } 1979 }
1987 1980
1988 void InternetOptionsHandler::FillNetworkInfo( 1981 void InternetOptionsHandler::FillNetworkInfo(
1989 base::DictionaryValue* dictionary) { 1982 base::DictionaryValue* dictionary) {
1990 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 1983 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
1991 dictionary->Set(kTagWiredList, GetWiredList()); 1984 dictionary->Set(kTagWiredList, GetWiredList());
1992 dictionary->Set(kTagWirelessList, GetWirelessList()); 1985 dictionary->Set(kTagWirelessList, GetWirelessList());
1993 dictionary->Set(kTagVpnList, GetVPNList()); 1986 dictionary->Set(kTagVpnList, GetVPNList());
1994 dictionary->Set(kTagRememberedList, GetRememberedList()); 1987 dictionary->Set(kTagRememberedList, GetRememberedList());
1995 1988
1996 dictionary->SetBoolean(kTagWifiAvailable, 1989 dictionary->SetBoolean(
1997 handler->IsTechnologyAvailable(flimflam::kTypeWifi)); 1990 kTagWifiAvailable,
1998 dictionary->SetBoolean(kTagWifiEnabled, 1991 handler->IsTechnologyAvailable(NetworkTypePattern::WiFi()));
1999 handler->IsTechnologyEnabled(flimflam::kTypeWifi)); 1992 dictionary->SetBoolean(
1993 kTagWifiEnabled,
1994 handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()));
2000 1995
2001 dictionary->SetBoolean(kTagCellularAvailable, 1996 dictionary->SetBoolean(
2002 handler->IsTechnologyAvailable( 1997 kTagCellularAvailable,
2003 NetworkStateHandler::kMatchTypeMobile)); 1998 handler->IsTechnologyAvailable(NetworkTypePattern::Mobile()));
2004 dictionary->SetBoolean(kTagCellularEnabled, 1999 dictionary->SetBoolean(
2005 handler->IsTechnologyEnabled( 2000 kTagCellularEnabled,
2006 NetworkStateHandler::kMatchTypeMobile)); 2001 handler->IsTechnologyEnabled(NetworkTypePattern::Mobile()));
2007 const DeviceState* cellular = 2002 const DeviceState* cellular =
2008 handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile); 2003 handler->GetDeviceStateByType(NetworkTypePattern::Mobile());
2009 dictionary->SetBoolean( 2004 dictionary->SetBoolean(
2010 kTagCellularSupportsScan, 2005 kTagCellularSupportsScan,
2011 cellular && cellular->support_network_scan()); 2006 cellular && cellular->support_network_scan());
2012 2007
2013 dictionary->SetBoolean(kTagWimaxAvailable, 2008 dictionary->SetBoolean(
2014 handler->IsTechnologyAvailable(flimflam::kTypeWimax)); 2009 kTagWimaxAvailable,
2015 dictionary->SetBoolean(kTagWimaxEnabled, 2010 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
2016 handler->IsTechnologyEnabled(flimflam::kTypeWimax)); 2011 dictionary->SetBoolean(
2012 kTagWimaxEnabled,
2013 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
2017 } 2014 }
2018 2015
2019 } // namespace options 2016 } // namespace options
2020 } // namespace chromeos 2017 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698