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

Side by Side 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: 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 "ash/system/chromeos/network/network_icon.h" 5 #include "ash/system/chromeos/network/network_icon.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/network/network_icon_animation.h" 8 #include "ash/system/chromeos/network/network_icon_animation.h"
9 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 9 #include "ash/system/chromeos/network/network_icon_animation_observer.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 const gfx::ImageSkia* BadgeForVPN(IconType icon_type) { 457 const gfx::ImageSkia* BadgeForVPN(IconType icon_type) {
458 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 458 return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
459 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE); 459 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE);
460 } 460 }
461 461
462 gfx::ImageSkia GetIcon(const NetworkState* network, 462 gfx::ImageSkia GetIcon(const NetworkState* network,
463 IconType icon_type, 463 IconType icon_type,
464 int strength_index) { 464 int strength_index) {
465 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 465 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
466 const std::string& type = network->type(); 466 const std::string& type = network->type();
467 if (type == flimflam::kTypeEthernet) { 467 if (network->IsTypeEthernet()) {
468 return *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_WIRED); 468 return *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_WIRED);
469 } else if (type == flimflam::kTypeWifi || 469 } else if (type == flimflam::kTypeWifi ||
470 type == flimflam::kTypeWimax || 470 type == flimflam::kTypeWimax ||
471 type == flimflam::kTypeCellular) { 471 type == flimflam::kTypeCellular) {
472 DCHECK(strength_index > 0); 472 DCHECK(strength_index > 0);
473 return GetImageForIndex( 473 return GetImageForIndex(
474 ImageTypeForNetworkType(type), icon_type, strength_index); 474 ImageTypeForNetworkType(type), icon_type, strength_index);
475 } else if (type == flimflam::kTypeVPN) { 475 } else if (type == flimflam::kTypeVPN) {
476 return *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_VPN); 476 return *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_VPN);
477 } else { 477 } else {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // Determine whether or not we need to update the icon. 538 // Determine whether or not we need to update the icon.
539 bool dirty = image_.isNull(); 539 bool dirty = image_.isNull();
540 540
541 // If the network state has changed, the icon needs updating. 541 // If the network state has changed, the icon needs updating.
542 if (state_ != network->connection_state()) { 542 if (state_ != network->connection_state()) {
543 state_ = network->connection_state(); 543 state_ = network->connection_state();
544 dirty = true; 544 dirty = true;
545 } 545 }
546 546
547 const std::string& type = network->type(); 547 const std::string& type = network->type();
548 if (type != flimflam::kTypeEthernet) 548 if (!network->IsTypeEthernet())
549 dirty |= UpdateWirelessStrengthIndex(network); 549 dirty |= UpdateWirelessStrengthIndex(network);
550 550
551 if (type == flimflam::kTypeCellular) 551 if (type == flimflam::kTypeCellular)
552 dirty |= UpdateCellularState(network); 552 dirty |= UpdateCellularState(network);
553 553
554 if (IconTypeHasVPNBadge(icon_type_) && type != flimflam::kTypeVPN) 554 if (IconTypeHasVPNBadge(icon_type_) && type != flimflam::kTypeVPN)
555 dirty |= UpdateVPNBadge(); 555 dirty |= UpdateVPNBadge();
556 556
557 if (dirty) { 557 if (dirty) {
558 // Set the icon and badges based on the network and generate the image. 558 // Set the icon and badges based on the network and generate the image.
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 return l10n_util::GetStringFUTF16( 718 return l10n_util::GetStringFUTF16(
719 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING, UTF8ToUTF16(network->name())); 719 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING, UTF8ToUTF16(network->name()));
720 } 720 }
721 if (activation_state == flimflam::kActivationStateActivating) { 721 if (activation_state == flimflam::kActivationStateActivating) {
722 return l10n_util::GetStringFUTF16( 722 return l10n_util::GetStringFUTF16(
723 IDS_ASH_STATUS_TRAY_NETWORK_ACTIVATING, UTF8ToUTF16(network->name())); 723 IDS_ASH_STATUS_TRAY_NETWORK_ACTIVATING, UTF8ToUTF16(network->name()));
724 } 724 }
725 } 725 }
726 726
727 // Otherwise just show the network name or 'Ethernet'. 727 // Otherwise just show the network name or 'Ethernet'.
728 if (network->type() == flimflam::kTypeEthernet) { 728 if (network->IsTypeEthernet()) {
729 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET); 729 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET);
730 } else { 730 } else {
731 return UTF8ToUTF16(network->name()); 731 return UTF8ToUTF16(network->name());
732 } 732 }
733 } 733 }
734 734
735 int GetCellularUninitializedMsg() { 735 int GetCellularUninitializedMsg() {
736 static base::Time s_uninitialized_state_time; 736 static base::Time s_uninitialized_state_time;
737 static int s_uninitialized_msg(0); 737 static int s_uninitialized_msg(0);
738 738
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 // network. 783 // network.
784 if (connecting_network && 784 if (connecting_network &&
785 (!connected_network || 785 (!connected_network ||
786 connect_handler->HasConnectingNetwork(connecting_network->path()))) { 786 connect_handler->HasConnectingNetwork(connecting_network->path()))) {
787 network = connecting_network; 787 network = connecting_network;
788 } else { 788 } else {
789 network = connected_network; 789 network = connected_network;
790 } 790 }
791 791
792 // Don't show ethernet in the tray 792 // Don't show ethernet in the tray
793 if (icon_type == ICON_TYPE_TRAY && 793 if (icon_type == ICON_TYPE_TRAY && network && network->IsTypeEthernet()) {
794 network && network->type() == flimflam::kTypeEthernet) {
795 *image = gfx::ImageSkia(); 794 *image = gfx::ImageSkia();
796 *animating = false; 795 *animating = false;
797 return; 796 return;
798 } 797 }
799 798
800 if (!network) { 799 if (!network) {
801 // If no connecting network, check if we are activating a network. 800 // If no connecting network, check if we are activating a network.
802 const NetworkState* mobile_network = state_handler->FirstNetworkByType( 801 const NetworkState* mobile_network = state_handler->FirstNetworkByType(
803 NetworkStateHandler::kMatchTypeMobile); 802 NetworkStateHandler::kMatchTypeMobile);
804 if (mobile_network && (mobile_network->activation_state() == 803 if (mobile_network && (mobile_network->activation_state() ==
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 iter != networks.end(); ++iter) { 839 iter != networks.end(); ++iter) {
841 network_paths.insert((*iter)->path()); 840 network_paths.insert((*iter)->path());
842 } 841 }
843 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 842 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
844 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 843 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
845 PurgeIconMap(ICON_TYPE_LIST, network_paths); 844 PurgeIconMap(ICON_TYPE_LIST, network_paths);
846 } 845 }
847 846
848 } // namespace network_icon 847 } // namespace network_icon
849 } // namespace ash 848 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698