diff options
-rw-r--r-- | ash/system/network/tray_network.cc | 6 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 20 | ||||
-rw-r--r-- | ash/system/tray/system_tray.h | 3 |
3 files changed, 23 insertions, 6 deletions
diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 8e750d7..7769e54 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -862,6 +862,9 @@ views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { CHECK(detailed_ == NULL); + // Clear any notifications when showing the detailed view. + messages_->messages().clear(); + HideNotificationView(); if (request_wifi_view_) { SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); // The Wi-Fi state is not toggled yet at this point. @@ -929,8 +932,7 @@ void TrayNetwork::SetNetworkMessage(NetworkTrayDelegate* delegate, void TrayNetwork::ClearNetworkMessage(MessageType message_type) { messages_->messages().erase(message_type); if (messages_->messages().empty()) { - if (notification_) - HideNotificationView(); + HideNotificationView(); return; } if (notification_) diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index 38ca270..f23c446 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -265,14 +265,18 @@ void SystemTray::DestroyBubble() { detailed_item_ = NULL; } +void SystemTray::DestroyNotificationBubble() { + notification_bubble_.reset(); + status_area_widget()->SetHideWebNotifications(false); +} + void SystemTray::RemoveBubble(SystemTrayBubble* bubble) { if (bubble == bubble_.get()) { DestroyBubble(); UpdateNotificationBubble(); // State changed, re-create notifications. Shell::GetInstance()->shelf()->UpdateAutoHideState(); } else if (bubble == notification_bubble_) { - notification_bubble_.reset(); - status_area_widget()->SetHideWebNotifications(false); + DestroyNotificationBubble(); } else { NOTREACHED(); } @@ -358,8 +362,7 @@ void SystemTray::UpdateNotificationBubble() { if (notification_items_.empty() || (bubble_.get() && bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DEFAULT)) { - notification_bubble_.reset(); - status_area_widget()->SetHideWebNotifications(false); + DestroyNotificationBubble(); return; } if (bubble_.get() && @@ -372,6 +375,10 @@ void SystemTray::UpdateNotificationBubble() { if (*iter != detailed_item_) items.push_back(*iter); } + if (items.empty()) { + DestroyNotificationBubble(); + return; + } notification_bubble_.reset(new SystemTrayBubble( this, items, SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION)); } else { @@ -394,6 +401,11 @@ void SystemTray::UpdateNotificationBubble() { user::LoginStatus login_status = Shell::GetInstance()->tray_delegate()->GetUserLoginStatus(); notification_bubble_->InitView(anchor, init_params, login_status); + if (notification_bubble_->bubble_view()->child_count() == 0) { + // It is possible that none of the items generated actual notifications. + DestroyNotificationBubble(); + return; + } if (hide_notifications_) notification_bubble_->SetVisible(false); else diff --git a/ash/system/tray/system_tray.h b/ash/system/tray/system_tray.h index de30b90..4afbc38 100644 --- a/ash/system/tray/system_tray.h +++ b/ash/system/tray/system_tray.h @@ -167,6 +167,9 @@ class ASH_EXPORT SystemTray : public internal::TrayBackgroundView { // Resets |bubble_| and clears any related state. void DestroyBubble(); + // Resets |notification_bubble_| and clears any related state. + void DestroyNotificationBubble(); + // Called when the widget associated with |bubble| closes. |bubble| should // always == |bubble_|. This triggers destroying |bubble_| and hiding the // launcher if necessary. |