diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 05:34:25 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-07 05:34:25 +0000 |
commit | bb8ecdccb3d13e27e67705f82ca259d31dbbeae2 (patch) | |
tree | 3b36b65aba6e5deadafb3c845b366c9c88aecd4e | |
parent | b88ce5e8e7c22666ceed361eca4c1c363599736a (diff) | |
download | chromium_src-bb8ecdccb3d13e27e67705f82ca259d31dbbeae2.zip chromium_src-bb8ecdccb3d13e27e67705f82ca259d31dbbeae2.tar.gz chromium_src-bb8ecdccb3d13e27e67705f82ca259d31dbbeae2.tar.bz2 |
Do not reuse the old NotificationView in PopupCollection.
The current code just reuse existing popup widgets, but the contents
might be updated, like image loads. We should recreate every views
and set to the widget.
We should reuse the widgets, beucase closing/opening widgets will
involve animations like fade-out/fade-in.
BUG=180386
TEST=Open multiple issues and make sure images appear
Review URL: https://chromiumcodereview.appspot.com/12521004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@186630 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/message_center/views/message_popup_collection.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index 17fa29a1..f00308d 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc @@ -24,7 +24,6 @@ namespace message_center { class ToastContentsView : public views::WidgetDelegateView { public: ToastContentsView(const Notification* notification, - MessageView* view, MessagePopupCollection* collection) : collection_(collection) { DCHECK(collection_); @@ -35,7 +34,6 @@ class ToastContentsView : public views::WidgetDelegateView { // the whole toast seems to slide although the actual bound of the widget // remains. This is hacky but easier to keep the consistency. set_background(views::Background::CreateSolidBackground(0, 0, 0, 0)); - AddChildView(view); int seconds = kAutocloseDefaultDelaySeconds; if (notification->priority() > DEFAULT_PRIORITY) @@ -59,6 +57,12 @@ class ToastContentsView : public views::WidgetDelegateView { return widget; } + void SetContents(MessageView* view) { + RemoveAllChildViews(true); + AddChildView(view); + Layout(); + } + void SuspendTimer() { timer_.Reset(); } @@ -149,12 +153,16 @@ void MessagePopupCollection::UpdatePopups() { popups.begin(); iter != popups.end(); ++iter) { ToastContainer::iterator toast_iter = toasts_.find((*iter)->id()); views::Widget* widget = NULL; + MessageView* view = NotificationView::Create(*(*iter), list_delegate_); if (toast_iter != toasts_.end()) { widget = toast_iter->second->GetWidget(); old_toast_ids.erase((*iter)->id()); + // Need to replace the contents because |view| can be updated, like + // image loads. + toast_iter->second->SetContents(view); } else { - MessageView* view = NotificationView::Create(*(*iter), list_delegate_); - ToastContentsView* toast = new ToastContentsView(*iter, view, this); + ToastContentsView* toast = new ToastContentsView(*iter, this); + toast->SetContents(view); widget = toast->CreateWidget(context_); widget->AddObserver(this); toast->StartTimer(); |