Commit fbdbb16c authored by Ahmed Mehfooz's avatar Ahmed Mehfooz Committed by Chromium LUCI CQ

Add support to update network icon when dark/light mode is toggled

Bug: 1169404
Change-Id: I458dee6a73e071f9f4d99dabf3907e5afb45963d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642925Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Ahmed Mehfooz <amehfooz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846354}
parent 9cc2d52e
...@@ -62,6 +62,8 @@ class ASH_EXPORT ActiveNetworkIcon : public TrayNetworkStateObserver { ...@@ -62,6 +62,8 @@ class ASH_EXPORT ActiveNetworkIcon : public TrayNetworkStateObserver {
network_icon::IconType icon_type, network_icon::IconType icon_type,
bool* animating); bool* animating);
void PurgeNetworkIconCache();
private: private:
gfx::ImageSkia GetSingleImage(network_icon::IconType icon_type, gfx::ImageSkia GetSingleImage(network_icon::IconType icon_type,
bool* animating); bool* animating);
...@@ -86,7 +88,6 @@ class ASH_EXPORT ActiveNetworkIcon : public TrayNetworkStateObserver { ...@@ -86,7 +88,6 @@ class ASH_EXPORT ActiveNetworkIcon : public TrayNetworkStateObserver {
void ActiveNetworkStateChanged() override; void ActiveNetworkStateChanged() override;
void NetworkListChanged() override; void NetworkListChanged() override;
void PurgeNetworkIconCache();
const chromeos::network_config::mojom::NetworkStateProperties* const chromeos::network_config::mojom::NetworkStateProperties*
GetNetworkForType(Type type); GetNetworkForType(Type type);
......
...@@ -136,6 +136,17 @@ void NetworkFeaturePodButton::ActiveNetworkStateChanged() { ...@@ -136,6 +136,17 @@ void NetworkFeaturePodButton::ActiveNetworkStateChanged() {
Update(); Update();
} }
void NetworkFeaturePodButton::OnThemeChanged() {
FeaturePodButton::OnThemeChanged();
// Need to redraw all network icons with new colors.
Shell::Get()
->system_tray_model()
->active_network_icon()
->PurgeNetworkIconCache();
NetworkIconChanged();
}
const char* NetworkFeaturePodButton::GetClassName() const { const char* NetworkFeaturePodButton::GetClassName() const {
return "NetworkFeaturePodButton"; return "NetworkFeaturePodButton";
} }
......
...@@ -31,6 +31,7 @@ class NetworkFeaturePodButton : public FeaturePodButton, ...@@ -31,6 +31,7 @@ class NetworkFeaturePodButton : public FeaturePodButton,
void ActiveNetworkStateChanged() override; void ActiveNetworkStateChanged() override;
// views::Button: // views::Button:
void OnThemeChanged() override;
const char* GetClassName() const override; const char* GetClassName() const override;
private: private:
......
...@@ -79,6 +79,7 @@ class NetworkIconImpl { ...@@ -79,6 +79,7 @@ class NetworkIconImpl {
Badge technology_badge_ = {}; Badge technology_badge_ = {};
bool show_vpn_badge_ = false; bool show_vpn_badge_ = false;
bool is_roaming_ = false; bool is_roaming_ = false;
bool is_dark_themed_ = false;
// Generated icon image. // Generated icon image.
gfx::ImageSkia image_; gfx::ImageSkia image_;
...@@ -300,7 +301,8 @@ gfx::ImageSkia GetConnectingVpnImage(IconType icon_type) { ...@@ -300,7 +301,8 @@ gfx::ImageSkia GetConnectingVpnImage(IconType icon_type) {
NetworkIconImpl::NetworkIconImpl(const std::string& guid, NetworkIconImpl::NetworkIconImpl(const std::string& guid,
IconType icon_type, IconType icon_type,
NetworkType network_type) NetworkType network_type)
: icon_type_(icon_type) { : icon_type_(icon_type),
is_dark_themed_(AshColorProvider::Get()->IsDarkModeEnabled()) {
// Default image is null. // Default image is null.
} }
...@@ -332,6 +334,11 @@ void NetworkIconImpl::Update(const NetworkStateProperties* network, ...@@ -332,6 +334,11 @@ void NetworkIconImpl::Update(const NetworkStateProperties* network,
dirty = true; dirty = true;
} }
if (is_dark_themed_ != AshColorProvider::Get()->IsDarkModeEnabled()) {
is_dark_themed_ = AshColorProvider::Get()->IsDarkModeEnabled();
dirty = true;
}
if (dirty) { if (dirty) {
// Set the icon and badges based on the network and generate the image. // Set the icon and badges based on the network and generate the image.
GenerateImage(network); GenerateImage(network);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment