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

Side by Side Diff: webkit/glue/plugins/webplugin_delegate_impl.cc

Issue 21453: Try a new approach to fixing IAT unpatch crashes when the DLL is gone. (Closed)
Patch Set: DCHECK Created 11 years, 9 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
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 #include "webkit/glue/plugins/webplugin_delegate_impl.h" 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 windowless_needs_set_window_(true), 148 windowless_needs_set_window_(true),
149 plugin_wnd_proc_(NULL), 149 plugin_wnd_proc_(NULL),
150 last_message_(0), 150 last_message_(0),
151 is_calling_wndproc(false), 151 is_calling_wndproc(false),
152 dummy_window_for_activation_(NULL), 152 dummy_window_for_activation_(NULL),
153 handle_event_message_filter_hook_(NULL), 153 handle_event_message_filter_hook_(NULL),
154 handle_event_pump_messages_event_(NULL), 154 handle_event_pump_messages_event_(NULL),
155 handle_event_depth_(0), 155 handle_event_depth_(0),
156 user_gesture_message_posted_(false), 156 user_gesture_message_posted_(false),
157 #pragma warning(suppress: 4355) // can use this 157 #pragma warning(suppress: 4355) // can use this
158 user_gesture_msg_factory_(this), 158 user_gesture_msg_factory_(this) {
159 plugin_module_handle_(NULL) {
160 memset(&window_, 0, sizeof(window_)); 159 memset(&window_, 0, sizeof(window_));
161 160
162 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); 161 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info();
163 std::string filename = 162 std::string filename =
164 WideToUTF8(StringToLowerASCII(plugin_info.path.BaseName().value())); 163 WideToUTF8(StringToLowerASCII(plugin_info.path.BaseName().value()));
165 164
166 if (instance_->mime_type() == "application/x-shockwave-flash" || 165 if (instance_->mime_type() == "application/x-shockwave-flash" ||
167 filename == "npswf32.dll") { 166 filename == "npswf32.dll") {
168 // Flash only requests windowless plugins if we return a Mozilla user 167 // Flash only requests windowless plugins if we return a Mozilla user
169 // agent. 168 // agent.
(...skipping 24 matching lines...) Expand all
194 // handle 193 // handle
195 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY; 194 quirks_ |= PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY;
196 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created. 195 // VLC 0.8.6d and 0.8.6e crash if multiple instances are created.
197 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES; 196 quirks_ |= PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES;
198 } else if (filename == "npctrl.dll") { 197 } else if (filename == "npctrl.dll") {
199 // Explanation for this quirk can be found in 198 // Explanation for this quirk can be found in
200 // WebPluginDelegateImpl::Initialize. 199 // WebPluginDelegateImpl::Initialize.
201 quirks_ |= PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU; 200 quirks_ |= PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU;
202 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; 201 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
203 } 202 }
204
205 plugin_module_handle_ = ::GetModuleHandle(plugin_info.path.value().c_str());
206 } 203 }
207 204
208 WebPluginDelegateImpl::~WebPluginDelegateImpl() { 205 WebPluginDelegateImpl::~WebPluginDelegateImpl() {
209 if (::IsWindow(dummy_window_for_activation_)) { 206 if (::IsWindow(dummy_window_for_activation_)) {
210 ::DestroyWindow(dummy_window_for_activation_); 207 ::DestroyWindow(dummy_window_for_activation_);
211 TRACK_HWND_DESTRUCTION(dummy_window_for_activation_); 208 TRACK_HWND_DESTRUCTION(dummy_window_for_activation_);
212 } 209 }
213 210
214 DestroyInstance(); 211 DestroyInstance();
215 212
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // WindowFromPoint API and passes the result of that to the 273 // WindowFromPoint API and passes the result of that to the
277 // TrackPopupMenu API call as the owner window. This causes the API 274 // TrackPopupMenu API call as the owner window. This causes the API
278 // to fail as the API expects the window handle to live on the same 275 // to fail as the API expects the window handle to live on the same
279 // thread as the caller. It works in the other browsers as the plugin 276 // thread as the caller. It works in the other browsers as the plugin
280 // lives on the browser thread. Our workaround is to intercept the 277 // lives on the browser thread. Our workaround is to intercept the
281 // TrackPopupMenu API for Silverlight and replace the window handle 278 // TrackPopupMenu API for Silverlight and replace the window handle
282 // with the dummy activation window. 279 // with the dummy activation window.
283 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched() && 280 if (windowless_ && !g_iat_patch_track_popup_menu.Pointer()->is_patched() &&
284 (quirks_ & PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU)) { 281 (quirks_ & PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU)) {
285 g_iat_patch_track_popup_menu.Pointer()->Patch( 282 g_iat_patch_track_popup_menu.Pointer()->Patch(
286 plugin_module_handle_, "user32.dll", "TrackPopupMenu", 283 GetPluginPath().value().c_str(), "user32.dll", "TrackPopupMenu",
287 WebPluginDelegateImpl::TrackPopupMenuPatch); 284 WebPluginDelegateImpl::TrackPopupMenuPatch);
288 } 285 }
289 286
290 // Windowless plugins can set cursors by calling the SetCursor API. This 287 // Windowless plugins can set cursors by calling the SetCursor API. This
291 // works because the thread inputs of the browser UI thread and the plugin 288 // works because the thread inputs of the browser UI thread and the plugin
292 // thread are attached. We intercept the SetCursor API for windowless plugins 289 // thread are attached. We intercept the SetCursor API for windowless plugins
293 // and remember the cursor being set. This is shipped over to the browser 290 // and remember the cursor being set. This is shipped over to the browser
294 // in the HandleEvent call, which ensures that the cursor does not change 291 // in the HandleEvent call, which ensures that the cursor does not change
295 // when a windowless plugin instance changes the cursor in a background tab. 292 // when a windowless plugin instance changes the cursor in a background tab.
296 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() && 293 if (windowless_ && !g_iat_patch_set_cursor.Pointer()->is_patched() &&
297 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) { 294 (quirks_ & PLUGIN_QUIRK_PATCH_SETCURSOR)) {
298 g_iat_patch_set_cursor.Pointer()->Patch( 295 g_iat_patch_set_cursor.Pointer()->Patch(
299 plugin_module_handle_, "user32.dll", "SetCursor", 296 GetPluginPath().value().c_str(), "user32.dll", "SetCursor",
300 WebPluginDelegateImpl::SetCursorPatch); 297 WebPluginDelegateImpl::SetCursorPatch);
301 } 298 }
302 return true; 299 return true;
303 } 300 }
304 301
305 void WebPluginDelegateImpl::DestroyInstance() { 302 void WebPluginDelegateImpl::DestroyInstance() {
306 if (instance_ && (instance_->npp()->ndata != NULL)) { 303 if (instance_ && (instance_->npp()->ndata != NULL)) {
307 // Shutdown all streams before destroying so that 304 // Shutdown all streams before destroying so that
308 // no streams are left "in progress". Need to do 305 // no streams are left "in progress". Need to do
309 // this before calling set_web_plugin(NULL) because the 306 // this before calling set_web_plugin(NULL) because the
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 1192
1196 // It is ok to pass NULL here to GetCursor as we are not looking for cursor 1193 // It is ok to pass NULL here to GetCursor as we are not looking for cursor
1197 // types defined by Webkit. 1194 // types defined by Webkit.
1198 HCURSOR previous_cursor = 1195 HCURSOR previous_cursor =
1199 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); 1196 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL);
1200 1197
1201 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( 1198 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor(
1202 cursor); 1199 cursor);
1203 return previous_cursor; 1200 return previous_cursor;
1204 } 1201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698