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

Side by Side Diff: ash/system/network/network_icon.cc

Issue 2819303002: Changed wifi arcs to mobile bars for Tether network. (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
Kyle Horimoto 2017/04/17 19:50:04 Please add unit tests for the changes you made in
lesliewatkins 2017/04/29 00:57:53 Done.
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/network/network_icon.h" 5 #include "ash/system/network/network_icon.h"
6 6
7 #include "ash/resources/vector_icons/vector_icons.h" 7 #include "ash/resources/vector_icons/vector_icons.h"
8 #include "ash/strings/grit/ash_strings.h" 8 #include "ash/strings/grit/ash_strings.h"
9 #include "ash/system/network/network_icon_animation.h" 9 #include "ash/system/network/network_icon_animation.h"
10 #include "ash/system/network/network_icon_animation_observer.h" 10 #include "ash/system/network/network_icon_animation_observer.h"
11 #include "ash/system/tray/tray_constants.h" 11 #include "ash/system/tray/tray_constants.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 416
417 DISALLOW_COPY_AND_ASSIGN(SignalStrengthImageSource); 417 DISALLOW_COPY_AND_ASSIGN(SignalStrengthImageSource);
418 }; 418 };
419 419
420 //------------------------------------------------------------------------------ 420 //------------------------------------------------------------------------------
421 // Utilities for extracting icon images. 421 // Utilities for extracting icon images.
422 422
423 ImageType ImageTypeForNetworkType(const std::string& type) { 423 ImageType ImageTypeForNetworkType(const std::string& type) {
424 if (type == shill::kTypeWifi) 424 if (type == shill::kTypeWifi)
425 return ARCS; 425 return ARCS;
426 else if (type == shill::kTypeCellular || type == shill::kTypeWimax) 426 else if (type == shill::kTypeCellular || type == shill::kTypeWimax ||
427 type == chromeos::kTypeTether)
427 return BARS; 428 return BARS;
428 return NONE; 429 return NONE;
429 } 430 }
430 431
432 ImageType ImageTypeForNetwork(const NetworkState* network) {
433 if (network->type() == shill::kTypeWifi && !network->tether_guid().empty())
Kyle Horimoto 2017/04/17 19:50:04 Add a comment explaining what this means.
lesliewatkins 2017/04/27 00:33:53 Done.
434 return ImageTypeForNetworkType(chromeos::kTypeTether);
435
436 return ImageTypeForNetworkType(network->type());
437 }
438
431 gfx::ImageSkia GetImageForIndex(ImageType image_type, 439 gfx::ImageSkia GetImageForIndex(ImageType image_type,
432 IconType icon_type, 440 IconType icon_type,
433 int index) { 441 int index) {
434 gfx::CanvasImageSource* source = 442 gfx::CanvasImageSource* source =
435 new SignalStrengthImageSource(image_type, icon_type, index); 443 new SignalStrengthImageSource(image_type, icon_type, index);
436 return gfx::ImageSkia(source, source->size()); 444 return gfx::ImageSkia(source, source->size());
437 } 445 }
438 446
439 // Returns an image to represent either a fully connected/enabled network or a 447 // Returns an image to represent either a fully connected/enabled network or a
440 // disconnected/disabled network. 448 // disconnected/disabled network.
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 543
536 gfx::ImageSkia GetIcon(const NetworkState* network, 544 gfx::ImageSkia GetIcon(const NetworkState* network,
537 IconType icon_type, 545 IconType icon_type,
538 int strength_index) { 546 int strength_index) {
539 if (network->Matches(NetworkTypePattern::Ethernet())) { 547 if (network->Matches(NetworkTypePattern::Ethernet())) {
540 DCHECK_NE(ICON_TYPE_TRAY, icon_type); 548 DCHECK_NE(ICON_TYPE_TRAY, icon_type);
541 return gfx::CreateVectorIcon(kNetworkEthernetIcon, 549 return gfx::CreateVectorIcon(kNetworkEthernetIcon,
542 GetDefaultColorForIconType(ICON_TYPE_LIST)); 550 GetDefaultColorForIconType(ICON_TYPE_LIST));
543 } else if (network->Matches(NetworkTypePattern::Wireless())) { 551 } else if (network->Matches(NetworkTypePattern::Wireless())) {
544 DCHECK(strength_index > 0); 552 DCHECK(strength_index > 0);
545 return GetImageForIndex(ImageTypeForNetworkType(network->type()), icon_type, 553 return GetImageForIndex(ImageTypeForNetwork(network), icon_type,
546 strength_index); 554 strength_index);
547 } else if (network->Matches(NetworkTypePattern::VPN())) { 555 } else if (network->Matches(NetworkTypePattern::VPN())) {
548 DCHECK_NE(ICON_TYPE_TRAY, icon_type); 556 DCHECK_NE(ICON_TYPE_TRAY, icon_type);
549 return gfx::CreateVectorIcon(kNetworkVpnIcon, 557 return gfx::CreateVectorIcon(kNetworkVpnIcon,
550 GetDefaultColorForIconType(ICON_TYPE_LIST)); 558 GetDefaultColorForIconType(ICON_TYPE_LIST));
551 } 559 }
552 560
553 NOTREACHED() << "Request for icon for unsupported type: " << network->type(); 561 NOTREACHED() << "Request for icon for unsupported type: " << network->type();
554 return gfx::ImageSkia(); 562 return gfx::ImageSkia();
555 } 563 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 } 760 }
753 761
754 } // namespace 762 } // namespace
755 763
756 //------------------------------------------------------------------------------ 764 //------------------------------------------------------------------------------
757 // Public interface 765 // Public interface
758 766
759 gfx::ImageSkia GetImageForNetwork(const NetworkState* network, 767 gfx::ImageSkia GetImageForNetwork(const NetworkState* network,
760 IconType icon_type) { 768 IconType icon_type) {
761 DCHECK(network); 769 DCHECK(network);
770 std::string network_type = network->type();
771
762 if (!network->visible()) 772 if (!network->visible())
763 return GetBasicImage(false, icon_type, network->type()); 773 return GetBasicImage(false, icon_type, network_type);
Kyle Horimoto 2017/04/17 19:50:04 nit: Add /* parameter_name */ after "false" so tha
lesliewatkins 2017/04/27 00:33:53 Done.
774
775 if (!network->tether_guid().empty()) {
Kyle Horimoto 2017/04/17 19:50:03 Also add an explanatory comment here.
lesliewatkins 2017/04/27 00:33:53 Done.
776 network_type = chromeos::kTypeTether;
Kyle Horimoto 2017/04/17 19:50:03 You do this check in ImageTypeForNetwork as well.
lesliewatkins 2017/04/27 00:33:53 Done.
777 }
764 778
765 if (network->IsConnectingState()) 779 if (network->IsConnectingState())
766 return GetConnectingImage(icon_type, network->type()); 780 return GetConnectingImage(icon_type, network_type);
767 781
768 NetworkIconImpl* icon = FindAndUpdateImageImpl(network, icon_type); 782 NetworkIconImpl* icon = FindAndUpdateImageImpl(network, icon_type);
769 return icon->image(); 783 return icon->image();
770 } 784 }
771 785
772 gfx::ImageSkia GetBasicImageForWiFiNetwork(bool connected) { 786 gfx::ImageSkia GetBasicImageForWiFiNetwork(bool connected) {
773 return GetBasicImage(connected, ICON_TYPE_LIST, shill::kTypeWifi); 787 return GetBasicImage(connected, ICON_TYPE_LIST, shill::kTypeWifi);
774 } 788 }
775 789
776 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { 790 gfx::ImageSkia GetImageForDisconnectedCellNetwork() {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 network_paths.insert((*iter)->path()); 971 network_paths.insert((*iter)->path());
958 } 972 }
959 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 973 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
960 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 974 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
961 PurgeIconMap(ICON_TYPE_LIST, network_paths); 975 PurgeIconMap(ICON_TYPE_LIST, network_paths);
962 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); 976 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths);
963 } 977 }
964 978
965 } // namespace network_icon 979 } // namespace network_icon
966 } // namespace ash 980 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698