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

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

Issue 2817223003: Chrome OS: adjust wifi icons. (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.
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"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 } 429 }
430 430
431 gfx::ImageSkia GetImageForIndex(ImageType image_type, 431 gfx::ImageSkia GetImageForIndex(ImageType image_type,
432 IconType icon_type, 432 IconType icon_type,
433 int index) { 433 int index) {
434 gfx::CanvasImageSource* source = 434 gfx::CanvasImageSource* source =
435 new SignalStrengthImageSource(image_type, icon_type, index); 435 new SignalStrengthImageSource(image_type, icon_type, index);
436 return gfx::ImageSkia(source, source->size()); 436 return gfx::ImageSkia(source, source->size());
437 } 437 }
438 438
439 // Returns an image to represent either a fully connected/enabled network or a 439 // Returns an image to represent either a fully connected network or a
440 // disconnected/disabled network. 440 // disconnected network.
441 const gfx::ImageSkia GetBasicImage(bool connected, 441 const gfx::ImageSkia GetBasicImage(bool connected,
442 IconType icon_type, 442 IconType icon_type,
443 const std::string& network_type) { 443 const std::string& network_type) {
444 DCHECK_NE(shill::kTypeVPN, network_type); 444 DCHECK_NE(shill::kTypeVPN, network_type);
445 SignalStrengthImageSource* source = new SignalStrengthImageSource( 445 return GetImageForIndex(ImageTypeForNetworkType(network_type), icon_type,
446 ImageTypeForNetworkType(network_type), icon_type, kNumNetworkImages - 1); 446 connected ? kNumNetworkImages - 1 : 0);
447 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size());
448 Badges badges;
449 if (!connected) {
450 badges.center = {&kNetworkBadgeOffIcon,
451 GetDefaultColorForIconType(icon_type)};
452 }
453 return NetworkIconImageSource::CreateImage(icon, badges);
454 } 447 }
455 448
456 gfx::ImageSkia* ConnectingWirelessImage(ImageType image_type, 449 gfx::ImageSkia* ConnectingWirelessImage(ImageType image_type,
457 IconType icon_type, 450 IconType icon_type,
458 double animation) { 451 double animation) {
459 static const int kImageCount = kNumNetworkImages - 1; 452 static const int kImageCount = kNumNetworkImages - 1;
460 static gfx::ImageSkia* s_bars_images_dark[kImageCount]; 453 static gfx::ImageSkia* s_bars_images_dark[kImageCount];
461 static gfx::ImageSkia* s_bars_images_light[kImageCount]; 454 static gfx::ImageSkia* s_bars_images_light[kImageCount];
462 static gfx::ImageSkia* s_arcs_images_dark[kImageCount]; 455 static gfx::ImageSkia* s_arcs_images_dark[kImageCount];
463 static gfx::ImageSkia* s_arcs_images_light[kImageCount]; 456 static gfx::ImageSkia* s_arcs_images_light[kImageCount];
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 if (!network->visible()) 755 if (!network->visible())
763 return GetBasicImage(false, icon_type, network->type()); 756 return GetBasicImage(false, icon_type, network->type());
764 757
765 if (network->IsConnectingState()) 758 if (network->IsConnectingState())
766 return GetConnectingImage(icon_type, network->type()); 759 return GetConnectingImage(icon_type, network->type());
767 760
768 NetworkIconImpl* icon = FindAndUpdateImageImpl(network, icon_type); 761 NetworkIconImpl* icon = FindAndUpdateImageImpl(network, icon_type);
769 return icon->image(); 762 return icon->image();
770 } 763 }
771 764
772 gfx::ImageSkia GetBasicImageForWiFiNetwork(bool connected) { 765 gfx::ImageSkia GetImageForWiFiChipState(bool enabled, IconType icon_type) {
773 return GetBasicImage(connected, ICON_TYPE_LIST, shill::kTypeWifi); 766 gfx::ImageSkia image = GetBasicImage(true, icon_type, shill::kTypeWifi);
stevenjb 2017/04/17 16:22:52 true /* connected */,
Evan Stade 2017/04/17 16:29:33 Done.
767 Badges badges;
768 if (!enabled) {
769 badges.center = {&kNetworkBadgeOffIcon,
770 GetDefaultColorForIconType(icon_type)};
771 }
772 return NetworkIconImageSource::CreateImage(image, badges);
774 } 773 }
775 774
776 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { 775 gfx::ImageSkia GetImageForDisconnectedCellNetwork() {
777 return GetBasicImage(false, ICON_TYPE_LIST, shill::kTypeCellular); 776 return GetBasicImage(false, ICON_TYPE_LIST, shill::kTypeCellular);
778 } 777 }
779 778
780 gfx::ImageSkia GetImageForNewWifiNetwork(SkColor icon_color, 779 gfx::ImageSkia GetImageForNewWifiNetwork(SkColor icon_color,
781 SkColor badge_color) { 780 SkColor badge_color) {
782 SignalStrengthImageSource* source = 781 SignalStrengthImageSource* source =
783 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi), 782 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi),
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 } 922 }
924 if (!network) { 923 if (!network) {
925 // If no connecting network, check for cellular initializing. 924 // If no connecting network, check for cellular initializing.
926 int uninitialized_msg = GetCellularUninitializedMsg(); 925 int uninitialized_msg = GetCellularUninitializedMsg();
927 if (uninitialized_msg != 0) { 926 if (uninitialized_msg != 0) {
928 *image = GetConnectingImage(icon_type, shill::kTypeCellular); 927 *image = GetConnectingImage(icon_type, shill::kTypeCellular);
929 if (label) 928 if (label)
930 *label = l10n_util::GetStringUTF16(uninitialized_msg); 929 *label = l10n_util::GetStringUTF16(uninitialized_msg);
931 *animating = true; 930 *animating = true;
932 } else { 931 } else {
933 // Otherwise show the disconnected wifi icon. 932 // Otherwise show a Wi-Fi icon. If Wi-Fi is disabled, show a full icon
934 *image = GetBasicImage(false, icon_type, shill::kTypeWifi); 933 // with a strikethrough. If it's enabled then it's disconnected, so show
934 // an empty wedge.
935 bool wifi_enabled =
936 NetworkHandler::Get()->network_state_handler()->IsTechnologyEnabled(
937 NetworkTypePattern::WiFi());
938 *image = wifi_enabled ? GetBasicImage(false, icon_type, shill::kTypeWifi)
stevenjb 2017/04/17 16:22:52 false /* not connected */,
Evan Stade 2017/04/17 16:29:33 Done.
939 : GetImageForWiFiChipState(false, icon_type);
stevenjb 2017/04/17 16:22:52 false /* not enabled */
Evan Stade 2017/04/17 16:29:33 Done.
935 if (label) { 940 if (label) {
936 *label = l10n_util::GetStringUTF16( 941 *label = l10n_util::GetStringUTF16(
937 IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED); 942 IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED);
938 } 943 }
939 *animating = false; 944 *animating = false;
940 } 945 }
941 return; 946 return;
942 } 947 }
943 *animating = network->IsConnectingState(); 948 *animating = network->IsConnectingState();
944 // Get icon and label for connected or connecting network. 949 // Get icon and label for connected or connecting network.
(...skipping 12 matching lines...) Expand all
957 network_paths.insert((*iter)->path()); 962 network_paths.insert((*iter)->path());
958 } 963 }
959 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 964 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
960 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 965 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
961 PurgeIconMap(ICON_TYPE_LIST, network_paths); 966 PurgeIconMap(ICON_TYPE_LIST, network_paths);
962 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); 967 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths);
963 } 968 }
964 969
965 } // namespace network_icon 970 } // namespace network_icon
966 } // namespace ash 971 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698