diff options
author | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 23:18:01 +0000 |
---|---|---|
committer | mukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-11 23:18:01 +0000 |
commit | cf179ee75a7a74baf967f0f8c17580b5b1f65766 (patch) | |
tree | 2fc122a41a364736073ad0e9e28495e3cfec4e1a | |
parent | d081b1940b7004bb2a6544b1a5e7c20bc896dcd3 (diff) | |
download | chromium_src-cf179ee75a7a74baf967f0f8c17580b5b1f65766.zip chromium_src-cf179ee75a7a74baf967f0f8c17580b5b1f65766.tar.gz chromium_src-cf179ee75a7a74baf967f0f8c17580b5b1f65766.tar.bz2 |
Merge 190635 "Fixes timer operation on notifications."
> Fixes timer operation on notifications.
>
> This CL does the following changes:
> - set_notify_enter_exit_on_child to true to bubble_view_, otherwise
> enter/exit events don't arrive at this.
> - it calls Reset() but it's wrong, Reset() actually restarts the timer.
> instead Stop() has to be called.
> - cleanup the logic of Restart()/Start(), which was reported and
> fixed on message_popup_collection, but the fix hasn't come to
> the old message_popup_bubble code.
>
> BUG=223614
> TEST=create a few notifications, move mouses over, and wait for >7 secs.
>
>
> Review URL: https://chromiumcodereview.appspot.com/12987021
TBR=mukai@chromium.org
Review URL: https://codereview.chromium.org/14198006
git-svn-id: svn://svn.chromium.org/chrome/branches/1453/src@193794 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/message_center/views/message_popup_bubble.cc | 17 | ||||
-rw-r--r-- | ui/message_center/views/message_popup_collection.cc | 10 |
2 files changed, 16 insertions, 11 deletions
diff --git a/ui/message_center/views/message_popup_bubble.cc b/ui/message_center/views/message_popup_bubble.cc index f003f71..8bd64db 100644 --- a/ui/message_center/views/message_popup_bubble.cc +++ b/ui/message_center/views/message_popup_bubble.cc @@ -79,7 +79,7 @@ class MessagePopupBubble::AutocloseTimer { AutocloseTimer(Notification* notification, MessagePopupBubble* bubble); void Start(); - + void Restart(); void Suspend(); private: @@ -111,10 +111,16 @@ void MessagePopupBubble::AutocloseTimer::Start() { base::Unretained(bubble_), id_)); } +void MessagePopupBubble::AutocloseTimer::Restart() { + delay_ -= base::Time::Now() - start_time_; + if (delay_ < base::TimeDelta()) + bubble_->OnAutoClose(id_); + else + Start(); +} + void MessagePopupBubble::AutocloseTimer::Suspend() { - base::TimeDelta passed = base::Time::Now() - start_time_; - delay_ = std::max(base::TimeDelta(), delay_ - passed); - timer_.Reset(); + timer_.Stop(); } // MessagePopupBubble @@ -142,6 +148,7 @@ void MessagePopupBubble::InitializeContents( set_bubble_view(new_bubble_view); contents_view_ = new PopupBubbleContentsView(message_center()); bubble_view()->AddChildView(contents_view_); + bubble_view()->set_notify_enter_exit_on_child(true); UpdateBubbleView(); } @@ -199,7 +206,7 @@ void MessagePopupBubble::OnMouseEnteredView() { void MessagePopupBubble::OnMouseExitedView() { for (std::map<std::string, AutocloseTimer*>::iterator iter = autoclose_timers_.begin(); iter != autoclose_timers_.end(); ++iter) { - iter->second->Start(); + iter->second->Restart(); } } diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index 15aea35..3856fa4 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc @@ -72,17 +72,15 @@ class ToastContentsView : public views::WidgetDelegateView { } void SuspendTimer() { - timer_.Reset(); + timer_.Stop(); } void RestartTimer() { - base::TimeDelta passed = base::Time::Now() - start_time_; - if (passed > delay_) { + delay_ -= base::Time::Now() - start_time_; + if (delay_ < base::TimeDelta()) GetWidget()->Close(); - } else { - delay_ -= passed; + else StartTimer(); - } } void StartTimer() { |