OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/message_center/views/message_center_view.h" | 5 #include "ui/message_center/views/message_center_view.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 if (hover_view->IsMouseHovered()) { | 400 if (hover_view->IsMouseHovered()) { |
401 message_list_view_->SetRepositionTarget(hover_view->bounds()); | 401 message_list_view_->SetRepositionTarget(hover_view->bounds()); |
402 return true; | 402 return true; |
403 } | 403 } |
404 } | 404 } |
405 } | 405 } |
406 return false; | 406 return false; |
407 } | 407 } |
408 | 408 |
409 void MessageCenterView::OnNotificationUpdated(const std::string& id) { | 409 void MessageCenterView::OnNotificationUpdated(const std::string& id) { |
| 410 // TODO(edcourtney): We may be able to remove this, since |UpdateNotification| |
| 411 // checks it anyway. |
410 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); | 412 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); |
411 if (view_iter == notification_views_.end()) | 413 if (view_iter == notification_views_.end()) |
412 return; | 414 return; |
413 | 415 |
414 // If there is no reposition target anymore, make sure to reset the reposition | 416 // If there is no reposition target anymore, make sure to reset the reposition |
415 // session. | 417 // session. |
416 if (!SetRepositionTarget()) | 418 if (!SetRepositionTarget()) |
417 message_list_view_->ResetRepositionSession(); | 419 message_list_view_->ResetRepositionSession(); |
418 | 420 |
419 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) | 421 UpdateNotification(id); |
420 MessageView* view = view_iter->second; | |
421 const NotificationList::Notifications& notifications = | |
422 message_center_->GetVisibleNotifications(); | |
423 for (NotificationList::Notifications::const_iterator iter = | |
424 notifications.begin(); iter != notifications.end(); ++iter) { | |
425 if ((*iter)->id() == id) { | |
426 int old_width = view->width(); | |
427 int old_height = view->height(); | |
428 bool old_pinned = view->IsPinned(); | |
429 message_list_view_->UpdateNotification(view, **iter); | |
430 if (view->GetHeightForWidth(old_width) != old_height) { | |
431 Update(true /* animate */); | |
432 } else if (view->IsPinned() != old_pinned) { | |
433 // Animate flag is false, since the pinned flag transition doesn't need | |
434 // animation. | |
435 Update(false /* animate */); | |
436 } | |
437 break; | |
438 } | |
439 } | |
440 | |
441 // Notify accessibility that the contents have changed. | |
442 view->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); | |
443 } | 422 } |
444 | 423 |
445 void MessageCenterView::OnLockedStateChanged(bool locked) { | 424 void MessageCenterView::OnLockedStateChanged(bool locked) { |
446 is_locked_ = locked; | 425 is_locked_ = locked; |
447 UpdateButtonBarStatus(); | 426 UpdateButtonBarStatus(); |
448 Update(true /* animate */); | 427 Update(true /* animate */); |
449 } | 428 } |
450 | 429 |
451 void MessageCenterView::ClickOnNotification( | 430 void MessageCenterView::ClickOnNotification( |
452 const std::string& notification_id) { | 431 const std::string& notification_id) { |
(...skipping 21 matching lines...) Expand all Loading... |
474 message_center_->ClickOnNotificationButton(notification_id, button_index); | 453 message_center_->ClickOnNotificationButton(notification_id, button_index); |
475 } | 454 } |
476 | 455 |
477 void MessageCenterView::ClickOnSettingsButton( | 456 void MessageCenterView::ClickOnSettingsButton( |
478 const std::string& notification_id) { | 457 const std::string& notification_id) { |
479 message_center_->ClickOnSettingsButton(notification_id); | 458 message_center_->ClickOnSettingsButton(notification_id); |
480 } | 459 } |
481 | 460 |
482 void MessageCenterView::UpdateNotificationSize( | 461 void MessageCenterView::UpdateNotificationSize( |
483 const std::string& notification_id) { | 462 const std::string& notification_id) { |
484 OnNotificationUpdated(notification_id); | 463 // TODO(edcourtney, yoshiki): We don't call OnNotificationUpdated directly |
| 464 // because it resets the reposition session, which can end up deleting |
| 465 // notification items when it cancels animations. This causes problems for |
| 466 // ARC notifications. See crbug.com/714493. OnNotificationUpdated should not |
| 467 // have to consider the reposition session, but OnMouseEntered and |
| 468 // OnMouseExited don't work properly for ARC notifications at the moment. |
| 469 // See crbug.com/714587. |
| 470 UpdateNotification(notification_id); |
485 } | 471 } |
486 | 472 |
487 void MessageCenterView::AnimationEnded(const gfx::Animation* animation) { | 473 void MessageCenterView::AnimationEnded(const gfx::Animation* animation) { |
488 DCHECK_EQ(animation, settings_transition_animation_.get()); | 474 DCHECK_EQ(animation, settings_transition_animation_.get()); |
489 | 475 |
490 Visibility visibility = | 476 Visibility visibility = |
491 mode_ == Mode::SETTINGS ? VISIBILITY_SETTINGS : VISIBILITY_MESSAGE_CENTER; | 477 mode_ == Mode::SETTINGS ? VISIBILITY_SETTINGS : VISIBILITY_MESSAGE_CENTER; |
492 message_center_->SetVisibility(visibility); | 478 message_center_->SetVisibility(visibility); |
493 | 479 |
494 if (source_view_) { | 480 if (source_view_) { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } else { | 652 } else { |
667 // Disable the close-all button since no notification is visible. | 653 // Disable the close-all button since no notification is visible. |
668 button_bar_->SetCloseAllButtonEnabled(false); | 654 button_bar_->SetCloseAllButtonEnabled(false); |
669 } | 655 } |
670 } | 656 } |
671 | 657 |
672 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 658 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
673 message_list_view_->AddNotificationAt(view, 0); | 659 message_list_view_->AddNotificationAt(view, 0); |
674 } | 660 } |
675 | 661 |
| 662 void MessageCenterView::UpdateNotification(const std::string& id) { |
| 663 // TODO(edcourtney, yoshiki): This check seems like it should not be needed. |
| 664 // Investigate what circumstances (if any) trigger it. |
| 665 NotificationViewsMap::const_iterator view_iter = notification_views_.find(id); |
| 666 if (view_iter == notification_views_.end()) |
| 667 return; |
| 668 |
| 669 // TODO(dimich): add MessageCenter::GetVisibleNotificationById(id) |
| 670 MessageView* view = view_iter->second; |
| 671 const NotificationList::Notifications& notifications = |
| 672 message_center_->GetVisibleNotifications(); |
| 673 for (NotificationList::Notifications::const_iterator iter = |
| 674 notifications.begin(); |
| 675 iter != notifications.end(); ++iter) { |
| 676 if ((*iter)->id() == id) { |
| 677 int old_width = view->width(); |
| 678 int old_height = view->height(); |
| 679 bool old_pinned = view->IsPinned(); |
| 680 message_list_view_->UpdateNotification(view, **iter); |
| 681 if (view->GetHeightForWidth(old_width) != old_height) { |
| 682 Update(true /* animate */); |
| 683 } else if (view->IsPinned() != old_pinned) { |
| 684 // Animate flag is false, since the pinned flag transition doesn't need |
| 685 // animation. |
| 686 Update(false /* animate */); |
| 687 } |
| 688 break; |
| 689 } |
| 690 } |
| 691 |
| 692 // Notify accessibility that the contents have changed. |
| 693 view->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); |
| 694 } |
| 695 |
676 } // namespace message_center | 696 } // namespace message_center |
OLD | NEW |