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

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

Issue 2792253002: Remove a use of raster asset for VPN; update to MD. (Closed)
Patch Set: restore Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "ash/resources/vector_icons/vector_icons.h" 10 #include "ash/resources/vector_icons/vector_icons.h"
12 #include "ash/strings/grit/ash_strings.h" 11 #include "ash/strings/grit/ash_strings.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "chromeos/network/device_state.h" 14 #include "chromeos/network/device_state.h"
16 #include "chromeos/network/network_connection_handler.h" 15 #include "chromeos/network/network_connection_handler.h"
17 #include "chromeos/network/network_state.h" 16 #include "chromeos/network/network_state.h"
18 #include "chromeos/network/network_state_handler.h" 17 #include "chromeos/network/network_state_handler.h"
19 #include "chromeos/network/portal_detector/network_portal_detector.h" 18 #include "chromeos/network/portal_detector/network_portal_detector.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 19 #include "third_party/cros_system_api/dbus/service_constants.h"
21 #include "third_party/skia/include/core/SkPaint.h" 20 #include "third_party/skia/include/core/SkPaint.h"
22 #include "third_party/skia/include/core/SkPath.h" 21 #include "third_party/skia/include/core/SkPath.h"
23 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h"
25 #include "ui/gfx/canvas.h" 23 #include "ui/gfx/canvas.h"
26 #include "ui/gfx/color_palette.h" 24 #include "ui/gfx/color_palette.h"
27 #include "ui/gfx/geometry/insets.h" 25 #include "ui/gfx/geometry/insets.h"
28 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
29 #include "ui/gfx/geometry/size_conversions.h" 27 #include "ui/gfx/geometry/size_conversions.h"
30 #include "ui/gfx/image/canvas_image_source.h" 28 #include "ui/gfx/image/canvas_image_source.h"
31 #include "ui/gfx/image/image_skia_operations.h" 29 #include "ui/gfx/image/image_skia_operations.h"
32 #include "ui/gfx/image/image_skia_source.h" 30 #include "ui/gfx/image/image_skia_source.h"
33 #include "ui/gfx/paint_vector_icon.h" 31 #include "ui/gfx/paint_vector_icon.h"
34 #include "ui/gfx/scoped_canvas.h" 32 #include "ui/gfx/scoped_canvas.h"
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // TODO(estade): should the alpha be applied in SignalStrengthImageSource? 474 // TODO(estade): should the alpha be applied in SignalStrengthImageSource?
477 gfx::ImageSkia source = GetImageForIndex(image_type, icon_type, index + 1); 475 gfx::ImageSkia source = GetImageForIndex(image_type, icon_type, index + 1);
478 images[index] = 476 images[index] =
479 new gfx::ImageSkia(gfx::ImageSkiaOperations::CreateTransparentImage( 477 new gfx::ImageSkia(gfx::ImageSkiaOperations::CreateTransparentImage(
480 source, kConnectingImageAlpha)); 478 source, kConnectingImageAlpha));
481 } 479 }
482 return images[index]; 480 return images[index];
483 } 481 }
484 482
485 gfx::ImageSkia ConnectingVpnImage(double animation) { 483 gfx::ImageSkia ConnectingVpnImage(double animation) {
486 int index = animation * nextafter(static_cast<float>(kNumFadeImages), 0); 484 float floored_animation_value =
487 static gfx::ImageSkia* s_vpn_images[kNumFadeImages]; 485 std::floor(animation * kNumFadeImages) / kNumFadeImages;
488 if (!s_vpn_images[index]) { 486 return gfx::CreateVectorIcon(
489 // Lazily cache images. 487 kNetworkVpnIcon,
490 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 488 gfx::Tween::ColorValueBetween(
491 // TODO(estade): update this icon to MD. See crbug.com/690176 489 floored_animation_value,
492 gfx::ImageSkia* icon = rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_VPN); 490 SkColorSetA(kMenuIconColor, kConnectingImageAlpha), kMenuIconColor));
493 s_vpn_images[index] = new gfx::ImageSkia(
494 gfx::ImageSkiaOperations::CreateTransparentImage(*icon, animation));
495 }
496 return *s_vpn_images[index];
497 } 491 }
498 492
499 Badge ConnectingVpnBadge(double animation, IconType icon_type) { 493 Badge ConnectingVpnBadge(double animation, IconType icon_type) {
500 return {&kNetworkBadgeVpnIcon, 494 return {&kNetworkBadgeVpnIcon,
501 SkColorSetA(GetDefaultColorForIconType(icon_type), 0xFF * animation)}; 495 SkColorSetA(GetDefaultColorForIconType(icon_type), 0xFF * animation)};
502 } 496 }
503 497
504 int StrengthIndex(int strength) { 498 int StrengthIndex(int strength) {
505 // Return an index in the range [1, kNumNetworkImages - 1]. 499 // Return an index in the range [1, kNumNetworkImages - 1].
506 const float findex = (static_cast<float>(strength) / 100.0f) * 500 const float findex = (static_cast<float>(strength) / 100.0f) *
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 network_paths.insert((*iter)->path()); 957 network_paths.insert((*iter)->path());
964 } 958 }
965 PurgeIconMap(ICON_TYPE_TRAY, network_paths); 959 PurgeIconMap(ICON_TYPE_TRAY, network_paths);
966 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); 960 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths);
967 PurgeIconMap(ICON_TYPE_LIST, network_paths); 961 PurgeIconMap(ICON_TYPE_LIST, network_paths);
968 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); 962 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths);
969 } 963 }
970 964
971 } // namespace network_icon 965 } // namespace network_icon
972 } // namespace ash 966 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698