| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 GetImageForWiFiEnabledState(bool enabled, IconType icon_type) { |
| 773 return GetBasicImage(connected, ICON_TYPE_LIST, shill::kTypeWifi); | 766 gfx::ImageSkia image = |
| 767 GetBasicImage(true /* connected */, icon_type, shill::kTypeWifi); |
| 768 Badges badges; |
| 769 if (!enabled) { |
| 770 badges.center = {&kNetworkBadgeOffIcon, |
| 771 GetDefaultColorForIconType(icon_type)}; |
| 772 } |
| 773 return NetworkIconImageSource::CreateImage(image, badges); |
| 774 } | 774 } |
| 775 | 775 |
| 776 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { | 776 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { |
| 777 return GetBasicImage(false, ICON_TYPE_LIST, shill::kTypeCellular); | 777 return GetBasicImage(false /* not connected */, ICON_TYPE_LIST, |
| 778 shill::kTypeCellular); |
| 778 } | 779 } |
| 779 | 780 |
| 780 gfx::ImageSkia GetImageForNewWifiNetwork(SkColor icon_color, | 781 gfx::ImageSkia GetImageForNewWifiNetwork(SkColor icon_color, |
| 781 SkColor badge_color) { | 782 SkColor badge_color) { |
| 782 SignalStrengthImageSource* source = | 783 SignalStrengthImageSource* source = |
| 783 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi), | 784 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi), |
| 784 ICON_TYPE_LIST, kNumNetworkImages - 1); | 785 ICON_TYPE_LIST, kNumNetworkImages - 1); |
| 785 source->set_color(icon_color); | 786 source->set_color(icon_color); |
| 786 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size()); | 787 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size()); |
| 787 Badges badges; | 788 Badges badges; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 } | 924 } |
| 924 if (!network) { | 925 if (!network) { |
| 925 // If no connecting network, check for cellular initializing. | 926 // If no connecting network, check for cellular initializing. |
| 926 int uninitialized_msg = GetCellularUninitializedMsg(); | 927 int uninitialized_msg = GetCellularUninitializedMsg(); |
| 927 if (uninitialized_msg != 0) { | 928 if (uninitialized_msg != 0) { |
| 928 *image = GetConnectingImage(icon_type, shill::kTypeCellular); | 929 *image = GetConnectingImage(icon_type, shill::kTypeCellular); |
| 929 if (label) | 930 if (label) |
| 930 *label = l10n_util::GetStringUTF16(uninitialized_msg); | 931 *label = l10n_util::GetStringUTF16(uninitialized_msg); |
| 931 *animating = true; | 932 *animating = true; |
| 932 } else { | 933 } else { |
| 933 // Otherwise show the disconnected wifi icon. | 934 // Otherwise show a Wi-Fi icon. If Wi-Fi is disabled, show a full icon |
| 934 *image = GetBasicImage(false, icon_type, shill::kTypeWifi); | 935 // with a strikethrough. If it's enabled then it's disconnected, so show |
| 936 // an empty wedge. |
| 937 bool wifi_enabled = |
| 938 NetworkHandler::Get()->network_state_handler()->IsTechnologyEnabled( |
| 939 NetworkTypePattern::WiFi()); |
| 940 *image = wifi_enabled ? GetBasicImage(false /* not connected */, |
| 941 icon_type, shill::kTypeWifi) |
| 942 : GetImageForWiFiEnabledState( |
| 943 false /* not enabled*/, icon_type); |
| 935 if (label) { | 944 if (label) { |
| 936 *label = l10n_util::GetStringUTF16( | 945 *label = l10n_util::GetStringUTF16( |
| 937 IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED); | 946 IDS_ASH_STATUS_TRAY_NETWORK_NOT_CONNECTED); |
| 938 } | 947 } |
| 939 *animating = false; | 948 *animating = false; |
| 940 } | 949 } |
| 941 return; | 950 return; |
| 942 } | 951 } |
| 943 *animating = network->IsConnectingState(); | 952 *animating = network->IsConnectingState(); |
| 944 // Get icon and label for connected or connecting network. | 953 // Get icon and label for connected or connecting network. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 957 network_paths.insert((*iter)->path()); | 966 network_paths.insert((*iter)->path()); |
| 958 } | 967 } |
| 959 PurgeIconMap(ICON_TYPE_TRAY, network_paths); | 968 PurgeIconMap(ICON_TYPE_TRAY, network_paths); |
| 960 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); | 969 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); |
| 961 PurgeIconMap(ICON_TYPE_LIST, network_paths); | 970 PurgeIconMap(ICON_TYPE_LIST, network_paths); |
| 962 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); | 971 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); |
| 963 } | 972 } |
| 964 | 973 |
| 965 } // namespace network_icon | 974 } // namespace network_icon |
| 966 } // namespace ash | 975 } // namespace ash |
| OLD | NEW |