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

Unified Diff: ash/system/chromeos/network/network_state_list_detailed_view.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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/network/network_state_list_detailed_view.cc
diff --git a/ash/system/chromeos/network/network_state_list_detailed_view.cc b/ash/system/chromeos/network/network_state_list_detailed_view.cc
index 03a181e793f91d62df3695e1ce20d7f87b0008ff..bf7d4e7edb4b389c7f4692f1b3c0912aac3842c1 100644
--- a/ash/system/chromeos/network/network_state_list_detailed_view.cc
+++ b/ash/system/chromeos/network/network_state_list_detailed_view.cc
@@ -30,6 +30,7 @@
#include "chromeos/network/network_configuration_handler.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
+#include "chromeos/network/shill_property_util.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -47,6 +48,7 @@ using chromeos::FavoriteState;
using chromeos::NetworkHandler;
using chromeos::NetworkState;
using chromeos::NetworkStateHandler;
+using chromeos::NetworkTypePattern;
namespace ash {
namespace internal {
@@ -251,14 +253,15 @@ void NetworkStateListDetailedView::ButtonPressed(views::Button* sender,
ash::SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->system_tray_delegate();
if (sender == button_wifi_) {
- bool enabled = handler->IsTechnologyEnabled(flimflam::kTypeWifi);
- handler->SetTechnologyEnabled(
- flimflam::kTypeWifi, !enabled,
- chromeos::network_handler::ErrorCallback());
+ bool enabled = handler->IsTechnologyEnabled(
+ NetworkTypePattern::WiFi());
+ handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(),
+ !enabled,
+ chromeos::network_handler::ErrorCallback());
} else if (sender == turn_on_wifi_) {
- handler->SetTechnologyEnabled(
- flimflam::kTypeWifi, true,
- chromeos::network_handler::ErrorCallback());
+ handler->SetTechnologyEnabled(NetworkTypePattern::WiFi(),
+ true,
+ chromeos::network_handler::ErrorCallback());
} else if (sender == button_mobile_) {
ToggleMobile();
} else if (sender == settings_) {
@@ -424,10 +427,9 @@ void NetworkStateListDetailedView::CreateNetworkExtra() {
void NetworkStateListDetailedView::UpdateHeaderButtons() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
if (button_wifi_)
- UpdateTechnologyButton(button_wifi_, flimflam::kTypeWifi);
+ UpdateTechnologyButton(button_wifi_, NetworkTypePattern::WiFi());
if (button_mobile_) {
- UpdateTechnologyButton(
- button_mobile_, NetworkStateHandler::kMatchTypeMobile);
+ UpdateTechnologyButton(button_mobile_, NetworkTypePattern::Mobile());
}
if (proxy_settings_)
proxy_settings_->SetEnabled(handler->DefaultNetwork() != NULL);
@@ -437,10 +439,10 @@ void NetworkStateListDetailedView::UpdateHeaderButtons() {
void NetworkStateListDetailedView::UpdateTechnologyButton(
TrayPopupHeaderButton* button,
- const std::string& technology) {
+ const NetworkTypePattern& technology) {
NetworkStateHandler::TechnologyState state =
- NetworkHandler::Get()->network_state_handler()->
- GetTechnologyState(technology);
+ NetworkHandler::Get()->network_state_handler()->GetTechnologyState(
+ technology);
if (state == NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) {
button->SetVisible(false);
return;
@@ -640,8 +642,8 @@ bool NetworkStateListDetailedView::UpdateNetworkListEntries(
// Cellular initializing
int status_message_id = network_icon::GetCellularUninitializedMsg();
if (!status_message_id &&
- handler->IsTechnologyEnabled(NetworkStateHandler::kMatchTypeMobile) &&
- !handler->FirstNetworkByType(NetworkStateHandler::kMatchTypeMobile)) {
+ handler->IsTechnologyEnabled(NetworkTypePattern::Mobile()) &&
+ !handler->FirstNetworkByType(NetworkTypePattern::Mobile())) {
status_message_id = IDS_ASH_STATUS_TRAY_NO_CELLULAR_NETWORKS;
}
if (status_message_id) {
@@ -656,9 +658,9 @@ bool NetworkStateListDetailedView::UpdateNetworkListEntries(
// "Wifi Enabled / Disabled"
if (network_list_.empty()) {
- int message_id = handler->IsTechnologyEnabled(flimflam::kTypeWifi) ?
- IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED :
- IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED;
+ int message_id = handler->IsTechnologyEnabled(NetworkTypePattern::WiFi())
+ ? IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED
+ : IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED;
base::string16 text = rb.GetLocalizedString(message_id);
if (CreateOrUpdateInfoLabel(index++, text, &no_wifi_networks_view_))
needs_relayout = true;
@@ -669,7 +671,7 @@ bool NetworkStateListDetailedView::UpdateNetworkListEntries(
}
// "Wifi Scanning"
- if (handler->GetScanningByType(flimflam::kTypeWifi)) {
+ if (handler->GetScanningByType(NetworkTypePattern::WiFi())) {
base::string16 text =
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_WIFI_SCANNING_MESSAGE);
if (CreateOrUpdateInfoLabel(index++, text, &scanning_view_))
@@ -714,7 +716,7 @@ void NetworkStateListDetailedView::UpdateNetworkExtra() {
if (other_wifi_) {
DCHECK(turn_on_wifi_);
NetworkStateHandler::TechnologyState state =
- handler->GetTechnologyState(flimflam::kTypeWifi);
+ handler->GetTechnologyState(NetworkTypePattern::WiFi());
if (state == NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) {
turn_on_wifi_->SetVisible(false);
other_wifi_->SetVisible(false);
@@ -739,10 +741,10 @@ void NetworkStateListDetailedView::UpdateNetworkExtra() {
if (other_mobile_) {
bool show_other_mobile = false;
NetworkStateHandler::TechnologyState state =
- handler->GetTechnologyState(NetworkStateHandler::kMatchTypeMobile);
+ handler->GetTechnologyState(NetworkTypePattern::Mobile());
if (state != NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) {
const chromeos::DeviceState* device =
- handler->GetDeviceStateByType(NetworkStateHandler::kMatchTypeMobile);
+ handler->GetDeviceStateByType(NetworkTypePattern::Mobile());
show_other_mobile = (device && device->support_network_scan());
}
if (show_other_mobile) {
@@ -806,13 +808,13 @@ views::View* NetworkStateListDetailedView::CreateNetworkInfoView() {
std::string ethernet_address, wifi_address, vpn_address;
if (list_type_ != LIST_TYPE_VPN) {
- ethernet_address =
- handler->FormattedHardwareAddressForType(flimflam::kTypeEthernet);
+ ethernet_address = handler->FormattedHardwareAddressForType(
+ NetworkTypePattern::Ethernet());
wifi_address =
- handler->FormattedHardwareAddressForType(flimflam::kTypeWifi);
+ handler->FormattedHardwareAddressForType(NetworkTypePattern::WiFi());
} else {
vpn_address =
- handler->FormattedHardwareAddressForType(flimflam::kTypeVPN);
+ handler->FormattedHardwareAddressForType(NetworkTypePattern::VPN());
}
if (!ip_address.empty()) {
@@ -855,9 +857,9 @@ void NetworkStateListDetailedView::CallRequestScan() {
void NetworkStateListDetailedView::ToggleMobile() {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
bool enabled =
- handler->IsTechnologyEnabled(NetworkStateHandler::kMatchTypeMobile);
- ash::network_connect::SetTechnologyEnabled(
- NetworkStateHandler::kMatchTypeMobile, !enabled);
+ handler->IsTechnologyEnabled(NetworkTypePattern::Mobile());
+ ash::network_connect::SetTechnologyEnabled(NetworkTypePattern::Mobile(),
+ !enabled);
}
} // namespace tray
« no previous file with comments | « ash/system/chromeos/network/network_state_list_detailed_view.h ('k') | ash/system/chromeos/network/network_state_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698