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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 7 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
8 8
9 #include <string> 9 #include <string>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // is actually being called in all the cases it should be, at which point 560 // is actually being called in all the cases it should be, at which point
561 // we'll know whether or not that's handled for us by WebKit. 561 // we'll know whether or not that's handled for us by WebKit.
562 if (!is_visible) 562 if (!is_visible)
563 FocusChanged(false); 563 FocusChanged(false);
564 564
565 // If the plugin is changing visibility, let the plugin know. If it's scrolled 565 // If the plugin is changing visibility, let the plugin know. If it's scrolled
566 // off screen (i.e., clip_rect_ is empty), then container visibility doesn't 566 // off screen (i.e., clip_rect_ is empty), then container visibility doesn't
567 // change anything. 567 // change anything.
568 if (!clip_rect_.IsEmpty()) { 568 if (!clip_rect_.IsEmpty()) {
569 #ifndef NP_NO_CARBON 569 #ifndef NP_NO_CARBON
570 if (instance()->event_model() == NPEventModelCarbon) 570 if (instance() && instance()->event_model() == NPEventModelCarbon)
571 UpdateIdleEventRate(); 571 UpdateIdleEventRate();
572 #endif 572 #endif
573 WindowlessSetWindow(true); 573 WindowlessSetWindow(true);
574 } 574 }
575 } 575 }
576 576
577 void WebPluginDelegateImpl::WindowFrameChanged(gfx::Rect window_frame, 577 void WebPluginDelegateImpl::WindowFrameChanged(gfx::Rect window_frame,
578 gfx::Rect view_frame) { 578 gfx::Rect view_frame) {
579 instance()->set_window_frame(window_frame); 579 instance()->set_window_frame(window_frame);
580 SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y())); 580 SetContentAreaOrigin(gfx::Point(view_frame.x(), view_frame.y()));
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 SetContentAreaOrigin(content_area_origin_); 942 SetContentAreaOrigin(content_area_origin_);
943 } 943 }
944 944
945 current_windowless_cursor_.GetCursorInfo(cursor_info); 945 current_windowless_cursor_.GetCursorInfo(cursor_info);
946 } 946 }
947 947
948 // if we do not currently have focus and this is a mouseDown, trigger a 948 // if we do not currently have focus and this is a mouseDown, trigger a
949 // notification that we are taking the keyboard focus. We can't just key 949 // notification that we are taking the keyboard focus. We can't just key
950 // off of incoming calls to SetFocus, since WebKit may already think we 950 // off of incoming calls to SetFocus, since WebKit may already think we
951 // have it if we were the most recently focused element on our parent tab. 951 // have it if we were the most recently focused element on our parent tab.
952 if (event.type == WebInputEvent::MouseDown && !have_focus_) 952 if (event.type == WebInputEvent::MouseDown && !have_focus_) {
953 SetFocus(); 953 SetFocus();
954 // Make sure that the plugin is still there after handling the focus event.
955 if (!instance())
956 return false;
957 }
954 958
955 #ifndef NP_NO_CARBON 959 #ifndef NP_NO_CARBON
956 if (instance()->event_model() == NPEventModelCarbon) { 960 if (instance()->event_model() == NPEventModelCarbon) {
957 if (event.type == WebInputEvent::MouseMove) { 961 if (event.type == WebInputEvent::MouseMove) {
958 return true; // The recurring OnNull will send null events. 962 return true; // The recurring OnNull will send null events.
959 } 963 }
960 964
961 switch (instance()->drawing_model()) { 965 switch (instance()->drawing_model()) {
962 #ifndef NP_NO_QUICKDRAW 966 #ifndef NP_NO_QUICKDRAW
963 case NPDrawingModelQuickDraw: 967 case NPDrawingModelQuickDraw:
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 1014
1011 if (WebInputEventIsWebMouseEvent(event)) { 1015 if (WebInputEventIsWebMouseEvent(event)) {
1012 // Plugins are not good about giving accurate information about whether or 1016 // Plugins are not good about giving accurate information about whether or
1013 // not they handled events, and other browsers on the Mac generally ignore 1017 // not they handled events, and other browsers on the Mac generally ignore
1014 // the return value. We may need to expand this to other input types, but 1018 // the return value. We may need to expand this to other input types, but
1015 // we'll need to be careful about things like Command-keys. 1019 // we'll need to be careful about things like Command-keys.
1016 ret = true; 1020 ret = true;
1017 } 1021 }
1018 1022
1019 #ifndef NP_NO_CARBON 1023 #ifndef NP_NO_CARBON
1020 if (instance()->event_model() == NPEventModelCarbon && 1024 if (instance() && instance()->event_model() == NPEventModelCarbon &&
1021 instance()->drawing_model() == NPDrawingModelCoreGraphics && 1025 instance()->drawing_model() == NPDrawingModelCoreGraphics &&
1022 cg_context_.context == old_context_weak) 1026 cg_context_.context == old_context_weak)
1023 CGContextRestoreGState(cg_context_.context); 1027 CGContextRestoreGState(cg_context_.context);
1024 #endif 1028 #endif
1025 1029
1026 return ret; 1030 return ret;
1027 } 1031 }
1028 1032
1029 #ifndef NP_NO_CARBON 1033 #ifndef NP_NO_CARBON
1030 void WebPluginDelegateImpl::FireIdleEvent() { 1034 void WebPluginDelegateImpl::FireIdleEvent() {
1031 // Avoid a race condition between IO and UI threads during plugin shutdown 1035 // Avoid a race condition between IO and UI threads during plugin shutdown
1032 if (!instance_) 1036 if (!instance())
1033 return; 1037 return;
1034 1038
1035 ScopedActiveDelegate active_delegate(this); 1039 ScopedActiveDelegate active_delegate(this);
1036 1040
1037 if (!webkit_glue::IsPluginRunningInRendererProcess()) { 1041 if (!webkit_glue::IsPluginRunningInRendererProcess()) {
1038 switch (instance()->event_model()) { 1042 switch (instance()->event_model()) {
1039 case NPEventModelCarbon: 1043 case NPEventModelCarbon:
1040 // If the plugin is running in a subprocess, drain any pending system 1044 // If the plugin is running in a subprocess, drain any pending system
1041 // events so that the plugin's event handlers will get called on any 1045 // events so that the plugin's event handlers will get called on any
1042 // windows it has created. Filter out activate/deactivate events on 1046 // windows it has created. Filter out activate/deactivate events on
1043 // the fake browser window, but pass everything else through. 1047 // the fake browser window, but pass everything else through.
1044 EventRecord event; 1048 EventRecord event;
1045 while (GetNextEvent(everyEvent, &event)) { 1049 while (GetNextEvent(everyEvent, &event)) {
1046 if (event.what == activateEvt && cg_context_.window && 1050 if (event.what == activateEvt && cg_context_.window &&
1047 reinterpret_cast<void *>(event.message) != cg_context_.window) 1051 reinterpret_cast<void *>(event.message) != cg_context_.window)
1048 continue; 1052 continue;
1049 instance()->NPP_HandleEvent(&event); 1053 instance()->NPP_HandleEvent(&event);
1054 // If the plugin went away during event handling, we're done.
1055 if (!instance())
1056 return;
1050 } 1057 }
1051 break; 1058 break;
1052 } 1059 }
1053 } 1060 }
1054 1061
1055 if (instance()->event_model() == NPEventModelCarbon) { 1062 if (instance()->event_model() == NPEventModelCarbon) {
1056 // Send an idle event so that the plugin can do background work 1063 // Send an idle event so that the plugin can do background work
1057 NPEvent np_event = {0}; 1064 NPEvent np_event = {0};
1058 np_event.what = nullEvent; 1065 np_event.what = nullEvent;
1059 np_event.when = TickCount(); 1066 np_event.when = TickCount();
1060 np_event.modifiers = GetCurrentKeyModifiers(); 1067 np_event.modifiers = GetCurrentKeyModifiers();
1061 if (!Button()) 1068 if (!Button())
1062 np_event.modifiers |= btnState; 1069 np_event.modifiers |= btnState;
1063 HIPoint mouse_location; 1070 HIPoint mouse_location;
1064 HIGetMousePosition(kHICoordSpaceScreenPixel, NULL, &mouse_location); 1071 HIGetMousePosition(kHICoordSpaceScreenPixel, NULL, &mouse_location);
1065 np_event.where.h = mouse_location.x; 1072 np_event.where.h = mouse_location.x;
1066 np_event.where.v = mouse_location.y; 1073 np_event.where.v = mouse_location.y;
1067 instance()->NPP_HandleEvent(&np_event); 1074 instance()->NPP_HandleEvent(&np_event);
1068 } 1075 }
1069 1076
1070 #ifndef NP_NO_QUICKDRAW 1077 #ifndef NP_NO_QUICKDRAW
1071 // Quickdraw-based plugins can draw at any time, so tell the renderer to 1078 // Quickdraw-based plugins can draw at any time, so tell the renderer to
1072 // repaint. 1079 // repaint.
1073 // TODO: only do this if the contents of the offscreen window has changed, 1080 // TODO: only do this if the contents of the offscreen window has changed,
1074 // so as not to spam the renderer with an unchanging image. 1081 // so as not to spam the renderer with an unchanging image.
1075 if (instance()->drawing_model() == NPDrawingModelQuickDraw) 1082 if (instance() && instance()->drawing_model() == NPDrawingModelQuickDraw)
1076 instance()->webplugin()->Invalidate(); 1083 instance()->webplugin()->Invalidate();
1077 #endif 1084 #endif
1078 } 1085 }
1079 #endif // !NP_NO_CARBON 1086 #endif // !NP_NO_CARBON
OLDNEW
« 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