summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 16:09:26 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-02 16:09:26 +0000
commit4e68b3267e3823024f6dd18a52c3eb14361079f2 (patch)
tree0f580d062d42021ed9532a3b38079e5bd1b673b2 /ash
parent06c50ce68cb43fc5fcdeebb7a47f1551f7055525 (diff)
downloadchromium_src-4e68b3267e3823024f6dd18a52c3eb14361079f2.zip
chromium_src-4e68b3267e3823024f6dd18a52c3eb14361079f2.tar.gz
chromium_src-4e68b3267e3823024f6dd18a52c3eb14361079f2.tar.bz2
Merge 159389 - Prevent showing empty notification bubbles
Also clear network notifications when showing the detailed view. There are two bugs related to this: 1. We are sometimes showing empty notification bubbles if either: a) The only notification is for the displayed detailed view b) The only notification(s) return NULL in CreateNotificationView (this wouldn't normally happen, but is possible in an edge case) 2. When we display the network details view, we should be clearing any current network messages BUG=152457 TEST=Ensure network and power notifications work as expected. Network notifications should be cleared after showing the network details bubble. See issue for repro. Review URL: https://chromiumcodereview.appspot.com/10990123 TBR=stevenjb@chromium.org Review URL: https://codereview.chromium.org/11032020 git-svn-id: svn://svn.chromium.org/chrome/branches/1271/src@159697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/network/tray_network.cc6
-rw-r--r--ash/system/tray/system_tray.cc20
-rw-r--r--ash/system/tray/system_tray.h3
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.