OLD | NEW |
---|---|
(Empty) | |
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 | |
5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ | |
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "ui/gfx/image/image_skia.h" | |
11 | |
12 namespace chromeos { | |
13 class NetworkState; | |
14 } | |
15 | |
16 namespace ash { | |
17 | |
18 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
| |
19 public: | |
20 enum ResourceColorTheme { | |
21 COLOR_DARK, | |
22 COLOR_LIGHT, | |
23 }; | |
24 | |
25 class AnimationObserver { | |
26 public: | |
27 virtual ~AnimationObserver() {} | |
28 // Called when the image has changed due to animation. The callback should | |
29 // trigger a call to GetImageForNetwork() to retrieve the image. | |
30 virtual void NetworkIconChanged() = 0; | |
31 }; | |
32 | |
33 NetworkIcon(const std::string& service_path, ResourceColorTheme color); | |
34 | |
35 // Get the image for the network associated with |service_path|. | |
36 // |color| determines the color theme. If the icon is animating (i.e the | |
37 // network is connecting) and |observer| is provided, it will be notified | |
38 // when the icon changes. | |
39 static gfx::ImageSkia GetImageForNetwork( | |
40 const chromeos::NetworkState* network, | |
41 ResourceColorTheme color, | |
42 AnimationObserver* observer); | |
43 | |
44 private: | |
45 // Determines whether or not the associated network might be dirty and if so | |
46 // updates and generates the icon. Does nothing if network no longer exists. | |
47 void Update(const chromeos::NetworkState* network); | |
48 // 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.
| |
49 bool UpdateWirelessStrengthIndex(const chromeos::NetworkState* network); | |
50 // Updates the local state for cellular networks. Returns true if changed. | |
51 bool UpdateCellularState(const chromeos::NetworkState* network); | |
52 // Gets the appropriate icon and badges and composites the image. | |
53 void GenerateImage(const chromeos::NetworkState* network); | |
54 | |
55 const gfx::ImageSkia& image() const { return image_; } | |
56 | |
57 // Service path for the network this icon is associated with. | |
58 std::string service_path_; | |
59 // Color theme for the icon. | |
60 ResourceColorTheme color_; | |
61 // Cached state of the network when the icon was last generated. | |
62 std::string state_; | |
63 // Cached strength index of the network when the icon was last generated. | |
64 int strength_index_; | |
65 // Cached technology badge for the network when the icon was last generated. | |
66 const gfx::ImageSkia* technology_badge_; | |
67 // Cached roaming state of the network when the icon was last generated. | |
68 std::string roaming_state_; | |
69 // Generated icon image. | |
70 gfx::ImageSkia image_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(NetworkIcon); | |
73 }; | |
74 | |
75 } // namespace ash | |
76 | |
77 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_ICON_H_ | |
OLD | NEW |