Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ash/common/system/chromeos/network/network_icon.cc

Issue 2761313003: Update appearance of Wi-Fi toggle notification. (Closed)
Patch Set: one more rename Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/network/network_icon.h" 5 #include "ash/common/system/chromeos/network/network_icon.h"
6 6
7 #include "ash/common/system/chromeos/network/network_icon_animation.h" 7 #include "ash/common/system/chromeos/network/network_icon_animation.h"
8 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h" 8 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h"
9 #include "ash/common/system/tray/tray_constants.h" 9 #include "ash/common/system/tray/tray_constants.h"
10 #include "ash/resources/grit/ash_resources.h" 10 #include "ash/resources/grit/ash_resources.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // The badge offsets are different depending on whether the icon is in the tray 54 // The badge offsets are different depending on whether the icon is in the tray
55 // or menu. 55 // or menu.
56 const int kTrayIconBadgeOffset = 3; 56 const int kTrayIconBadgeOffset = 3;
57 const int kMenuIconBadgeOffset = 2; 57 const int kMenuIconBadgeOffset = 2;
58 58
59 //------------------------------------------------------------------------------ 59 //------------------------------------------------------------------------------
60 // Struct to pass icon badges to NetworkIconImageSource. 60 // Struct to pass icon badges to NetworkIconImageSource.
61 struct Badges { 61 struct Badges {
62 gfx::ImageSkia top_left; 62 gfx::ImageSkia top_left;
63 gfx::ImageSkia top_right; 63 gfx::ImageSkia top_right;
64 gfx::ImageSkia center;
64 gfx::ImageSkia bottom_left; 65 gfx::ImageSkia bottom_left;
65 gfx::ImageSkia bottom_right; 66 gfx::ImageSkia bottom_right;
66 }; 67 };
67 68
68 //------------------------------------------------------------------------------ 69 //------------------------------------------------------------------------------
69 // class used for maintaining a map of network state and images. 70 // class used for maintaining a map of network state and images.
70 class NetworkIconImpl { 71 class NetworkIconImpl {
71 public: 72 public:
72 NetworkIconImpl(const std::string& path, IconType icon_type); 73 NetworkIconImpl(const std::string& path, IconType icon_type);
73 74
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 218
218 // The badges are flush against the edges of the canvas, except at the top, 219 // The badges are flush against the edges of the canvas, except at the top,
219 // where the badge is only 1dp higher than the base image. 220 // where the badge is only 1dp higher than the base image.
220 const int top_badge_y = icon_y - 1; 221 const int top_badge_y = icon_y - 1;
221 if (!badges_.top_left.isNull()) 222 if (!badges_.top_left.isNull())
222 canvas->DrawImageInt(badges_.top_left, 0, top_badge_y); 223 canvas->DrawImageInt(badges_.top_left, 0, top_badge_y);
223 if (!badges_.top_right.isNull()) { 224 if (!badges_.top_right.isNull()) {
224 canvas->DrawImageInt(badges_.top_right, width - badges_.top_right.width(), 225 canvas->DrawImageInt(badges_.top_right, width - badges_.top_right.width(),
225 top_badge_y); 226 top_badge_y);
226 } 227 }
228 if (!badges_.center.isNull()) {
229 canvas->DrawImageInt(badges_.center, (width - badges_.center.width()) / 2,
230 (height - badges_.center.height()) / 2);
231 }
227 if (!badges_.bottom_left.isNull()) { 232 if (!badges_.bottom_left.isNull()) {
228 canvas->DrawImageInt(badges_.bottom_left, 0, 233 canvas->DrawImageInt(badges_.bottom_left, 0,
229 height - badges_.bottom_left.height()); 234 height - badges_.bottom_left.height());
230 } 235 }
231 if (!badges_.bottom_right.isNull()) { 236 if (!badges_.bottom_right.isNull()) {
232 canvas->DrawImageInt(badges_.bottom_right, 237 canvas->DrawImageInt(badges_.bottom_right,
233 width - badges_.bottom_right.width(), 238 width - badges_.bottom_right.width(),
234 height - badges_.bottom_right.height()); 239 height - badges_.bottom_right.height());
235 } 240 }
236 } 241 }
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi), 778 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi),
774 ICON_TYPE_LIST, kNumNetworkImages - 1); 779 ICON_TYPE_LIST, kNumNetworkImages - 1);
775 source->set_color(icon_color); 780 source->set_color(icon_color);
776 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size()); 781 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size());
777 Badges badges; 782 Badges badges;
778 badges.bottom_right = 783 badges.bottom_right =
779 gfx::CreateVectorIcon(kNetworkBadgeAddOtherIcon, badge_color); 784 gfx::CreateVectorIcon(kNetworkBadgeAddOtherIcon, badge_color);
780 return NetworkIconImageSource::CreateImage(icon, badges); 785 return NetworkIconImageSource::CreateImage(icon, badges);
781 } 786 }
782 787
788 gfx::ImageSkia GetImageForWifiChipState(bool enabled) {
789 SignalStrengthImageSource* source =
790 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi),
791 ICON_TYPE_LIST, kNumNetworkImages - 1);
792 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size());
793 Badges badges;
794 if (!enabled)
795 badges.center = gfx::CreateVectorIcon(kNetworkBadgeOffIcon, kMenuIconColor);
796 return NetworkIconImageSource::CreateImage(icon, badges);
797 }
798
783 base::string16 GetLabelForNetwork(const chromeos::NetworkState* network, 799 base::string16 GetLabelForNetwork(const chromeos::NetworkState* network,
784 IconType icon_type) { 800 IconType icon_type) {
785 DCHECK(network); 801 DCHECK(network);
786 std::string activation_state = network->activation_state(); 802 std::string activation_state = network->activation_state();
787 if (icon_type == ICON_TYPE_LIST || icon_type == ICON_TYPE_MENU_LIST) { 803 if (icon_type == ICON_TYPE_LIST || icon_type == ICON_TYPE_MENU_LIST) {
788 // Show "<network>: [Connecting|Activating|Reconnecting]..." 804 // Show "<network>: [Connecting|Activating|Reconnecting]..."
789 // TODO(varkha): Remaining states should migrate to secondary status in the 805 // TODO(varkha): Remaining states should migrate to secondary status in the
790 // network item and no longer be part of the label. 806 // network item and no longer be part of the label.
791 // See http://crbug.com/676181 . 807 // See http://crbug.com/676181 .
792 if (network->IsReconnecting()) { 808 if (network->IsReconnecting()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 network_paths.insert((*iter)->path()); 964 network_paths.insert((*iter)->path());
949 } 965 }
950 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 966 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
951 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 967 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
952 PurgeIconMap(ICON_TYPE_LIST, network_paths); 968 PurgeIconMap(ICON_TYPE_LIST, network_paths);
953 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); 969 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths);
954 } 970 }
955 971
956 } // namespace network_icon 972 } // namespace network_icon
957 } // namespace ash 973 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/network_icon.h ('k') | ash/common/system/chromeos/network/tray_network.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698