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

Unified Diff: webkit/glue/plugins/webplugin_delegate_impl_mac.mm

Issue 609003: Add checks for Mac plugin instance destruction after NPP_* calls (Closed)
Patch Set: Created 10 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/plugins/webplugin_delegate_impl_mac.mm
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 58e3b3db299a8ae45009844aa66dcc18a2e32ca4..b22808898151193cb5ec6cf8b4cc3e0c743c87de 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -567,7 +567,7 @@ void WebPluginDelegateImpl::SetContainerVisibility(bool is_visible) {
// change anything.
if (!clip_rect_.IsEmpty()) {
#ifndef NP_NO_CARBON
- if (instance()->event_model() == NPEventModelCarbon)
+ if (instance() && instance()->event_model() == NPEventModelCarbon)
UpdateIdleEventRate();
#endif
WindowlessSetWindow(true);
@@ -949,8 +949,12 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
// notification that we are taking the keyboard focus. We can't just key
// off of incoming calls to SetFocus, since WebKit may already think we
// have it if we were the most recently focused element on our parent tab.
- if (event.type == WebInputEvent::MouseDown && !have_focus_)
+ if (event.type == WebInputEvent::MouseDown && !have_focus_) {
SetFocus();
+ // Make sure that the plugin is still there after handling the focus event.
+ if (!instance())
+ return false;
+ }
#ifndef NP_NO_CARBON
if (instance()->event_model() == NPEventModelCarbon) {
@@ -1017,7 +1021,7 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
}
#ifndef NP_NO_CARBON
- if (instance()->event_model() == NPEventModelCarbon &&
+ if (instance() && instance()->event_model() == NPEventModelCarbon &&
instance()->drawing_model() == NPDrawingModelCoreGraphics &&
cg_context_.context == old_context_weak)
CGContextRestoreGState(cg_context_.context);
@@ -1029,7 +1033,7 @@ bool WebPluginDelegateImpl::PlatformHandleInputEvent(
#ifndef NP_NO_CARBON
void WebPluginDelegateImpl::FireIdleEvent() {
// Avoid a race condition between IO and UI threads during plugin shutdown
- if (!instance_)
+ if (!instance())
return;
ScopedActiveDelegate active_delegate(this);
@@ -1047,6 +1051,9 @@ void WebPluginDelegateImpl::FireIdleEvent() {
reinterpret_cast<void *>(event.message) != cg_context_.window)
continue;
instance()->NPP_HandleEvent(&event);
+ // If the plugin went away during event handling, we're done.
+ if (!instance())
+ return;
}
break;
}
@@ -1072,7 +1079,7 @@ void WebPluginDelegateImpl::FireIdleEvent() {
// repaint.
// TODO: only do this if the contents of the offscreen window has changed,
// so as not to spam the renderer with an unchanging image.
- if (instance()->drawing_model() == NPDrawingModelQuickDraw)
+ if (instance() && instance()->drawing_model() == NPDrawingModelQuickDraw)
instance()->webplugin()->Invalidate();
#endif
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698