OLD | NEW |
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 "ui/chromeos/network/network_icon.h" | 5 #include "ui/chromeos/network/network_icon.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chromeos/network/device_state.h" | 9 #include "chromeos/network/device_state.h" |
10 #include "chromeos/network/network_connection_handler.h" | 10 #include "chromeos/network/network_connection_handler.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // Amount to fade icons while connecting. | 189 // Amount to fade icons while connecting. |
190 const double kConnectingImageAlpha = 0.5; | 190 const double kConnectingImageAlpha = 0.5; |
191 | 191 |
192 // Images for strength arcs for wireless networks or strength bars for cellular | 192 // Images for strength arcs for wireless networks or strength bars for cellular |
193 // networks. | 193 // networks. |
194 const int kNumNetworkImages = 5; | 194 const int kNumNetworkImages = 5; |
195 | 195 |
196 // Number of discrete images to use for alpha fade animation | 196 // Number of discrete images to use for alpha fade animation |
197 const int kNumFadeImages = 10; | 197 const int kNumFadeImages = 10; |
198 | 198 |
199 SkColor GetBaseColorForIconType(IconType icon_type) { | 199 SkColor GetDefaultColorForIconType(IconType icon_type) { |
200 // TODO(estade): use kTrayIconColor and kMenuIconColor. | 200 // TODO(estade): use kTrayIconColor and kMenuIconColor. |
201 return icon_type == ICON_TYPE_TRAY ? SK_ColorWHITE : gfx::kChromeIconGrey; | 201 return icon_type == ICON_TYPE_TRAY ? SK_ColorWHITE : gfx::kChromeIconGrey; |
202 } | 202 } |
203 | 203 |
204 bool IconTypeIsDark(IconType icon_type) { | 204 bool IconTypeIsDark(IconType icon_type) { |
205 return (icon_type != ICON_TYPE_TRAY); | 205 return (icon_type != ICON_TYPE_TRAY); |
206 } | 206 } |
207 | 207 |
208 bool IconTypeHasVPNBadge(IconType icon_type) { | 208 bool IconTypeHasVPNBadge(IconType icon_type) { |
209 return (icon_type != ICON_TYPE_LIST); | 209 return (icon_type != ICON_TYPE_LIST); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // Depicts a given signal strength using arcs (e.g. for WiFi connections) or | 309 // Depicts a given signal strength using arcs (e.g. for WiFi connections) or |
310 // bars (e.g. for cell connections). | 310 // bars (e.g. for cell connections). |
311 class SignalStrengthImageSource : public gfx::CanvasImageSource { | 311 class SignalStrengthImageSource : public gfx::CanvasImageSource { |
312 public: | 312 public: |
313 SignalStrengthImageSource(ImageType image_type, | 313 SignalStrengthImageSource(ImageType image_type, |
314 IconType icon_type, | 314 IconType icon_type, |
315 int signal_strength) | 315 int signal_strength) |
316 : CanvasImageSource(GetSizeForIconType(icon_type), false), | 316 : CanvasImageSource(GetSizeForIconType(icon_type), false), |
317 image_type_(image_type), | 317 image_type_(image_type), |
318 icon_type_(icon_type), | 318 icon_type_(icon_type), |
| 319 color_(GetDefaultColorForIconType(icon_type_)), |
319 signal_strength_(signal_strength) { | 320 signal_strength_(signal_strength) { |
320 if (image_type_ == NONE) | 321 if (image_type_ == NONE) |
321 image_type_ = ARCS; | 322 image_type_ = ARCS; |
322 | 323 |
323 DCHECK_GE(signal_strength, 0); | 324 DCHECK_GE(signal_strength, 0); |
324 DCHECK_LT(signal_strength, kNumNetworkImages); | 325 DCHECK_LT(signal_strength, kNumNetworkImages); |
325 } | 326 } |
326 ~SignalStrengthImageSource() override {} | 327 ~SignalStrengthImageSource() override {} |
327 | 328 |
| 329 void set_color(SkColor color) { color_ = color; } |
| 330 |
328 // gfx::CanvasImageSource: | 331 // gfx::CanvasImageSource: |
329 void Draw(gfx::Canvas* canvas) override { | 332 void Draw(gfx::Canvas* canvas) override { |
330 if (image_type_ == ARCS) | 333 if (image_type_ == ARCS) |
331 DrawArcs(canvas); | 334 DrawArcs(canvas); |
332 else | 335 else |
333 DrawBars(canvas); | 336 DrawBars(canvas); |
334 } | 337 } |
335 | 338 |
336 bool HasRepresentationAtAllScales() const override { | 339 bool HasRepresentationAtAllScales() const override { |
337 return true; | 340 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
353 oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2, | 356 oval_bounds.Inset(-oval_bounds.width() / 2, 0, -oval_bounds.width() / 2, |
354 -oval_bounds.height()); | 357 -oval_bounds.height()); |
355 | 358 |
356 const SkScalar kAngleAboveHorizontal = 51.f; | 359 const SkScalar kAngleAboveHorizontal = 51.f; |
357 const SkScalar kStartAngle = 180.f + kAngleAboveHorizontal; | 360 const SkScalar kStartAngle = 180.f + kAngleAboveHorizontal; |
358 const SkScalar kSweepAngle = 180.f - 2 * kAngleAboveHorizontal; | 361 const SkScalar kSweepAngle = 180.f - 2 * kAngleAboveHorizontal; |
359 | 362 |
360 SkPaint paint; | 363 SkPaint paint; |
361 paint.setAntiAlias(true); | 364 paint.setAntiAlias(true); |
362 paint.setStyle(SkPaint::kFill_Style); | 365 paint.setStyle(SkPaint::kFill_Style); |
363 const SkColor base_color = GetBaseColorForIconType(icon_type_); | |
364 // Background. Skip drawing for full signal. | 366 // Background. Skip drawing for full signal. |
365 if (signal_strength_ != kNumNetworkImages - 1) { | 367 if (signal_strength_ != kNumNetworkImages - 1) { |
366 paint.setColor(SkColorSetA(base_color, kBgAlpha)); | 368 paint.setColor(SkColorSetA(color_, kBgAlpha)); |
367 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, | 369 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, |
368 kSweepAngle, true, paint); | 370 kSweepAngle, true, paint); |
369 } | 371 } |
370 // Foreground (signal strength). | 372 // Foreground (signal strength). |
371 if (signal_strength_ != 0) { | 373 if (signal_strength_ != 0) { |
372 paint.setColor(base_color); | 374 paint.setColor(color_); |
373 // Percent of the height of the background wedge that we draw the | 375 // Percent of the height of the background wedge that we draw the |
374 // foreground wedge, indexed by signal strength. | 376 // foreground wedge, indexed by signal strength. |
375 static const float kWedgeHeightPercentages[] = {0.f, 0.375f, 0.5833f, | 377 static const float kWedgeHeightPercentages[] = {0.f, 0.375f, 0.5833f, |
376 0.75f, 1.f}; | 378 0.75f, 1.f}; |
377 const float wedge_percent = kWedgeHeightPercentages[signal_strength_]; | 379 const float wedge_percent = kWedgeHeightPercentages[signal_strength_]; |
378 oval_bounds.Inset( | 380 oval_bounds.Inset( |
379 gfx::InsetsF((oval_bounds.height() / 2) * (1.f - wedge_percent))); | 381 gfx::InsetsF((oval_bounds.height() / 2) * (1.f - wedge_percent))); |
380 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, | 382 canvas->sk_canvas()->drawArc(gfx::RectFToSkRect(oval_bounds), kStartAngle, |
381 kSweepAngle, true, paint); | 383 kSweepAngle, true, paint); |
382 } | 384 } |
(...skipping 16 matching lines...) Expand all Loading... |
399 triangle.moveTo(scale(kIconInset), scale(kIconInset + kFullTriangleSide)); | 401 triangle.moveTo(scale(kIconInset), scale(kIconInset + kFullTriangleSide)); |
400 triangle.rLineTo(scale(side), 0); | 402 triangle.rLineTo(scale(side), 0); |
401 triangle.rLineTo(0, -scale(side)); | 403 triangle.rLineTo(0, -scale(side)); |
402 triangle.close(); | 404 triangle.close(); |
403 return triangle; | 405 return triangle; |
404 }; | 406 }; |
405 | 407 |
406 SkPaint paint; | 408 SkPaint paint; |
407 paint.setAntiAlias(true); | 409 paint.setAntiAlias(true); |
408 paint.setStyle(SkPaint::kFill_Style); | 410 paint.setStyle(SkPaint::kFill_Style); |
409 const SkColor base_color = GetBaseColorForIconType(icon_type_); | |
410 // Background. Skip drawing for full signal. | 411 // Background. Skip drawing for full signal. |
411 if (signal_strength_ != kNumNetworkImages - 1) { | 412 if (signal_strength_ != kNumNetworkImages - 1) { |
412 paint.setColor(SkColorSetA(base_color, kBgAlpha)); | 413 paint.setColor(SkColorSetA(color_, kBgAlpha)); |
413 canvas->DrawPath(make_triangle(kFullTriangleSide), paint); | 414 canvas->DrawPath(make_triangle(kFullTriangleSide), paint); |
414 } | 415 } |
415 // Foreground (signal strength). | 416 // Foreground (signal strength). |
416 if (signal_strength_ != 0) { | 417 if (signal_strength_ != 0) { |
417 paint.setColor(base_color); | 418 paint.setColor(color_); |
418 // As a percentage of the bg triangle, the length of one of the short | 419 // As a percentage of the bg triangle, the length of one of the short |
419 // sides of the fg triangle, indexed by signal strength. | 420 // sides of the fg triangle, indexed by signal strength. |
420 static const float kTriangleSidePercents[] = {0.f, 0.5f, 0.625f, 0.75f, | 421 static const float kTriangleSidePercents[] = {0.f, 0.5f, 0.625f, 0.75f, |
421 1.f}; | 422 1.f}; |
422 canvas->DrawPath(make_triangle(kTriangleSidePercents[signal_strength_] * | 423 canvas->DrawPath(make_triangle(kTriangleSidePercents[signal_strength_] * |
423 kFullTriangleSide), | 424 kFullTriangleSide), |
424 paint); | 425 paint); |
425 } | 426 } |
426 } | 427 } |
427 | 428 |
428 ImageType image_type_; | 429 ImageType image_type_; |
429 IconType icon_type_; | 430 IconType icon_type_; |
| 431 SkColor color_; |
430 | 432 |
431 // On a scale of 0 to kNum{Arcs,Bars}Images - 1, how connected we are. | 433 // On a scale of 0 to kNum{Arcs,Bars}Images - 1, how connected we are. |
432 int signal_strength_; | 434 int signal_strength_; |
433 | 435 |
434 // Padding between outside of icon and edge of the canvas, in dp. This value | 436 // Padding between outside of icon and edge of the canvas, in dp. This value |
435 // stays the same regardless of the canvas size (which depends on | 437 // stays the same regardless of the canvas size (which depends on |
436 // |icon_type_|). | 438 // |icon_type_|). |
437 static constexpr int kIconInset = 2; | 439 static constexpr int kIconInset = 2; |
438 | 440 |
439 // TODO(estade): share this alpha with other things in ash (battery, etc.). | 441 // TODO(estade): share this alpha with other things in ash (battery, etc.). |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 return *s_vpn_images[index]; | 536 return *s_vpn_images[index]; |
535 } | 537 } |
536 | 538 |
537 gfx::ImageSkia ConnectingVpnBadge(double animation, IconType icon_type) { | 539 gfx::ImageSkia ConnectingVpnBadge(double animation, IconType icon_type) { |
538 int index = animation * nextafter(static_cast<float>(kNumFadeImages), 0); | 540 int index = animation * nextafter(static_cast<float>(kNumFadeImages), 0); |
539 static gfx::ImageSkia* s_vpn_badges[kNumFadeImages]; | 541 static gfx::ImageSkia* s_vpn_badges[kNumFadeImages]; |
540 if (!s_vpn_badges[index]) { | 542 if (!s_vpn_badges[index]) { |
541 // Lazily cache images. | 543 // Lazily cache images. |
542 gfx::ImageSkia badge = | 544 gfx::ImageSkia badge = |
543 UseMd() ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_VPN, | 545 UseMd() ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_VPN, |
544 GetBaseColorForIconType(icon_type)) | 546 GetDefaultColorForIconType(icon_type)) |
545 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 547 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
546 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE); | 548 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE); |
547 s_vpn_badges[index] = new gfx::ImageSkia( | 549 s_vpn_badges[index] = new gfx::ImageSkia( |
548 gfx::ImageSkiaOperations::CreateTransparentImage(badge, animation)); | 550 gfx::ImageSkiaOperations::CreateTransparentImage(badge, animation)); |
549 } | 551 } |
550 return *s_vpn_badges[index]; | 552 return *s_vpn_badges[index]; |
551 } | 553 } |
552 | 554 |
553 int StrengthIndex(int strength) { | 555 int StrengthIndex(int strength) { |
554 // Return an index in the range [1, kNumNetworkImages - 1]. | 556 // Return an index in the range [1, kNumNetworkImages - 1]. |
(...skipping 24 matching lines...) Expand all Loading... |
579 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_HSPA; | 581 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_HSPA; |
580 } else if (technology == shill::kNetworkTechnologyHspaPlus) { | 582 } else if (technology == shill::kNetworkTechnologyHspaPlus) { |
581 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_HSPA_PLUS; | 583 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_HSPA_PLUS; |
582 } else if (technology == shill::kNetworkTechnologyLte) { | 584 } else if (technology == shill::kNetworkTechnologyLte) { |
583 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_LTE; | 585 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_LTE; |
584 } else if (technology == shill::kNetworkTechnologyLteAdvanced) { | 586 } else if (technology == shill::kNetworkTechnologyLteAdvanced) { |
585 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_LTE_ADVANCED; | 587 id = gfx::VectorIconId::NETWORK_BADGE_TECHNOLOGY_LTE_ADVANCED; |
586 } else { | 588 } else { |
587 return gfx::ImageSkia(); | 589 return gfx::ImageSkia(); |
588 } | 590 } |
589 return gfx::CreateVectorIcon(id, GetBaseColorForIconType(icon_type)); | 591 return gfx::CreateVectorIcon(id, GetDefaultColorForIconType(icon_type)); |
590 } | 592 } |
591 | 593 |
592 int id = -1; | 594 int id = -1; |
593 if (technology == shill::kNetworkTechnologyEvdo) { | 595 if (technology == shill::kNetworkTechnologyEvdo) { |
594 id = IconTypeIsDark(icon_type) ? IDR_AURA_UBER_TRAY_NETWORK_EVDO_DARK | 596 id = IconTypeIsDark(icon_type) ? IDR_AURA_UBER_TRAY_NETWORK_EVDO_DARK |
595 : IDR_AURA_UBER_TRAY_NETWORK_EVDO_LIGHT; | 597 : IDR_AURA_UBER_TRAY_NETWORK_EVDO_LIGHT; |
596 } else if (technology == shill::kNetworkTechnology1Xrtt) { | 598 } else if (technology == shill::kNetworkTechnology1Xrtt) { |
597 id = IDR_AURA_UBER_TRAY_NETWORK_1X; | 599 id = IDR_AURA_UBER_TRAY_NETWORK_1X; |
598 } else if (technology == shill::kNetworkTechnologyGprs) { | 600 } else if (technology == shill::kNetworkTechnologyGprs) { |
599 id = IconTypeIsDark(icon_type) ? IDR_AURA_UBER_TRAY_NETWORK_GPRS_DARK | 601 id = IconTypeIsDark(icon_type) ? IDR_AURA_UBER_TRAY_NETWORK_GPRS_DARK |
(...skipping 25 matching lines...) Expand all Loading... |
625 } | 627 } |
626 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); | 628 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); |
627 } | 629 } |
628 | 630 |
629 gfx::ImageSkia GetIcon(const NetworkState* network, | 631 gfx::ImageSkia GetIcon(const NetworkState* network, |
630 IconType icon_type, | 632 IconType icon_type, |
631 int strength_index) { | 633 int strength_index) { |
632 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 634 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
633 if (network->Matches(NetworkTypePattern::Ethernet())) { | 635 if (network->Matches(NetworkTypePattern::Ethernet())) { |
634 DCHECK_NE(ICON_TYPE_TRAY, icon_type); | 636 DCHECK_NE(ICON_TYPE_TRAY, icon_type); |
635 return UseMd() | 637 return UseMd() ? gfx::CreateVectorIcon( |
636 ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_ETHERNET, | 638 gfx::VectorIconId::NETWORK_ETHERNET, |
637 GetBaseColorForIconType(ICON_TYPE_LIST)) | 639 GetDefaultColorForIconType(ICON_TYPE_LIST)) |
638 : *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_WIRED); | 640 : *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_WIRED); |
639 } else if (network->Matches(NetworkTypePattern::Wireless())) { | 641 } else if (network->Matches(NetworkTypePattern::Wireless())) { |
640 DCHECK(strength_index > 0); | 642 DCHECK(strength_index > 0); |
641 return GetImageForIndex(ImageTypeForNetworkType(network->type()), icon_type, | 643 return GetImageForIndex(ImageTypeForNetworkType(network->type()), icon_type, |
642 strength_index); | 644 strength_index); |
643 } else if (network->Matches(NetworkTypePattern::VPN())) { | 645 } else if (network->Matches(NetworkTypePattern::VPN())) { |
644 DCHECK_NE(ICON_TYPE_TRAY, icon_type); | 646 DCHECK_NE(ICON_TYPE_TRAY, icon_type); |
645 return GetVpnImage(); | 647 return GetVpnImage(); |
646 } | 648 } |
647 | 649 |
648 NOTREACHED() << "Request for icon for unsupported type: " << network->type(); | 650 NOTREACHED() << "Request for icon for unsupported type: " << network->type(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 behind_captive_portal_ = behind_captive_portal; | 776 behind_captive_portal_ = behind_captive_portal; |
775 return true; | 777 return true; |
776 } | 778 } |
777 | 779 |
778 bool NetworkIconImpl::UpdateVPNBadge() { | 780 bool NetworkIconImpl::UpdateVPNBadge() { |
779 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> | 781 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
780 ConnectedNetworkByType(NetworkTypePattern::VPN()); | 782 ConnectedNetworkByType(NetworkTypePattern::VPN()); |
781 if (vpn && vpn_badge_.isNull()) { | 783 if (vpn && vpn_badge_.isNull()) { |
782 vpn_badge_ = | 784 vpn_badge_ = |
783 UseMd() ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_VPN, | 785 UseMd() ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_VPN, |
784 GetBaseColorForIconType(icon_type_)) | 786 GetDefaultColorForIconType(icon_type_)) |
785 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 787 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
786 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE); | 788 IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE); |
787 return true; | 789 return true; |
788 } | 790 } |
789 if (!vpn && !vpn_badge_.isNull()) { | 791 if (!vpn && !vpn_badge_.isNull()) { |
790 vpn_badge_ = gfx::ImageSkia(); | 792 vpn_badge_ = gfx::ImageSkia(); |
791 return true; | 793 return true; |
792 } | 794 } |
793 return false; | 795 return false; |
794 } | 796 } |
795 | 797 |
796 void NetworkIconImpl::GetBadges(const NetworkState* network, Badges* badges) { | 798 void NetworkIconImpl::GetBadges(const NetworkState* network, Badges* badges) { |
797 DCHECK(network); | 799 DCHECK(network); |
798 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 800 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
799 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 801 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
800 | 802 |
801 const std::string& type = network->type(); | 803 const std::string& type = network->type(); |
802 const SkColor icon_color = GetBaseColorForIconType(icon_type_); | 804 const SkColor icon_color = GetDefaultColorForIconType(icon_type_); |
803 if (type == shill::kTypeWifi) { | 805 if (type == shill::kTypeWifi) { |
804 if (network->security_class() != shill::kSecurityNone && | 806 if (network->security_class() != shill::kSecurityNone && |
805 IconTypeIsDark(icon_type_)) { | 807 IconTypeIsDark(icon_type_)) { |
806 badges->bottom_right = | 808 badges->bottom_right = |
807 UseMd() | 809 UseMd() |
808 ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_SECURE, | 810 ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_BADGE_SECURE, |
809 icon_color) | 811 icon_color) |
810 : *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_SECURE_DARK); | 812 : *rb.GetImageSkiaNamed(IDR_AURA_UBER_TRAY_NETWORK_SECURE_DARK); |
811 } | 813 } |
812 } else if (type == shill::kTypeWimax) { | 814 } else if (type == shill::kTypeWimax) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 ImageType image_type = ImageTypeForNetworkType(shill::kTypeWifi); | 906 ImageType image_type = ImageTypeForNetworkType(shill::kTypeWifi); |
905 const IconType icon_type = ICON_TYPE_LIST; | 907 const IconType icon_type = ICON_TYPE_LIST; |
906 const int connected_index = kNumNetworkImages - 1; | 908 const int connected_index = kNumNetworkImages - 1; |
907 return GetImageForIndex(image_type, icon_type, connected_index); | 909 return GetImageForIndex(image_type, icon_type, connected_index); |
908 } | 910 } |
909 | 911 |
910 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { | 912 gfx::ImageSkia GetImageForDisconnectedCellNetwork() { |
911 return GetDisconnectedImage(ICON_TYPE_LIST, shill::kTypeCellular); | 913 return GetDisconnectedImage(ICON_TYPE_LIST, shill::kTypeCellular); |
912 } | 914 } |
913 | 915 |
| 916 gfx::ImageSkia GetImageForNewWifiNetwork(SkColor icon_color, |
| 917 SkColor badge_color) { |
| 918 SignalStrengthImageSource* source = |
| 919 new SignalStrengthImageSource(ImageTypeForNetworkType(shill::kTypeWifi), |
| 920 ICON_TYPE_LIST, kNumNetworkImages - 1); |
| 921 source->set_color(icon_color); |
| 922 gfx::ImageSkia icon = gfx::ImageSkia(source, source->size()); |
| 923 Badges badges; |
| 924 badges.bottom_right = gfx::CreateVectorIcon( |
| 925 gfx::VectorIconId::NETWORK_BADGE_ADD_OTHER, badge_color); |
| 926 return NetworkIconImageSourceMd::CreateImage(icon, badges); |
| 927 } |
| 928 |
914 gfx::ImageSkia GetVpnImage() { | 929 gfx::ImageSkia GetVpnImage() { |
915 return UseMd() | 930 return UseMd() |
916 ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_VPN, | 931 ? gfx::CreateVectorIcon(gfx::VectorIconId::NETWORK_VPN, |
917 GetBaseColorForIconType(ICON_TYPE_LIST)) | 932 GetDefaultColorForIconType(ICON_TYPE_LIST)) |
918 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 933 : *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
919 IDR_AURA_UBER_TRAY_NETWORK_VPN); | 934 IDR_AURA_UBER_TRAY_NETWORK_VPN); |
920 } | 935 } |
921 | 936 |
922 base::string16 GetLabelForNetwork(const chromeos::NetworkState* network, | 937 base::string16 GetLabelForNetwork(const chromeos::NetworkState* network, |
923 IconType icon_type) { | 938 IconType icon_type) { |
924 DCHECK(network); | 939 DCHECK(network); |
925 std::string activation_state = network->activation_state(); | 940 std::string activation_state = network->activation_state(); |
926 if (icon_type == ICON_TYPE_LIST) { | 941 if (icon_type == ICON_TYPE_LIST) { |
927 // Show "<network>: [Connecting|Activating|Reconnecting]..." | 942 // Show "<network>: [Connecting|Activating|Reconnecting]..." |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 iter != networks.end(); ++iter) { | 1098 iter != networks.end(); ++iter) { |
1084 network_paths.insert((*iter)->path()); | 1099 network_paths.insert((*iter)->path()); |
1085 } | 1100 } |
1086 PurgeIconMap(ICON_TYPE_TRAY, network_paths); | 1101 PurgeIconMap(ICON_TYPE_TRAY, network_paths); |
1087 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); | 1102 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); |
1088 PurgeIconMap(ICON_TYPE_LIST, network_paths); | 1103 PurgeIconMap(ICON_TYPE_LIST, network_paths); |
1089 } | 1104 } |
1090 | 1105 |
1091 } // namespace network_icon | 1106 } // namespace network_icon |
1092 } // namespace ui | 1107 } // namespace ui |
OLD | NEW |