OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/child/npapi/webplugin_delegate_impl.h" | 5 #include "content/child/npapi/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 | 1015 |
1016 // Maintain a local/global stack for the g_current_plugin_instance variable | 1016 // Maintain a local/global stack for the g_current_plugin_instance variable |
1017 // as this may be a nested invocation. | 1017 // as this may be a nested invocation. |
1018 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; | 1018 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; |
1019 | 1019 |
1020 g_current_plugin_instance = delegate; | 1020 g_current_plugin_instance = delegate; |
1021 | 1021 |
1022 result = CallWindowProc( | 1022 result = CallWindowProc( |
1023 delegate->plugin_wnd_proc_, hwnd, message, wparam, lparam); | 1023 delegate->plugin_wnd_proc_, hwnd, message, wparam, lparam); |
1024 | 1024 |
1025 delegate->is_calling_wndproc = false; | 1025 // The plugin instance may have been destroyed in the CallWindowProc call |
| 1026 // above. This will also destroy the plugin window. Before attempting to |
| 1027 // access the WebPluginDelegateImpl instance we validate if the window is |
| 1028 // still valid. |
| 1029 if (::IsWindow(hwnd)) |
| 1030 delegate->is_calling_wndproc = false; |
| 1031 |
1026 g_current_plugin_instance = last_plugin_instance; | 1032 g_current_plugin_instance = last_plugin_instance; |
1027 | 1033 |
1028 if (message == WM_NCDESTROY) { | 1034 if (message == WM_NCDESTROY) { |
1029 RemoveProp(hwnd, kWebPluginDelegateProperty); | 1035 RemoveProp(hwnd, kWebPluginDelegateProperty); |
1030 ATOM plugin_name_atom = reinterpret_cast<ATOM>( | 1036 ATOM plugin_name_atom = reinterpret_cast<ATOM>( |
1031 RemoveProp(hwnd, kPluginNameAtomProperty)); | 1037 RemoveProp(hwnd, kPluginNameAtomProperty)); |
1032 if (plugin_name_atom != 0) | 1038 if (plugin_name_atom != 0) |
1033 GlobalDeleteAtom(plugin_name_atom); | 1039 GlobalDeleteAtom(plugin_name_atom); |
1034 ATOM plugin_version_atom = reinterpret_cast<ATOM>( | 1040 ATOM plugin_version_atom = reinterpret_cast<ATOM>( |
1035 RemoveProp(hwnd, kPluginVersionAtomProperty)); | 1041 RemoveProp(hwnd, kPluginVersionAtomProperty)); |
1036 if (plugin_version_atom != 0) | 1042 if (plugin_version_atom != 0) |
1037 GlobalDeleteAtom(plugin_version_atom); | 1043 GlobalDeleteAtom(plugin_version_atom); |
1038 ClearThrottleQueueForWindow(hwnd); | 1044 ClearThrottleQueueForWindow(hwnd); |
1039 } | 1045 } |
1040 } | 1046 } |
1041 delegate->last_message_ = old_message; | 1047 if (::IsWindow(hwnd)) |
| 1048 delegate->last_message_ = old_message; |
1042 return result; | 1049 return result; |
1043 } | 1050 } |
1044 | 1051 |
1045 void WebPluginDelegateImpl::WindowlessUpdateGeometry( | 1052 void WebPluginDelegateImpl::WindowlessUpdateGeometry( |
1046 const gfx::Rect& window_rect, | 1053 const gfx::Rect& window_rect, |
1047 const gfx::Rect& clip_rect) { | 1054 const gfx::Rect& clip_rect) { |
1048 bool window_rect_changed = (window_rect_ != window_rect); | 1055 bool window_rect_changed = (window_rect_ != window_rect); |
1049 // Only resend to the instance if the geometry has changed. | 1056 // Only resend to the instance if the geometry has changed. |
1050 if (!window_rect_changed && clip_rect == clip_rect_) | 1057 if (!window_rect_changed && clip_rect == clip_rect_) |
1051 return; | 1058 return; |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 case WM_RBUTTONUP: | 1530 case WM_RBUTTONUP: |
1524 ::ReleaseCapture(); | 1531 ::ReleaseCapture(); |
1525 break; | 1532 break; |
1526 | 1533 |
1527 default: | 1534 default: |
1528 break; | 1535 break; |
1529 } | 1536 } |
1530 } | 1537 } |
1531 | 1538 |
1532 } // namespace content | 1539 } // namespace content |
OLD | NEW |