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

Side by Side Diff: Source/web/WebNotification.cpp

Issue 22909013: Notification should not leak document. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update testexp 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/notifications/Notification.cpp ('k') | public/web/WebNotification.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 return m_private->tag(); 104 return m_private->tag();
105 } 105 }
106 106
107 void WebNotification::detachPresenter() 107 void WebNotification::detachPresenter()
108 { 108 {
109 m_private->detachPresenter(); 109 m_private->detachPresenter();
110 } 110 }
111 111
112 void WebNotification::dispatchDisplayEvent() 112 void WebNotification::dispatchDisplayEvent()
113 { 113 {
114 #if ENABLE(LEGACY_NOTIFICATIONS) 114 m_private->dispatchShowEvent();
115 dispatchEvent("display");
116 #endif
117 dispatchEvent("show");
118 } 115 }
119 116
120 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessag e */) 117 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessag e */)
121 { 118 {
122 // FIXME: errorMessage not supported by WebCore yet 119 // FIXME: errorMessage not supported by WebCore yet
123 dispatchEvent(eventNames().errorEvent); 120 m_private->dispatchErrorEvent();
124 } 121 }
125 122
126 void WebNotification::dispatchCloseEvent(bool /* byUser */) 123 void WebNotification::dispatchCloseEvent(bool /* byUser */)
127 { 124 {
128 // FIXME: byUser flag not supported by WebCore yet 125 // FIXME: byUser flag not supported by WebCore yet
129 dispatchEvent(eventNames().closeEvent); 126 m_private->dispatchCloseEvent();
130 } 127 }
131 128
132 void WebNotification::dispatchClickEvent() 129 void WebNotification::dispatchClickEvent()
133 { 130 {
134 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture); 131 m_private->dispatchClickEvent();
135 WindowFocusAllowedIndicator windowFocusAllowed;
136 dispatchEvent(eventNames().clickEvent);
137 }
138
139 void WebNotification::dispatchEvent(const WTF::AtomicString& type)
140 {
141 // Do not dispatch if the context is gone.
142 if (!m_private->scriptExecutionContext())
143 return;
144
145 RefPtr<Event> event = Event::create(type, false, true);
146 m_private->dispatchEvent(event.release());
147 } 132 }
148 133
149 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notificati on) 134 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notificati on)
150 : m_private(static_cast<WebNotificationPrivate*>(notification.leakRef())) 135 : m_private(static_cast<WebNotificationPrivate*>(notification.leakRef()))
151 { 136 {
152 } 137 }
153 138
154 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification) 139 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification)
155 { 140 {
156 assign(static_cast<WebNotificationPrivate*>(notification.leakRef())); 141 assign(static_cast<WebNotificationPrivate*>(notification.leakRef()));
157 return *this; 142 return *this;
158 } 143 }
159 144
160 WebNotification::operator WTF::PassRefPtr<Notification>() const 145 WebNotification::operator WTF::PassRefPtr<Notification>() const
161 { 146 {
162 return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_p rivate)); 147 return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_p rivate));
163 } 148 }
164 149
165 void WebNotification::assign(WebNotificationPrivate* p) 150 void WebNotification::assign(WebNotificationPrivate* p)
166 { 151 {
167 // p is already ref'd for us by the caller 152 // p is already ref'd for us by the caller
168 if (m_private) 153 if (m_private)
169 m_private->deref(); 154 m_private->deref();
170 m_private = p; 155 m_private = p;
171 } 156 }
172 157
173 } // namespace WebKit 158 } // namespace WebKit
174 159
175 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 160 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
OLDNEW
« no previous file with comments | « Source/modules/notifications/Notification.cpp ('k') | public/web/WebNotification.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698