| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 settings_transition_animation_.reset(new gfx::MultiAnimation( | 249 settings_transition_animation_.reset(new gfx::MultiAnimation( |
| 250 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); | 250 parts, base::TimeDelta::FromMicroseconds(1000000 / kDefaultFrameRateHz))); |
| 251 settings_transition_animation_->set_delegate(this); | 251 settings_transition_animation_->set_delegate(this); |
| 252 settings_transition_animation_->set_continuous(false); | 252 settings_transition_animation_->set_continuous(false); |
| 253 settings_transition_animation_->Start(); | 253 settings_transition_animation_->Start(); |
| 254 | 254 |
| 255 button_bar_->SetBackArrowVisible(visible); | 255 button_bar_->SetBackArrowVisible(visible); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void MessageCenterView::ClearAllNotifications() { | 258 void MessageCenterView::ClearAllClosableNotifications() { |
| 259 if (is_closing_) | 259 if (is_closing_) |
| 260 return; | 260 return; |
| 261 | 261 |
| 262 SetViewHierarchyEnabled(scroller_, false); | 262 SetViewHierarchyEnabled(scroller_, false); |
| 263 button_bar_->SetAllButtonsEnabled(false); | 263 button_bar_->SetAllButtonsEnabled(false); |
| 264 message_list_view_->ClearAllNotifications(scroller_->GetVisibleRect()); | 264 message_list_view_->ClearAllClosableNotifications( |
| 265 scroller_->GetVisibleRect()); |
| 265 } | 266 } |
| 266 | 267 |
| 267 void MessageCenterView::OnAllNotificationsCleared() { | 268 void MessageCenterView::OnAllNotificationsCleared() { |
| 268 SetViewHierarchyEnabled(scroller_, true); | 269 SetViewHierarchyEnabled(scroller_, true); |
| 269 button_bar_->SetAllButtonsEnabled(true); | 270 button_bar_->SetAllButtonsEnabled(true); |
| 270 button_bar_->SetCloseAllButtonEnabled(false); | 271 button_bar_->SetCloseAllButtonEnabled(false); |
| 271 message_center_->RemoveAllVisibleNotifications(true); // Action by user. | 272 |
| 273 // Action by user. |
| 274 message_center_->RemoveAllClosableNotifications(true); |
| 272 } | 275 } |
| 273 | 276 |
| 274 size_t MessageCenterView::NumMessageViewsForTest() const { | 277 size_t MessageCenterView::NumMessageViewsForTest() const { |
| 275 return message_list_view_->child_count(); | 278 return message_list_view_->child_count(); |
| 276 } | 279 } |
| 277 | 280 |
| 278 void MessageCenterView::OnSettingsChanged() { | 281 void MessageCenterView::OnSettingsChanged() { |
| 279 scroller_->InvalidateLayout(); | 282 scroller_->InvalidateLayout(); |
| 280 PreferredSizeChanged(); | 283 PreferredSizeChanged(); |
| 281 Layout(); | 284 Layout(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 View* focused_view = NULL; | 584 View* focused_view = NULL; |
| 582 // |focus_manager| can be NULL in tests. | 585 // |focus_manager| can be NULL in tests. |
| 583 if (focus_manager) | 586 if (focus_manager) |
| 584 focused_view = focus_manager->GetFocusedView(); | 587 focused_view = focus_manager->GetFocusedView(); |
| 585 | 588 |
| 586 // All the children of this view are owned by |this|. | 589 // All the children of this view are owned by |this|. |
| 587 scroller_->contents()->RemoveAllChildViews(/*delete_children=*/false); | 590 scroller_->contents()->RemoveAllChildViews(/*delete_children=*/false); |
| 588 scroller_->contents()->AddChildView( | 591 scroller_->contents()->AddChildView( |
| 589 no_message_views ? empty_list_view_.get() : message_list_view_.get()); | 592 no_message_views ? empty_list_view_.get() : message_list_view_.get()); |
| 590 | 593 |
| 591 button_bar_->SetCloseAllButtonEnabled(!no_message_views); | 594 bool no_closable_views = true; |
| 595 for (const auto& view : notification_views_) { |
| 596 if (view.second->closable()) { |
| 597 no_closable_views = false; |
| 598 break; |
| 599 } |
| 600 } |
| 601 button_bar_->SetCloseAllButtonEnabled(!no_closable_views); |
| 592 scroller_->SetFocusable(!no_message_views); | 602 scroller_->SetFocusable(!no_message_views); |
| 593 | 603 |
| 594 if (focus_manager && focused_view) | 604 if (focus_manager && focused_view) |
| 595 focus_manager->SetFocusedView(focused_view); | 605 focus_manager->SetFocusedView(focused_view); |
| 596 | 606 |
| 597 scroller_->InvalidateLayout(); | 607 scroller_->InvalidateLayout(); |
| 598 PreferredSizeChanged(); | 608 PreferredSizeChanged(); |
| 599 Layout(); | 609 Layout(); |
| 600 } | 610 } |
| 601 | 611 |
| 602 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { | 612 void MessageCenterView::SetNotificationViewForTest(MessageView* view) { |
| 603 message_list_view_->AddNotificationAt(view, 0); | 613 message_list_view_->AddNotificationAt(view, 0); |
| 604 } | 614 } |
| 605 | 615 |
| 606 } // namespace message_center | 616 } // namespace message_center |
| OLD | NEW |