File: network_icon.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (143 lines) | stat: -rw-r--r-- 5,947 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_NETWORK_NETWORK_ICON_H_
#define ASH_SYSTEM_NETWORK_NETWORK_ICON_H_

#include <set>
#include <string>

#include "ash/ash_export.h"
#include "chromeos/services/network_config/public/mojom/cros_network_config.mojom-forward.h"
#include "chromeos/services/network_config/public/mojom/network_types.mojom-forward.h"
#include "ui/base/models/image_model.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia.h"

namespace ash {
namespace network_icon {

// Type of icon which dictates color theme and VPN badging
enum IconType {
  ICON_TYPE_TRAY_OOBE,     // dark icons with VPN badges, used during OOBE
  ICON_TYPE_TRAY_REGULAR,  // light icons with VPN badges, used outside of OOBE
  ICON_TYPE_TRAY_ACTIVE,   // icons with VPN badges, used when the tray is
                           // active
  ICON_TYPE_DEFAULT_VIEW,  // dark icons with VPN badges
  ICON_TYPE_LIST,          // dark icons without VPN badges; in-line status
  ICON_TYPE_FEATURE_POD,   // icons in the network feature pod button in system
                           // menu
  ICON_TYPE_FEATURE_POD_TOGGLED,   // toggled icons in the network feature pod
                                   // button in system menu
  ICON_TYPE_FEATURE_POD_DISABLED,  // disabled icons in the network feature pod
                                   // button in system menu
  ICON_TYPE_MENU_LIST,  // dark icons without VPN badges; separate status
};

// Strength of a wireless signal.
enum class SignalStrength { NONE, WEAK, MEDIUM, STRONG };

// Returns the color of an icon on the given |icon_type|.
SkColor GetDefaultColorForIconType(const ui::ColorProvider* color_provider,
                                   IconType icon_type);

// Returns an image to represent either a fully connected network or a
// disconnected network.
const gfx::ImageSkia GetBasicImage(
    const ui::ColorProvider* color_provider,
    IconType icon_type,
    chromeos::network_config::mojom::NetworkType network_type,
    bool connected);

// Returns and caches an image for non VPN |network| which must not be null.
// Use this for non virtual networks and for the default (tray) icon.
// |color_provider| and |icon_type| are used to determine the color theme.
// |badge_vpn| should be true if a VPN is also connected and a badge is desired.
// |animating| is an optional out parameter that is set to true when the
// returned image should be animated.
ASH_EXPORT gfx::ImageSkia GetImageForNonVirtualNetwork(
    const ui::ColorProvider* color_provider,
    const chromeos::network_config::mojom::NetworkStateProperties* network,
    IconType icon_type,
    bool badge_vpn,
    bool* animating = nullptr);

// Similar to above but for displaying only VPN icons, e.g. for the VPN menu
// or Settings section.
ASH_EXPORT gfx::ImageSkia GetImageForVPN(
    const ui::ColorProvider* color_provider,
    const chromeos::network_config::mojom::NetworkStateProperties* vpn,
    IconType icon_type,
    bool* animating = nullptr);

// Returns an image for Wi-Fi with no connections available, Wi-Fi icon with
// a cross in the center.
ASH_EXPORT gfx::ImageSkia GetImageForWiFiNoConnections(
    const ui::ColorProvider* color_provider,
    IconType icon_type);

// Returns an image for an unactivated PSim when device is not logged in or in
// OOBE.
ASH_EXPORT gfx::ImageSkia GetImageForPSimPendingActivationWhileLoggedOut(
    const ui::ColorProvider* color_provider,
    IconType icon_type);

// Returns an image for an carrier locked cellular network.
ASH_EXPORT gfx::ImageSkia GetImageForCarrierLockedNetwork(
    const ui::ColorProvider* color_provider,
    IconType icon_type);

// Returns an image for a Wi-Fi network, either full strength or strike-through
// based on |enabled|.
ASH_EXPORT gfx::ImageSkia GetImageForWiFiEnabledState(
    const ui::ColorProvider* color_provider,
    bool enabled,
    IconType = ICON_TYPE_DEFAULT_VIEW);

// Returns an image for a Wi-Fi network, either full strength or strike-through
// based on |enabled|. Note that this method uses the window background color
// to color the image.
ASH_EXPORT ui::ImageModel GetImageModelForWiFiEnabledState(
    bool wifi_enabled,
    IconType icon_type = ICON_TYPE_DEFAULT_VIEW);

// Returns the connecting image for a shill network non-VPN type.
gfx::ImageSkia GetConnectingImageForNetworkType(
    const ui::ColorProvider* color_provider,
    chromeos::network_config::mojom::NetworkType network_type,
    IconType icon_type);

// Returns the connected image for |connected_network| and |network_type| with a
// connecting VPN badge.
gfx::ImageSkia GetConnectedNetworkWithConnectingVpnImage(
    const ui::ColorProvider* color_provider,
    const chromeos::network_config::mojom::NetworkStateProperties*
        connected_network,
    IconType icon_type);

// Returns the disconnected image for a shill network type.
gfx::ImageSkia GetDisconnectedImageForNetworkType(
    const ui::ColorProvider* color_provider,
    chromeos::network_config::mojom::NetworkType network_type,
    IconType icon_type);

// Returns the label for |network| when displayed in a list.
ASH_EXPORT std::u16string GetLabelForNetworkList(
    const chromeos::network_config::mojom::NetworkStateProperties* network);

// Called periodically with the current list of network guids. Removes cached
// entries that are no longer in the list.
ASH_EXPORT void PurgeNetworkIconCache(
    const std::set<std::string>& network_guids);

// Called by ChromeVox to give a verbal indication of the network icon. Returns
// a signal strength enum for |strength| value 0-100.
ASH_EXPORT SignalStrength GetSignalStrength(int strength);

}  // namespace network_icon
}  // namespace ash

#endif  // ASH_SYSTEM_NETWORK_NETWORK_ICON_H_