OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 views::BoundsAnimator* animator) { | 295 views::BoundsAnimator* animator) { |
296 DCHECK_EQ(&animator_, animator); | 296 DCHECK_EQ(&animator_, animator); |
297 for (auto* view : deleted_when_done_) { | 297 for (auto* view : deleted_when_done_) { |
298 const gfx::SlideAnimation* animation = animator->GetAnimationForView(view); | 298 const gfx::SlideAnimation* animation = animator->GetAnimationForView(view); |
299 if (animation) | 299 if (animation) |
300 view->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); | 300 view->layer()->SetOpacity(animation->CurrentValueBetween(1.0, 0.0)); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { | 304 void MessageListView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { |
| 305 bool need_update = false; |
| 306 |
| 307 if (clear_all_started_) { |
| 308 clear_all_started_ = false; |
| 309 // TODO(yoshiki): we shouldn't touch views in OnAllNotificationsCleared(). |
| 310 // Or rename it to like OnAllNotificationsClearing(). |
| 311 for (auto& observer : observers_) |
| 312 observer.OnAllNotificationsCleared(); |
| 313 |
| 314 // Need to update layout after deleting the views. |
| 315 if (!deleted_when_done_.empty()) |
| 316 need_update = true; |
| 317 } |
| 318 |
| 319 // None of these views should be deleted. |
| 320 DCHECK(std::all_of(deleted_when_done_.begin(), deleted_when_done_.end(), |
| 321 [this](views::View* view) { return Contains(view); })); |
| 322 |
305 for (auto* view : deleted_when_done_) | 323 for (auto* view : deleted_when_done_) |
306 delete view; | 324 delete view; |
307 deleted_when_done_.clear(); | 325 deleted_when_done_.clear(); |
308 | 326 |
309 if (clear_all_started_) { | 327 if (has_deferred_task_) { |
310 clear_all_started_ = false; | 328 has_deferred_task_ = false; |
311 for (auto& observer : observers_) | 329 need_update = true; |
312 observer.OnAllNotificationsCleared(); | |
313 } | 330 } |
314 | 331 |
315 if (has_deferred_task_) { | 332 if (need_update) |
316 has_deferred_task_ = false; | |
317 DoUpdateIfPossible(); | 333 DoUpdateIfPossible(); |
318 } | |
319 | 334 |
320 if (GetWidget()) | 335 if (GetWidget()) |
321 GetWidget()->SynthesizeMouseMoveEvent(); | 336 GetWidget()->SynthesizeMouseMoveEvent(); |
322 | 337 |
323 if (quit_message_loop_after_animation_for_test_) | 338 if (quit_message_loop_after_animation_for_test_) |
324 base::MessageLoop::current()->QuitWhenIdle(); | 339 base::MessageLoop::current()->QuitWhenIdle(); |
325 } | 340 } |
326 | 341 |
327 bool MessageListView::IsValidChild(const views::View* child) const { | 342 bool MessageListView::IsValidChild(const views::View* child) const { |
328 return child->visible() && | 343 return child->visible() && |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 base::TimeDelta::FromMilliseconds( | 587 base::TimeDelta::FromMilliseconds( |
573 kAnimateClearingNextNotificationDelayMS)); | 588 kAnimateClearingNextNotificationDelayMS)); |
574 } | 589 } |
575 } | 590 } |
576 | 591 |
577 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { | 592 void MessageListView::SetRepositionTargetForTest(const gfx::Rect& target_rect) { |
578 SetRepositionTarget(target_rect); | 593 SetRepositionTarget(target_rect); |
579 } | 594 } |
580 | 595 |
581 } // namespace message_center | 596 } // namespace message_center |
OLD | NEW |