OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 for (UINT i = 0; i < num_chars; ++i) { | 407 for (UINT i = 0; i < num_chars; ++i) { |
408 if (path_to_use[i] == '\\') { | 408 if (path_to_use[i] == '\\') { |
409 path_to_use[i] = '/'; | 409 path_to_use[i] = '/'; |
410 } | 410 } |
411 } | 411 } |
412 obj->RedirectToFile(path_to_use); | 412 obj->RedirectToFile(path_to_use); |
413 | 413 |
414 return 1; | 414 return 1; |
415 } | 415 } |
416 | 416 |
| 417 static const UINT kDestroyWindowMessageID = WM_USER + 1; |
| 418 |
417 LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { | 419 LRESULT CALLBACK WindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { |
| 420 // To work around deadlocks caused by calling DestroyWindow |
| 421 // synchronously during plugin destruction in Chrome's multi-process |
| 422 // architecture, we call DestroyWindow asynchronously. |
| 423 if (Msg == kDestroyWindowMessageID) { |
| 424 ::DestroyWindow(hWnd); |
| 425 // Do not touch anything related to the plugin; it has likely |
| 426 // already been destroyed. |
| 427 return 0; |
| 428 } |
| 429 |
418 PluginObject *obj = PluginObject::GetPluginProperty(hWnd); | 430 PluginObject *obj = PluginObject::GetPluginProperty(hWnd); |
419 if (obj == NULL) { // It's not my window | 431 if (obj == NULL) { // It's not my window |
420 return 1; // 0 often means we handled it. | 432 return 1; // 0 often means we handled it. |
421 } | 433 } |
422 | 434 |
423 // Limit the ways in which we can be reentrant. Note that this WindowProc | 435 // Limit the ways in which we can be reentrant. Note that this WindowProc |
424 // may be called by different threads. For example, IE will register plugin | 436 // may be called by different threads. For example, IE will register plugin |
425 // instances on separate threads. | 437 // instances on separate threads. |
426 o3d::Client::ScopedIncrement reentrance_count(obj->client()); | 438 o3d::Client::ScopedIncrement reentrance_count(obj->client()); |
427 | 439 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 if (!RegisterO3DWindowClass()) | 675 if (!RegisterO3DWindowClass()) |
664 return NPERR_MODULE_LOAD_FAILED_ERROR; | 676 return NPERR_MODULE_LOAD_FAILED_ERROR; |
665 | 677 |
666 return NPERR_NO_ERROR; | 678 return NPERR_NO_ERROR; |
667 } | 679 } |
668 | 680 |
669 void CleanupAllWindows(PluginObject *obj) { | 681 void CleanupAllWindows(PluginObject *obj) { |
670 if (obj->GetContentHWnd()) { | 682 if (obj->GetContentHWnd()) { |
671 ::KillTimer(obj->GetContentHWnd(), 0); | 683 ::KillTimer(obj->GetContentHWnd(), 0); |
672 PluginObject::ClearPluginProperty(obj->GetContentHWnd()); | 684 PluginObject::ClearPluginProperty(obj->GetContentHWnd()); |
673 ::DestroyWindow(obj->GetContentHWnd()); | 685 ::PostMessage(obj->GetContentHWnd(), kDestroyWindowMessageID, 0, 0); |
674 obj->SetContentHWnd(NULL); | 686 obj->SetContentHWnd(NULL); |
675 } | 687 } |
676 | 688 |
677 if (obj->GetPluginHWnd()) { | 689 if (obj->GetPluginHWnd()) { |
678 // Restore the original WNDPROC on the plugin window so that we | 690 // Restore the original WNDPROC on the plugin window so that we |
679 // don't attempt to call into the O3D DLL after it's been unloaded. | 691 // don't attempt to call into the O3D DLL after it's been unloaded. |
680 LONG_PTR origWndProc = reinterpret_cast<LONG_PTR>( | 692 LONG_PTR origWndProc = reinterpret_cast<LONG_PTR>( |
681 GetProp(obj->GetPluginHWnd(), | 693 GetProp(obj->GetPluginHWnd(), |
682 kOrigWndProcName)); | 694 kOrigWndProcName)); |
683 DCHECK(origWndProc != NULL); | 695 DCHECK(origWndProc != NULL); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 if (!renderer_->CancelFullscreen(display, prev_width_, prev_height_)) { | 994 if (!renderer_->CancelFullscreen(display, prev_width_, prev_height_)) { |
983 LOG(FATAL) << "Failed to get the renderer out of fullscreen mode!"; | 995 LOG(FATAL) << "Failed to get the renderer out of fullscreen mode!"; |
984 } | 996 } |
985 ReplaceContentWindow(GetContentHWnd(), GetPluginHWnd(), | 997 ReplaceContentWindow(GetContentHWnd(), GetPluginHWnd(), |
986 prev_width_, prev_height_); | 998 prev_width_, prev_height_); |
987 client()->SendResizeEvent(prev_width_, prev_height_, false); | 999 client()->SendResizeEvent(prev_width_, prev_height_, false); |
988 } | 1000 } |
989 } | 1001 } |
990 } // namespace _o3d | 1002 } // namespace _o3d |
991 } // namespace glue | 1003 } // namespace glue |
OLD | NEW |