OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/status_area_widget.h" | 8 #include "ash/system/status_area_widget.h" |
9 #include "ash/system/tray/tray_bubble_view.h" | 9 #include "ash/system/tray/tray_bubble_view.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 343 } |
344 if (popup_bubble()) { | 344 if (popup_bubble()) { |
345 if (notification_list_->notifications().size() == 0) | 345 if (notification_list_->notifications().size() == 0) |
346 HidePopupBubble(); | 346 HidePopupBubble(); |
347 else | 347 else |
348 popup_bubble()->ScheduleUpdate(); | 348 popup_bubble()->ScheduleUpdate(); |
349 } | 349 } |
350 UpdateTray(); | 350 UpdateTray(); |
351 } | 351 } |
352 | 352 |
353 void WebNotificationTray::HideBubble(WebNotificationBubble* bubble) { | 353 void WebNotificationTray::HideBubble(TrayBubbleView* bubble_view) { |
354 if (bubble == message_center_bubble()) { | 354 if (message_center_bubble() && |
| 355 bubble_view == message_center_bubble()->bubble_view()) { |
355 HideMessageCenterBubble(); | 356 HideMessageCenterBubble(); |
356 } else if (bubble == popup_bubble()) { | 357 } else if (popup_bubble() && bubble_view == popup_bubble()->bubble_view()) { |
357 HidePopupBubble(); | 358 HidePopupBubble(); |
358 } | 359 } |
359 } | 360 } |
360 | 361 |
| 362 bool WebNotificationTray::ClickedOutsideBubble() { |
| 363 // Only hide the message center. |
| 364 if (!message_center_bubble()) |
| 365 return false; |
| 366 HideMessageCenterBubble(); |
| 367 return true; |
| 368 } |
| 369 |
361 // Methods for testing | 370 // Methods for testing |
362 | 371 |
363 size_t WebNotificationTray::GetNotificationCountForTest() const { | 372 size_t WebNotificationTray::GetNotificationCountForTest() const { |
364 return notification_list_->notifications().size(); | 373 return notification_list_->notifications().size(); |
365 } | 374 } |
366 | 375 |
367 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { | 376 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { |
368 return notification_list_->HasNotification(id); | 377 return notification_list_->HasNotification(id); |
369 } | 378 } |
370 | 379 |
371 void WebNotificationTray::RemoveAllNotificationsForTest() { | 380 void WebNotificationTray::RemoveAllNotificationsForTest() { |
372 notification_list_->RemoveAllNotifications(); | 381 notification_list_->RemoveAllNotifications(); |
373 } | 382 } |
374 | 383 |
375 size_t WebNotificationTray::GetMessageCenterNotificationCountForTest() const { | 384 size_t WebNotificationTray::GetMessageCenterNotificationCountForTest() const { |
376 if (!message_center_bubble()) | 385 if (!message_center_bubble()) |
377 return 0; | 386 return 0; |
378 return message_center_bubble()->NumMessageViewsForTest(); | 387 return message_center_bubble()->NumMessageViewsForTest(); |
379 } | 388 } |
380 | 389 |
381 size_t WebNotificationTray::GetPopupNotificationCountForTest() const { | 390 size_t WebNotificationTray::GetPopupNotificationCountForTest() const { |
382 if (!popup_bubble()) | 391 if (!popup_bubble()) |
383 return 0; | 392 return 0; |
384 return popup_bubble()->NumMessageViewsForTest(); | 393 return popup_bubble()->NumMessageViewsForTest(); |
385 } | 394 } |
386 | 395 |
387 } // namespace ash | 396 } // namespace ash |
OLD | NEW |