Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 22909013: Notification should not leak document. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add test expectation Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 742e6b7517f5fa90285c79f957aa4a0cadbea9ca..d1e58e0059080a281e6a980b56a1a9ca52ef441d 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -55,14 +55,14 @@
namespace WebCore {
Notification::Notification()
- : ActiveDOMObject(0)
+ : ContextLifecycleObserver(0)
{
ScriptWrappable::init(this);
}
#if ENABLE(LEGACY_NOTIFICATIONS)
Notification::Notification(const String& title, const String& body, const String& iconURI, ScriptExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider)
- : ActiveDOMObject(context)
+ : ContextLifecycleObserver(context)
, m_title(title)
, m_body(body)
, m_state(Idle)
@@ -84,7 +84,7 @@ Notification::Notification(const String& title, const String& body, const String
#if ENABLE(NOTIFICATIONS)
Notification::Notification(ScriptExecutionContext* context, const String& title)
- : ActiveDOMObject(context)
+ : ContextLifecycleObserver(context)
, m_title(title)
, m_state(Idle)
, m_taskTimer(adoptPtr(new Timer<Notification>(this, &Notification::taskTimerFired)))
@@ -105,7 +105,6 @@ Notification::~Notification()
PassRefPtr<Notification> Notification::create(const String& title, const String& body, const String& iconURI, ScriptExecutionContext* context, ExceptionState& es, PassRefPtr<NotificationCenter> provider)
{
RefPtr<Notification> notification(adoptRef(new Notification(title, body, iconURI, context, es, provider)));
- notification->suspendIfNeeded();
return notification.release();
}
#endif
@@ -129,7 +128,6 @@ PassRefPtr<Notification> Notification::create(ScriptExecutionContext* context, c
notification->setIconURL(iconURI);
}
- notification->suspendIfNeeded();
return notification.release();
}
#endif
@@ -153,7 +151,6 @@ void Notification::show()
#endif
if (m_notificationCenter->client()->show(this)) {
m_state = Showing;
- setPendingActivity(this);
}
}
}
@@ -184,26 +181,22 @@ EventTargetData* Notification::ensureEventTargetData()
void Notification::contextDestroyed()
{
- ActiveDOMObject::contextDestroyed();
+ ContextLifecycleObserver::contextDestroyed();
if (m_notificationCenter->client())
m_notificationCenter->client()->notificationObjectDestroyed(this);
}
-void Notification::finalize()
-{
- if (m_state == Closed)
- return;
- m_state = Closed;
- unsetPendingActivity(this);
-}
-
void Notification::dispatchShowEvent()
{
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ dispatchEvent(Event::create(eventNames().displayEvent, false, false));
+#endif
dispatchEvent(Event::create(eventNames().showEvent, false, false));
}
void Notification::dispatchClickEvent()
{
+ UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
WindowFocusAllowedIndicator windowFocusAllowed;
dispatchEvent(Event::create(eventNames().clickEvent, false, false));
}
@@ -211,7 +204,7 @@ void Notification::dispatchClickEvent()
void Notification::dispatchCloseEvent()
{
dispatchEvent(Event::create(eventNames().closeEvent, false, false));
- finalize();
+ m_state = Closed;
}
void Notification::dispatchErrorEvent()

Powered by Google App Engine
This is Rietveld 408576698