Index: ash/system/chromeos/network/tray_vpn.cc |
diff --git a/ash/system/chromeos/network/tray_vpn.cc b/ash/system/chromeos/network/tray_vpn.cc |
index 3cb42ec7c32f1960eabb51173fef5110691f9396..3eb9ce537db09b615f703d8c40c565296a03ca14 100644 |
--- a/ash/system/chromeos/network/tray_vpn.cc |
+++ b/ash/system/chromeos/network/tray_vpn.cc |
@@ -6,6 +6,7 @@ |
#include "ash/shell.h" |
#include "ash/system/chromeos/network/network_list_detailed_view_base.h" |
+#include "ash/system/tray/system_tray.h" |
#include "ash/system/tray/system_tray_delegate.h" |
#include "ash/system/tray/system_tray_notifier.h" |
#include "ash/system/tray/tray_constants.h" |
@@ -27,6 +28,13 @@ class VpnDefaultView : public TrayItemMore { |
virtual ~VpnDefaultView() {} |
+ static bool ShouldShow() { |
+ // Do not show VPN line in uber tray bubble if VPN is not configured. |
+ std::vector<NetworkIconInfo> list; |
+ Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworks(&list); |
+ return list.size() != 0; |
+ } |
+ |
void Update() { |
NetworkIconInfo info; |
Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworkIcon(&info); |
@@ -153,10 +161,7 @@ views::View* TrayVPN::CreateDefaultView(user::LoginStatus status) { |
if (status == user::LOGGED_IN_NONE) |
return NULL; |
- // Do not show VPN line in uber tray bubble if VPN is not configured. |
- std::vector<NetworkIconInfo> list; |
- Shell::GetInstance()->system_tray_delegate()->GetVirtualNetworks(&list); |
- if (list.size() == 0) |
+ if (!tray::VpnDefaultView::ShouldShow()) |
return NULL; |
default_ = new tray::VpnDefaultView(this, status != user::LOGGED_IN_LOCKED); |
@@ -196,8 +201,16 @@ void TrayVPN::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
} |
void TrayVPN::OnNetworkRefresh(const NetworkIconInfo& info) { |
- if (default_) |
+ if (default_) { |
default_->Update(); |
+ } else if (tray::VpnDefaultView::ShouldShow()) { |
+ if (system_tray()->HasSystemBubbleType( |
+ SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { |
+ // We created the default view without a VPN view, so rebuild it. |
+ system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
+ } |
+ } |
+ |
if (detailed_) |
detailed_->ManagerChanged(); |
} |