Commit cde035b0 authored by johnnyg@chromium.org's avatar johnnyg@chromium.org

[linux] When the user has the notification options menu, delay...

[linux] When the user has the notification options menu, delay system-initiated closing of the notification.

BUG=51177
TEST=open the notification options menu on a notification which will be auto-closed by the page.

Review URL: http://codereview.chromium.org/6273010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72456 0039d316-1c4b-4281-b951-d872f2087c98
parent c32868b3
......@@ -102,16 +102,24 @@ BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
html_container_(NULL),
method_factory_(this),
close_button_(NULL),
animation_(NULL) {
animation_(NULL),
menu_showing_(false),
pending_close_(false) {
}
BalloonViewImpl::~BalloonViewImpl() {
}
void BalloonViewImpl::Close(bool by_user) {
MessageLoop::current()->PostTask(FROM_HERE,
method_factory_.NewRunnableMethod(
&BalloonViewImpl::DelayedClose, by_user));
// Delay a system-initiated close if the menu is showing.
if (!by_user && menu_showing_) {
pending_close_ = true;
} else {
MessageLoop::current()->PostTask(
FROM_HERE,
method_factory_.NewRunnableMethod(
&BalloonViewImpl::DelayedClose, by_user));
}
}
gfx::Size BalloonViewImpl::GetSize() const {
......@@ -417,9 +425,17 @@ gboolean BalloonViewImpl::OnExpose(GtkWidget* sender, GdkEventExpose* event) {
}
void BalloonViewImpl::OnOptionsMenuButton(GtkWidget* widget) {
menu_showing_ = true;
options_menu_->PopupAsContext(gtk_get_current_event_time());
}
// Called when the menu stops showing.
void BalloonViewImpl::StoppedShowing() {
if (pending_close_)
DelayedClose(false);
menu_showing_ = false;
}
gboolean BalloonViewImpl::OnDestroy(GtkWidget* widget) {
frame_container_ = NULL;
Close(false);
......
......@@ -51,6 +51,9 @@ class BalloonViewImpl : public BalloonView,
virtual gfx::Size GetSize() const;
virtual BalloonHost* GetHost() const;
// MenuGtk::Delegate interface.
virtual void StoppedShowing();
private:
// NotificationObserver interface.
virtual void Observe(NotificationType type,
......@@ -124,6 +127,12 @@ class BalloonViewImpl : public BalloonView,
NotificationRegistrar notification_registrar_;
// Is the menu currently showing?
bool menu_showing_;
// Is there a pending system-initiated close?
bool pending_close_;
DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment