network_icon.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_NETWORK_NETWORK_ICON_H_
  5. #define ASH_SYSTEM_NETWORK_NETWORK_ICON_H_
  6. #include <set>
  7. #include <string>
  8. #include "ash/ash_export.h"
  9. #include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h"
  10. #include "chromeos/services/network_config/public/mojom/network_types.mojom-forward.h"
  11. #include "ui/gfx/canvas.h"
  12. #include "ui/gfx/image/canvas_image_source.h"
  13. #include "ui/gfx/image/image_skia.h"
  14. namespace ash {
  15. namespace network_icon {
  16. // Type of icon which dictates color theme and VPN badging
  17. enum IconType {
  18. ICON_TYPE_TRAY_OOBE, // dark icons with VPN badges, used during OOBE
  19. ICON_TYPE_TRAY_REGULAR, // light icons with VPN badges, used outside of OOBE
  20. ICON_TYPE_DEFAULT_VIEW, // dark icons with VPN badges
  21. ICON_TYPE_LIST, // dark icons without VPN badges; in-line status
  22. ICON_TYPE_FEATURE_POD, // icons in the network feature pod button in system
  23. // menu
  24. ICON_TYPE_FEATURE_POD_TOGGLED, // toggled icons in the network feature pod
  25. // button in system menu
  26. ICON_TYPE_FEATURE_POD_DISABLED, // disabled icons in the network feature pod
  27. // button in system menu
  28. ICON_TYPE_MENU_LIST, // dark icons without VPN badges; separate status
  29. };
  30. // Strength of a wireless signal.
  31. enum class SignalStrength { NONE, WEAK, MEDIUM, STRONG };
  32. // Returns the color of an icon on the given |icon_type|.
  33. SkColor GetDefaultColorForIconType(IconType icon_type);
  34. // Returns an image to represent either a fully connected network or a
  35. // disconnected network.
  36. const gfx::ImageSkia GetBasicImage(
  37. IconType icon_type,
  38. chromeos::network_config::mojom::NetworkType network_type,
  39. bool connected);
  40. // Returns and caches an image for non VPN |network| which must not be null.
  41. // Use this for non virtual networks and for the default (tray) icon.
  42. // |icon_type| determines the color theme.
  43. // |badge_vpn| should be true if a VPN is also connected and a badge is desired.
  44. // |animating| is an optional out parameter that is set to true when the
  45. // returned image should be animated.
  46. ASH_EXPORT gfx::ImageSkia GetImageForNonVirtualNetwork(
  47. const chromeos::network_config::mojom::NetworkStateProperties* network,
  48. IconType icon_type,
  49. bool badge_vpn,
  50. bool* animating = nullptr);
  51. // Similar to above but for displaying only VPN icons, e.g. for the VPN menu
  52. // or Settings section.
  53. ASH_EXPORT gfx::ImageSkia GetImageForVPN(
  54. const chromeos::network_config::mojom::NetworkStateProperties* vpn,
  55. IconType icon_type,
  56. bool* animating = nullptr);
  57. // Returns an image for Wi-Fi with no connections available, Wi-Fi icon with
  58. // a cross in the center.
  59. ASH_EXPORT gfx::ImageSkia GetImageForWiFiNoConnections(IconType icon_type);
  60. // Returns an image for a Wi-Fi network, either full strength or strike-through
  61. // based on |enabled|.
  62. ASH_EXPORT gfx::ImageSkia GetImageForWiFiEnabledState(
  63. bool enabled,
  64. IconType = ICON_TYPE_DEFAULT_VIEW);
  65. // Returns the connecting image for a shill network non-VPN type.
  66. gfx::ImageSkia GetConnectingImageForNetworkType(
  67. chromeos::network_config::mojom::NetworkType network_type,
  68. IconType icon_type);
  69. // Returns the connected image for |connected_network| and |network_type| with a
  70. // connecting VPN badge.
  71. gfx::ImageSkia GetConnectedNetworkWithConnectingVpnImage(
  72. const chromeos::network_config::mojom::NetworkStateProperties*
  73. connected_network,
  74. IconType icon_type);
  75. // Returns the disconnected image for a shill network type.
  76. gfx::ImageSkia GetDisconnectedImageForNetworkType(
  77. chromeos::network_config::mojom::NetworkType network_type);
  78. // Returns the label for |network| when displayed in a list.
  79. ASH_EXPORT std::u16string GetLabelForNetworkList(
  80. const chromeos::network_config::mojom::NetworkStateProperties* network);
  81. // Called periodically with the current list of network guids. Removes cached
  82. // entries that are no longer in the list.
  83. ASH_EXPORT void PurgeNetworkIconCache(
  84. const std::set<std::string>& network_guids);
  85. // Called by ChromeVox to give a verbal indication of the network icon. Returns
  86. // a signal strength enum for |strength| value 0-100.
  87. ASH_EXPORT SignalStrength GetSignalStrength(int strength);
  88. } // namespace network_icon
  89. } // namespace ash
  90. #endif // ASH_SYSTEM_NETWORK_NETWORK_ICON_H_