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

Unified Diff: ash/system/chromeos/network/tray_vpn.cc

Issue 12079011: Update system tray if vpn networks appear (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comments Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/system/tray/system_tray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | ash/system/tray/system_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698