| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/status/network_menu_icon.h" | 5 #include "chrome/browser/chromeos/status/network_menu_icon.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/cros/cros_library.h" | 10 #include "chrome/browser/chromeos/cros/cros_library.h" |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 // VPN should never be the primiary active network. This is used for | 333 // VPN should never be the primiary active network. This is used for |
| 334 // the icon next to a connected or disconnected VPN. | 334 // the icon next to a connected or disconnected VPN. |
| 335 const Network* connected_network = cros->connected_network(); | 335 const Network* connected_network = cros->connected_network(); |
| 336 if (connected_network && connected_network->type() != TYPE_VPN) { | 336 if (connected_network && connected_network->type() != TYPE_VPN) { |
| 337 // Set the icon and badges for the connected network. | 337 // Set the icon and badges for the connected network. |
| 338 SetIcon(connected_network); | 338 SetIcon(connected_network); |
| 339 SetBadges(connected_network); | 339 SetBadges(connected_network); |
| 340 } else { | 340 } else { |
| 341 // Use the ethernet icon for VPN when not connected. | 341 // Use the ethernet icon for VPN when not connected. |
| 342 icon_ = rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); | 342 icon_ = rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); |
| 343 // We can be connected to a VPN, even when there is no connected |
| 344 // underlying network. In that case, for the status bar, show the |
| 345 // disconencted badge. |
| 346 if (is_status_bar_) { |
| 347 bottom_right_badge_ = |
| 348 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED); |
| 349 } |
| 343 } | 350 } |
| 344 // Overlay the VPN badge. | 351 // Overlay the VPN badge. |
| 345 bottom_left_badge_ = rb.GetBitmapNamed(kVpnBadgeId); | 352 bottom_left_badge_ = rb.GetBitmapNamed(kVpnBadgeId); |
| 346 } else { | 353 } else { |
| 347 SetIcon(network); | 354 SetIcon(network); |
| 348 SetBadges(network); | 355 SetBadges(network); |
| 349 } | 356 } |
| 350 } | 357 } |
| 351 | 358 |
| 352 // Generates the bitmap. Call after setting the icon and badges. | 359 // Generates the bitmap. Call after setting the icon and badges. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 566 } |
| 560 | 567 |
| 561 // If we are not connecting to a network, show the active network. | 568 // If we are not connecting to a network, show the active network. |
| 562 const Network* network = cros->active_network(); | 569 const Network* network = cros->active_network(); |
| 563 if (network) { | 570 if (network) { |
| 564 bool animating = false; | 571 bool animating = false; |
| 565 last_network_type_ = network->type(); | 572 last_network_type_ = network->type(); |
| 566 // Icon + badges. | 573 // Icon + badges. |
| 567 icon_->SetDirty(); | 574 icon_->SetDirty(); |
| 568 icon_->UpdateIcon(network); | 575 icon_->UpdateIcon(network); |
| 569 // Overlay the VPN badge if connected or connecting to a VPN. | 576 // Overlay the VPN badge if connecting to a VPN. |
| 570 if (cros->virtual_network()) { | 577 if (network->type() != TYPE_VPN && cros->virtual_network()) { |
| 571 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); | 578 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); |
| 572 if (cros->virtual_network()->connecting()) { | 579 if (cros->virtual_network()->connecting()) { |
| 573 double animation = GetAnimation(); | 580 double animation = GetAnimation(); |
| 574 animating = true; | 581 animating = true; |
| 575 // Even though this is the only place we use vpn_connecting_badge_, | 582 // Even though this is the only place we use vpn_connecting_badge_, |
| 576 // it is important that this is a member variable since we set a | 583 // it is important that this is a member variable since we set a |
| 577 // pointer to it and access that pointer in icon_->GenerateBitmap(). | 584 // pointer to it and access that pointer in icon_->GenerateBitmap(). |
| 578 vpn_connecting_badge_ = SkBitmapOperations::CreateBlendedBitmap( | 585 vpn_connecting_badge_ = SkBitmapOperations::CreateBlendedBitmap( |
| 579 empty_vpn_badge_, *vpn_badge, animation); | 586 empty_vpn_badge_, *vpn_badge, animation); |
| 580 icon_->set_bottom_left_badge(&vpn_connecting_badge_); | 587 icon_->set_bottom_left_badge(&vpn_connecting_badge_); |
| 581 } else if (cros->virtual_network()->connected()) { | |
| 582 icon_->set_bottom_left_badge(vpn_badge); | |
| 583 } | 588 } |
| 584 } | 589 } |
| 585 if (!animating) | 590 if (!animating) |
| 586 animation_connecting_.Stop(); | 591 animation_connecting_.Stop(); |
| 587 // Text. | 592 // Text. |
| 588 if (text) { | 593 if (text) { |
| 589 switch (network->type()) { | 594 switch (network->type()) { |
| 590 case TYPE_ETHERNET: | 595 case TYPE_ETHERNET: |
| 591 if (mode_ == MENU_MODE) { | 596 if (mode_ == MENU_MODE) { |
| 592 *text = l10n_util::GetStringFUTF16( | 597 *text = l10n_util::GetStringFUTF16( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 ethernet_icon->width(), ethernet_icon->height(), false); | 683 ethernet_icon->width(), ethernet_icon->height(), false); |
| 679 canvas.DrawBitmapInt(*ethernet_icon, 0, 0); | 684 canvas.DrawBitmapInt(*ethernet_icon, 0, 0); |
| 680 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); | 685 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); |
| 681 canvas.DrawBitmapInt(*vpn_badge, kBadgeLeftX, kBadgeBottomY); | 686 canvas.DrawBitmapInt(*vpn_badge, kBadgeLeftX, kBadgeBottomY); |
| 682 vpn_bitmap = new SkBitmap(canvas.ExtractBitmap()); | 687 vpn_bitmap = new SkBitmap(canvas.ExtractBitmap()); |
| 683 } | 688 } |
| 684 return vpn_bitmap; | 689 return vpn_bitmap; |
| 685 } | 690 } |
| 686 | 691 |
| 687 } // chromeos | 692 } // chromeos |
| OLD | NEW |