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

Unified Diff: ash/system/chromeos/network/network_icon.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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/network/network_icon.cc
diff --git a/ash/system/chromeos/network/network_icon.cc b/ash/system/chromeos/network/network_icon.cc
index efe7e07afc4665d94faa0632db855717734c9f86..2ed3b2c31b3245afde63e79158fd94d23ceef6d5 100644
--- a/ash/system/chromeos/network/network_icon.cc
+++ b/ash/system/chromeos/network/network_icon.cc
@@ -12,6 +12,7 @@
#include "chromeos/network/network_connection_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"
@@ -28,6 +29,7 @@ using chromeos::NetworkConnectionHandler;
using chromeos::NetworkHandler;
using chromeos::NetworkState;
using chromeos::NetworkStateHandler;
+using chromeos::NetworkTypePattern;
namespace ash {
namespace network_icon {
@@ -464,7 +466,7 @@ gfx::ImageSkia GetIcon(const NetworkState* network,
int strength_index) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
const std::string& type = network->type();
- if (type == flimflam::kTypeEthernet) {
+ if (NetworkTypePattern::Ethernet().Matches(type)) {
return *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_WIRED);
} else if (type == flimflam::kTypeWifi ||
type == flimflam::kTypeWimax ||
@@ -487,8 +489,8 @@ gfx::ImageSkia GetConnectingVpnImage(IconType icon_type) {
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
const NetworkState* connected_network = NULL;
if (icon_type == ICON_TYPE_TRAY) {
- connected_network = handler->ConnectedNetworkByType(
- NetworkStateHandler::kMatchTypeNonVirtual);
+ connected_network =
+ handler->ConnectedNetworkByType(NetworkTypePattern::NonVirtual());
}
double animation = NetworkIconAnimation::GetInstance()->GetAnimation();
@@ -545,7 +547,7 @@ void NetworkIconImpl::Update(const NetworkState* network) {
}
const std::string& type = network->type();
- if (type != flimflam::kTypeEthernet)
+ if (!NetworkTypePattern::Ethernet().Matches(type))
dirty |= UpdateWirelessStrengthIndex(network);
if (type == flimflam::kTypeCellular)
@@ -587,7 +589,7 @@ bool NetworkIconImpl::UpdateCellularState(const NetworkState* network) {
bool NetworkIconImpl::UpdateVPNBadge() {
const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()->
- ConnectedNetworkByType(flimflam::kTypeVPN);
+ ConnectedNetworkByType(NetworkTypePattern::VPN());
if (vpn && vpn_badge_ == NULL) {
vpn_badge_ = BadgeForVPN(icon_type_);
return true;
@@ -725,7 +727,7 @@ base::string16 GetLabelForNetwork(const chromeos::NetworkState* network,
}
// Otherwise just show the network name or 'Ethernet'.
- if (network->type() == flimflam::kTypeEthernet) {
+ if (network->Matches(NetworkTypePattern::Ethernet())) {
return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET);
} else {
return UTF8ToUTF16(network->name());
@@ -737,13 +739,12 @@ int GetCellularUninitializedMsg() {
static int s_uninitialized_msg(0);
NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
- if (handler->GetTechnologyState(NetworkStateHandler::kMatchTypeMobile)
+ if (handler->GetTechnologyState(NetworkTypePattern::Mobile())
== NetworkStateHandler::TECHNOLOGY_UNINITIALIZED) {
s_uninitialized_msg = IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR;
s_uninitialized_state_time = base::Time::Now();
return s_uninitialized_msg;
- } else if (handler->GetScanningByType(
- NetworkStateHandler::kMatchTypeMobile)) {
+ } else if (handler->GetScanningByType(NetworkTypePattern::Mobile())) {
s_uninitialized_msg = IDS_ASH_STATUS_TRAY_CELLULAR_SCANNING;
s_uninitialized_state_time = base::Time::Now();
return s_uninitialized_msg;
@@ -767,14 +768,12 @@ void GetDefaultNetworkImageAndLabel(IconType icon_type,
NetworkConnectionHandler* connect_handler =
NetworkHandler::Get()->network_connection_handler();
const NetworkState* connected_network =
- state_handler->ConnectedNetworkByType(
- NetworkStateHandler::kMatchTypeNonVirtual);
+ state_handler->ConnectedNetworkByType(NetworkTypePattern::NonVirtual());
const NetworkState* connecting_network =
- state_handler->ConnectingNetworkByType(
- NetworkStateHandler::kMatchTypeWireless);
+ state_handler->ConnectingNetworkByType(NetworkTypePattern::Wireless());
if (!connecting_network && icon_type == ICON_TYPE_TRAY) {
connecting_network =
- state_handler->ConnectingNetworkByType(flimflam::kTypeVPN);
+ state_handler->ConnectingNetworkByType(NetworkTypePattern::VPN());
}
const NetworkState* network;
@@ -790,8 +789,8 @@ void GetDefaultNetworkImageAndLabel(IconType icon_type,
}
// Don't show ethernet in the tray
- if (icon_type == ICON_TYPE_TRAY &&
- network && network->type() == flimflam::kTypeEthernet) {
+ if (icon_type == ICON_TYPE_TRAY && network &&
+ network->Matches(NetworkTypePattern::Ethernet())) {
*image = gfx::ImageSkia();
*animating = false;
return;
@@ -799,8 +798,8 @@ void GetDefaultNetworkImageAndLabel(IconType icon_type,
if (!network) {
// If no connecting network, check if we are activating a network.
- const NetworkState* mobile_network = state_handler->FirstNetworkByType(
- NetworkStateHandler::kMatchTypeMobile);
+ const NetworkState* mobile_network =
+ state_handler->FirstNetworkByType(NetworkTypePattern::Mobile());
if (mobile_network && (mobile_network->activation_state() ==
flimflam::kActivationStateActivating)) {
network = mobile_network;

Powered by Google App Engine
This is Rietveld 408576698