Chromium Code Reviews| Index: ash/system/chromeos/network/network_icon.h |
| diff --git a/ash/system/chromeos/network/network_icon.h b/ash/system/chromeos/network/network_icon.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fed67be24ec7bcb93c28bfc257c693d89321bd98 |
| --- /dev/null |
| +++ b/ash/system/chromeos/network/network_icon.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ |
| +#define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ |
| + |
| +#include <string> |
| + |
| +#include "ui/gfx/image/image_skia.h" |
| + |
| +namespace chromeos { |
| +class NetworkState; |
| +} |
| + |
| +namespace ash { |
| + |
| +class NetworkIcon { |
|
pneubeck (no reviews)
2012/11/21 13:34:45
It seems that only the GetImageForNetwork function
stevenjb
2012/11/27 00:58:18
Moved NetworkIcon into the .cc file, put GetImageF
|
| + public: |
| + enum ResourceColorTheme { |
| + COLOR_DARK, |
| + COLOR_LIGHT, |
| + }; |
| + |
| + class AnimationObserver { |
| + public: |
| + virtual ~AnimationObserver() {} |
| + // Called when the image has changed due to animation. The callback should |
| + // trigger a call to GetImageForNetwork() to retrieve the image. |
| + virtual void NetworkIconChanged() = 0; |
| + }; |
| + |
| + NetworkIcon(const std::string& service_path, ResourceColorTheme color); |
| + |
| + // Get the image for the network associated with |service_path|. |
| + // |color| determines the color theme. If the icon is animating (i.e the |
| + // network is connecting) and |observer| is provided, it will be notified |
| + // when the icon changes. |
| + static gfx::ImageSkia GetImageForNetwork( |
| + const chromeos::NetworkState* network, |
| + ResourceColorTheme color, |
| + AnimationObserver* observer); |
| + |
| + private: |
| + // 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. |
| + void Update(const chromeos::NetworkState* network); |
| + // Updates strength_index_ for wireless networks. Returns true if changed. |
|
pneubeck (no reviews)
2012/11/21 13:34:45
put strength_index_ between || for consistency
ne
stevenjb
2012/11/27 00:58:18
Done.
|
| + bool UpdateWirelessStrengthIndex(const chromeos::NetworkState* network); |
| + // Updates the local state for cellular networks. Returns true if changed. |
| + bool UpdateCellularState(const chromeos::NetworkState* network); |
| + // Gets the appropriate icon and badges and composites the image. |
| + void GenerateImage(const chromeos::NetworkState* network); |
| + |
| + const gfx::ImageSkia& image() const { return image_; } |
| + |
| + // Service path for the network this icon is associated with. |
| + std::string service_path_; |
| + // Color theme for the icon. |
| + ResourceColorTheme color_; |
| + // Cached state of the network when the icon was last generated. |
| + std::string state_; |
| + // Cached strength index of the network when the icon was last generated. |
| + int strength_index_; |
| + // Cached technology badge for the network when the icon was last generated. |
| + const gfx::ImageSkia* technology_badge_; |
| + // Cached roaming state of the network when the icon was last generated. |
| + std::string roaming_state_; |
| + // Generated icon image. |
| + gfx::ImageSkia image_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NetworkIcon); |
| +}; |
| + |
| +} // namespace ash |
| + |
| +#endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ |