Title: [88743] branches/chromium/782/Source/WebKit/chromium
Revision
88743
Author
[email protected]
Date
2011-06-13 18:00:39 -0700 (Mon, 13 Jun 2011)

Log Message

Merge 88738 - [Chromium] WebNotification should check if ScriptExecutionContext is gone
before dispatching events.
https://bugs.webkit.org/show_bug.cgi?id=62592

Reviewed by David Levin.

* public/WebNotification.h:
* src/WebNotification.cpp:
(WebKit::WebNotification::dispatchDisplayEvent):
(WebKit::WebNotification::dispatchErrorEvent):
(WebKit::WebNotification::dispatchCloseEvent):
(WebKit::WebNotification::dispatchClickEvent):
(WebKit::WebNotification::dispatchEvent): Added a helper method to check
the context and dispatch an event.

[email protected]
BUG=84660
Review URL: http://codereview.chromium.org/7148005

Modified Paths

Diff

Modified: branches/chromium/782/Source/WebKit/chromium/public/WebNotification.h (88742 => 88743)


--- branches/chromium/782/Source/WebKit/chromium/public/WebNotification.h	2011-06-14 00:58:17 UTC (rev 88742)
+++ branches/chromium/782/Source/WebKit/chromium/public/WebNotification.h	2011-06-14 01:00:39 UTC (rev 88743)
@@ -39,6 +39,10 @@
 namespace WTF { template <typename T> class PassRefPtr; }
 #endif
 
+namespace WTF {
+class AtomicString;
+}
+
 namespace WebKit {
 
 class WebNotificationPrivate;
@@ -104,6 +108,7 @@
 
 private:
     void assign(WebNotificationPrivate*);
+    void dispatchEvent(const WTF::AtomicString& type);
     WebNotificationPrivate* m_private;
 };
 

Modified: branches/chromium/782/Source/WebKit/chromium/src/WebNotification.cpp (88742 => 88743)


--- branches/chromium/782/Source/WebKit/chromium/src/WebNotification.cpp	2011-06-14 00:58:17 UTC (rev 88742)
+++ branches/chromium/782/Source/WebKit/chromium/src/WebNotification.cpp	2011-06-14 01:00:39 UTC (rev 88743)
@@ -116,29 +116,35 @@
 
 void WebNotification::dispatchDisplayEvent()
 {
-    RefPtr<Event> event = Event::create("display", false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent("display");
 }
 
 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */)
 {
     // FIXME: errorMessage not supported by WebCore yet
-    RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent(eventNames().errorEvent);
 }
 
 void WebNotification::dispatchCloseEvent(bool /* byUser */)
 {
     // FIXME: byUser flag not supported by WebCore yet
-    RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true);
-    m_private->dispatchEvent(event.release());
+    dispatchEvent(eventNames().closeEvent);
 }
 
 void WebNotification::dispatchClickEvent()
 {
     // Make sure clicks on notifications are treated as user gestures.
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture);
-    RefPtr<Event> event = Event::create(eventNames().clickEvent, false, true);
+    dispatchEvent(eventNames().clickEvent);
+}
+
+void WebNotification::dispatchEvent(const WTF::AtomicString& type)
+{
+    // Do not dispatch if the context is gone.
+    if (!m_private->scriptExecutionContext())
+        return;
+
+    RefPtr<Event> event = Event::create(type, false, true);
     m_private->dispatchEvent(event.release());
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to