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

Side by Side Diff: Source/modules/notifications/Notification.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.h ('k') | Source/web/WebNotification.cpp » ('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 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2009, 2011, 2012 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void Notification::finalize() 192 void Notification::finalize()
193 { 193 {
194 if (m_state == Closed) 194 if (m_state == Closed)
195 return; 195 return;
196 m_state = Closed; 196 m_state = Closed;
197 unsetPendingActivity(this); 197 unsetPendingActivity(this);
198 } 198 }
199 199
200 void Notification::dispatchShowEvent() 200 void Notification::dispatchShowEvent()
201 { 201 {
202 #if ENABLE(LEGACY_NOTIFICATIONS)
203 dispatchEvent(Event::create(eventNames().displayEvent, false, false));
204 #endif
202 dispatchEvent(Event::create(eventNames().showEvent, false, false)); 205 dispatchEvent(Event::create(eventNames().showEvent, false, false));
203 } 206 }
204 207
205 void Notification::dispatchClickEvent() 208 void Notification::dispatchClickEvent()
206 { 209 {
210 UserGestureIndicator gestureIndicator(DefinitelyProcessingNewUserGesture);
207 WindowFocusAllowedIndicator windowFocusAllowed; 211 WindowFocusAllowedIndicator windowFocusAllowed;
208 dispatchEvent(Event::create(eventNames().clickEvent, false, false)); 212 dispatchEvent(Event::create(eventNames().clickEvent, false, false));
209 } 213 }
210 214
211 void Notification::dispatchCloseEvent() 215 void Notification::dispatchCloseEvent()
212 { 216 {
213 dispatchEvent(Event::create(eventNames().closeEvent, false, false)); 217 dispatchEvent(Event::create(eventNames().closeEvent, false, false));
214 finalize(); 218 finalize();
215 } 219 }
216 220
217 void Notification::dispatchErrorEvent() 221 void Notification::dispatchErrorEvent()
218 { 222 {
219 dispatchEvent(Event::create(eventNames().errorEvent, false, false)); 223 dispatchEvent(Event::create(eventNames().errorEvent, false, false));
220 } 224 }
221 225
222 #if ENABLE(NOTIFICATIONS) 226 #if ENABLE(NOTIFICATIONS)
223 void Notification::taskTimerFired(Timer<Notification>* timer) 227 void Notification::taskTimerFired(Timer<Notification>* timer)
224 { 228 {
225 ASSERT(scriptExecutionContext()->isDocument()); 229 ASSERT(scriptExecutionContext()->isDocument());
226 ASSERT_UNUSED(timer, timer == m_taskTimer.get()); 230 ASSERT_UNUSED(timer, timer == m_taskTimer.get());
227 show(); 231 show();
228 } 232 }
229 #endif 233 #endif
230 234
235 bool Notification::dispatchEvent(PassRefPtr<Event> event)
236 {
237 // Do not dispatch if the context is gone.
238 if (!scriptExecutionContext())
239 return false;
240
241 return EventTarget::dispatchEvent(event);
242 }
231 243
232 #if ENABLE(NOTIFICATIONS) 244 #if ENABLE(NOTIFICATIONS)
233 const String& Notification::permission(ScriptExecutionContext* context) 245 const String& Notification::permission(ScriptExecutionContext* context)
234 { 246 {
235 ASSERT(toDocument(context)->page()); 247 ASSERT(toDocument(context)->page());
236 return permissionString(NotificationController::from(toDocument(context)->pa ge())->client()->checkPermission(context)); 248 return permissionString(NotificationController::from(toDocument(context)->pa ge())->client()->checkPermission(context));
237 } 249 }
238 250
239 const String& Notification::permissionString(NotificationClient::Permission perm ission) 251 const String& Notification::permissionString(NotificationClient::Permission perm ission)
240 { 252 {
(...skipping 17 matching lines...) Expand all
258 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr <NotificationPermissionCallback> callback) 270 void Notification::requestPermission(ScriptExecutionContext* context, PassRefPtr <NotificationPermissionCallback> callback)
259 { 271 {
260 ASSERT(toDocument(context)->page()); 272 ASSERT(toDocument(context)->page());
261 NotificationController::from(toDocument(context)->page())->client()->request Permission(context, callback); 273 NotificationController::from(toDocument(context)->page())->client()->request Permission(context, callback);
262 } 274 }
263 #endif 275 #endif
264 276
265 } // namespace WebCore 277 } // namespace WebCore
266 278
267 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS) 279 #endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
OLDNEW
« no previous file with comments | « Source/modules/notifications/Notification.h ('k') | Source/web/WebNotification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698