Chromium Code Reviews| Index: ash/system/network/network_icon.cc |
| diff --git a/ash/system/network/network_icon.cc b/ash/system/network/network_icon.cc |
| index 6d94d2a87e46fc32a96d7cab22f646b84da27993..1dd2223faaf795e535f2bf97d457e457702dee53 100644 |
| --- a/ash/system/network/network_icon.cc |
| +++ b/ash/system/network/network_icon.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <iostream> |
|
Kyle Horimoto
2017/04/27 01:28:07
Remove.
lesliewatkins
2017/04/28 21:30:42
Done.
|
| + |
| #include "ash/system/network/network_icon.h" |
| #include "ash/resources/vector_icons/vector_icons.h" |
| @@ -16,6 +18,7 @@ |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| #include "chromeos/network/portal_detector/network_portal_detector.h" |
| +#include "chromeos/network/tether_constants.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| #include "third_party/skia/include/core/SkPaint.h" |
| #include "third_party/skia/include/core/SkPath.h" |
| @@ -79,7 +82,9 @@ struct Badges { |
| // class used for maintaining a map of network state and images. |
| class NetworkIconImpl { |
| public: |
| - NetworkIconImpl(const std::string& path, IconType icon_type); |
| + NetworkIconImpl(const std::string& path, |
| + IconType icon_type, |
| + const std::string& network_type); |
| // Determines whether or not the associated network might be dirty and if so |
| // updates and generates the icon. Does nothing if network no longer exists. |
| @@ -423,11 +428,25 @@ class SignalStrengthImageSource : public gfx::CanvasImageSource { |
| ImageType ImageTypeForNetworkType(const std::string& type) { |
| if (type == shill::kTypeWifi) |
| return ARCS; |
| - else if (type == shill::kTypeCellular || type == shill::kTypeWimax) |
| + else if (type == shill::kTypeCellular || type == shill::kTypeWimax || |
| + type == chromeos::kTypeTether) |
| return BARS; |
| return NONE; |
| } |
| +// Returns the network type, performing a check to see if Wi-Fi networks |
| +// have an associated Tether network. Used to display the correct icon. |
| +std::string NetworkTypeForIcon(const NetworkState* network) { |
|
Kyle Horimoto
2017/04/27 01:28:07
nit: How about GetEffectiveNetworkType()? This doe
lesliewatkins
2017/04/28 21:30:42
Done.
Kyle Horimoto
2017/04/28 22:07:28
Update the comment as well. "Returns the effective
|
| + if (network->type() == shill::kTypeWifi && !network->tether_guid().empty()) |
| + return chromeos::kTypeTether; |
| + |
| + return network->type(); |
| +} |
| + |
| +ImageType ImageTypeForNetwork(const NetworkState* network) { |
| + return ImageTypeForNetworkType(NetworkTypeForIcon(network)); |
| +} |
| + |
| gfx::ImageSkia GetImageForIndex(ImageType image_type, |
| IconType icon_type, |
| int index) { |
| @@ -533,9 +552,10 @@ gfx::ImageSkia GetIcon(const NetworkState* network, |
| DCHECK_NE(ICON_TYPE_TRAY, icon_type); |
| return gfx::CreateVectorIcon(kNetworkEthernetIcon, |
| GetDefaultColorForIconType(ICON_TYPE_LIST)); |
| - } else if (network->Matches(NetworkTypePattern::Wireless())) { |
| + } else if (network->Matches(NetworkTypePattern::Wireless()) || |
| + network->Matches(NetworkTypePattern::Tether())) { |
| DCHECK(strength_index > 0); |
| - return GetImageForIndex(ImageTypeForNetworkType(network->type()), icon_type, |
| + return GetImageForIndex(ImageTypeForNetwork(network), icon_type, |
| strength_index); |
| } else if (network->Matches(NetworkTypePattern::VPN())) { |
| DCHECK_NE(ICON_TYPE_TRAY, icon_type); |
| @@ -587,13 +607,16 @@ gfx::ImageSkia GetConnectingImage(IconType icon_type, |
| //------------------------------------------------------------------------------ |
| // NetworkIconImpl |
| -NetworkIconImpl::NetworkIconImpl(const std::string& path, IconType icon_type) |
| +NetworkIconImpl::NetworkIconImpl(const std::string& path, |
| + IconType icon_type, |
| + const std::string& network_type) |
| : network_path_(path), |
| icon_type_(icon_type), |
| strength_index_(-1), |
| behind_captive_portal_(false) { |
| // Default image |
| - image_ = GetBasicImage(false, icon_type, shill::kTypeWifi); |
| + std::cout << network_type << std::endl; |
|
Kyle Horimoto
2017/04/27 01:28:07
Remove test logs.
Also, FYI, the preferred loggin
lesliewatkins
2017/04/28 21:30:42
Done.
|
| + image_ = GetBasicImage(false, icon_type, network_type); |
| } |
| void NetworkIconImpl::Update(const NetworkState* network) { |
| @@ -609,7 +632,8 @@ void NetworkIconImpl::Update(const NetworkState* network) { |
| dirty |= UpdatePortalState(network); |
| - if (network->Matches(NetworkTypePattern::Wireless())) { |
| + if (network->Matches(NetworkTypePattern::Wireless()) || |
| + network->Matches(NetworkTypePattern::Tether())) { |
| dirty |= UpdateWirelessStrengthIndex(network); |
| } |
| @@ -733,7 +757,7 @@ NetworkIconImpl* FindAndUpdateImageImpl(const NetworkState* network, |
| NetworkIconImpl* icon; |
| NetworkIconMap::iterator iter = icon_map->find(network->path()); |
| if (iter == icon_map->end()) { |
| - icon = new NetworkIconImpl(network->path(), icon_type); |
| + icon = new NetworkIconImpl(network->path(), icon_type, network->type()); |
| icon_map->insert(std::make_pair(network->path(), icon)); |
| } else { |
| icon = iter->second; |
| @@ -752,11 +776,13 @@ NetworkIconImpl* FindAndUpdateImageImpl(const NetworkState* network, |
| gfx::ImageSkia GetImageForNetwork(const NetworkState* network, |
| IconType icon_type) { |
| DCHECK(network); |
| + std::string network_type = NetworkTypeForIcon(network); |
| + |
| if (!network->visible()) |
| - return GetBasicImage(false, icon_type, network->type()); |
| + return GetBasicImage(false /* not connected */, icon_type, network_type); |
|
Ryan Hansberry
2017/04/27 16:32:26
just 'connected'
lesliewatkins
2017/04/28 21:30:42
Changed to is_connected.
Kyle Horimoto
2017/04/28 22:07:28
You're supposed to match the name of the parameter
|
| if (network->IsConnectingState()) |
| - return GetConnectingImage(icon_type, network->type()); |
| + return GetConnectingImage(icon_type, network_type); |
| NetworkIconImpl* icon = FindAndUpdateImageImpl(network, icon_type); |
| return icon->image(); |