| 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 "ui/message_center/views/message_bubble_base.h" | 5 #include "ui/message_center/views/message_bubble_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "ui/message_center/message_center_style.h" | 11 #include "ui/message_center/message_center_style.h" |
| 9 #include "ui/views/widget/widget.h" | 12 #include "ui/views/widget/widget.h" |
| 10 #include "ui/views/widget/widget_observer.h" | 13 #include "ui/views/widget/widget_observer.h" |
| 11 | 14 |
| 12 namespace { | 15 namespace { |
| 13 // Delay laying out the MessageBubbleBase until all notifications have been | 16 // Delay laying out the MessageBubbleBase until all notifications have been |
| 14 // added and icons have had a chance to load. | 17 // added and icons have had a chance to load. |
| 15 const int kUpdateDelayMs = 50; | 18 const int kUpdateDelayMs = 50; |
| 16 const int kMessageBubbleBaseDefaultMaxHeight = 400; | 19 const int kMessageBubbleBaseDefaultMaxHeight = 400; |
| 17 } | 20 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 35 bubble_view_->reset_delegate(); | 38 bubble_view_->reset_delegate(); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void MessageBubbleBase::BubbleViewDestroyed() { | 41 void MessageBubbleBase::BubbleViewDestroyed() { |
| 39 bubble_view_ = NULL; | 42 bubble_view_ = NULL; |
| 40 OnBubbleViewDestroyed(); | 43 OnBubbleViewDestroyed(); |
| 41 } | 44 } |
| 42 | 45 |
| 43 void MessageBubbleBase::ScheduleUpdate() { | 46 void MessageBubbleBase::ScheduleUpdate() { |
| 44 weak_ptr_factory_.InvalidateWeakPtrs(); // Cancel any pending update. | 47 weak_ptr_factory_.InvalidateWeakPtrs(); // Cancel any pending update. |
| 45 base::MessageLoop::current()->PostDelayedTask( | 48 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 46 FROM_HERE, | 49 FROM_HERE, base::Bind(&MessageBubbleBase::UpdateBubbleView, |
| 47 base::Bind(&MessageBubbleBase::UpdateBubbleView, | 50 weak_ptr_factory_.GetWeakPtr()), |
| 48 weak_ptr_factory_.GetWeakPtr()), | |
| 49 base::TimeDelta::FromMilliseconds(kUpdateDelayMs)); | 51 base::TimeDelta::FromMilliseconds(kUpdateDelayMs)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 bool MessageBubbleBase::IsVisible() const { | 54 bool MessageBubbleBase::IsVisible() const { |
| 53 return bubble_view() && bubble_view()->GetWidget()->IsVisible(); | 55 return bubble_view() && bubble_view()->GetWidget()->IsVisible(); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void MessageBubbleBase::SetMaxHeight(int height) { | 58 void MessageBubbleBase::SetMaxHeight(int height) { |
| 57 // Maximum height makes sense only for the new design. | 59 // Maximum height makes sense only for the new design. |
| 58 if (height == 0) | 60 if (height == 0) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 70 views::TrayBubbleView::InitParams init_params( | 72 views::TrayBubbleView::InitParams init_params( |
| 71 views::TrayBubbleView::ANCHOR_TYPE_TRAY, | 73 views::TrayBubbleView::ANCHOR_TYPE_TRAY, |
| 72 anchor_alignment, | 74 anchor_alignment, |
| 73 kNotificationWidth, | 75 kNotificationWidth, |
| 74 kNotificationWidth); | 76 kNotificationWidth); |
| 75 init_params.arrow_color = kBackgroundDarkColor; | 77 init_params.arrow_color = kBackgroundDarkColor; |
| 76 return init_params; | 78 return init_params; |
| 77 } | 79 } |
| 78 | 80 |
| 79 } // namespace message_center | 81 } // namespace message_center |
| OLD | NEW |