| OLD | NEW |
| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 std::list<MSG> WebPluginDelegateImpl::throttle_queue_; | 46 std::list<MSG> WebPluginDelegateImpl::throttle_queue_; |
| 47 | 47 |
| 48 WebPluginDelegateImpl* WebPluginDelegateImpl::current_plugin_instance_ = NULL; | 48 WebPluginDelegateImpl* WebPluginDelegateImpl::current_plugin_instance_ = NULL; |
| 49 | 49 |
| 50 bool WebPluginDelegateImpl::track_popup_menu_patched_ = false; | 50 bool WebPluginDelegateImpl::track_popup_menu_patched_ = false; |
| 51 iat_patch::IATPatchFunction WebPluginDelegateImpl::iat_patch_helper_; | 51 iat_patch::IATPatchFunction WebPluginDelegateImpl::iat_patch_helper_; |
| 52 | 52 |
| 53 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( | 53 WebPluginDelegateImpl* WebPluginDelegateImpl::Create( |
| 54 const std::wstring& filename, | 54 const std::wstring& filename, |
| 55 const std::string& mime_type, | 55 const std::string& mime_type, |
| 56 HWND containing_window) { | 56 gfx::NativeView containing_view) { |
| 57 scoped_refptr<NPAPI::PluginLib> plugin = | 57 scoped_refptr<NPAPI::PluginLib> plugin = |
| 58 NPAPI::PluginLib::CreatePluginLib(filename); | 58 NPAPI::PluginLib::CreatePluginLib(filename); |
| 59 if (plugin.get() == NULL) | 59 if (plugin.get() == NULL) |
| 60 return NULL; | 60 return NULL; |
| 61 | 61 |
| 62 NPError err = plugin->NP_Initialize(); | 62 NPError err = plugin->NP_Initialize(); |
| 63 if (err != NPERR_NO_ERROR) | 63 if (err != NPERR_NO_ERROR) |
| 64 return NULL; | 64 return NULL; |
| 65 | 65 |
| 66 scoped_refptr<NPAPI::PluginInstance> instance = | 66 scoped_refptr<NPAPI::PluginInstance> instance = |
| 67 plugin->CreateInstance(mime_type); | 67 plugin->CreateInstance(mime_type); |
| 68 return new WebPluginDelegateImpl(containing_window, instance.get()); | 68 return new WebPluginDelegateImpl(containing_view, instance.get()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) { | 71 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) { |
| 72 // We use a buffer that is one char longer than we need to detect cases where | 72 // We use a buffer that is one char longer than we need to detect cases where |
| 73 // kNativeWindowClassName is a prefix of the given window's class name. It | 73 // kNativeWindowClassName is a prefix of the given window's class name. It |
| 74 // happens that GetClassNameW will just silently truncate the class name to | 74 // happens that GetClassNameW will just silently truncate the class name to |
| 75 // fit into the given buffer. | 75 // fit into the given buffer. |
| 76 wchar_t class_name[arraysize(kNativeWindowClassName) + 1]; | 76 wchar_t class_name[arraysize(kNativeWindowClassName) + 1]; |
| 77 if (!GetClassNameW(window, class_name, arraysize(class_name))) | 77 if (!GetClassNameW(window, class_name, arraysize(class_name))) |
| 78 return false; | 78 return false; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook( | 114 LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook( |
| 115 int code, WPARAM wParam, LPARAM lParam) { | 115 int code, WPARAM wParam, LPARAM lParam) { |
| 116 | 116 |
| 117 DCHECK(current_plugin_instance_); | 117 DCHECK(current_plugin_instance_); |
| 118 current_plugin_instance_->OnModalLoopEntered(); | 118 current_plugin_instance_->OnModalLoopEntered(); |
| 119 return CallNextHookEx(NULL, code, wParam, lParam); | 119 return CallNextHookEx(NULL, code, wParam, lParam); |
| 120 } | 120 } |
| 121 | 121 |
| 122 WebPluginDelegateImpl::WebPluginDelegateImpl( | 122 WebPluginDelegateImpl::WebPluginDelegateImpl( |
| 123 HWND containing_window, | 123 gfx::NativeView containing_view, |
| 124 NPAPI::PluginInstance *instance) | 124 NPAPI::PluginInstance *instance) |
| 125 : parent_(containing_window), | 125 : parent_(containing_view), |
| 126 instance_(instance), | 126 instance_(instance), |
| 127 quirks_(0), | 127 quirks_(0), |
| 128 plugin_(NULL), | 128 plugin_(NULL), |
| 129 windowless_(false), | 129 windowless_(false), |
| 130 windowed_handle_(NULL), | 130 windowed_handle_(NULL), |
| 131 windowed_did_set_window_(false), | 131 windowed_did_set_window_(false), |
| 132 windowless_needs_set_window_(true), | 132 windowless_needs_set_window_(true), |
| 133 plugin_wnd_proc_(NULL), | 133 plugin_wnd_proc_(NULL), |
| 134 last_message_(0), | 134 last_message_(0), |
| 135 is_calling_wndproc(false), | 135 is_calling_wndproc(false), |
| (...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 unsigned long window_thread_id = | 1117 unsigned long window_thread_id = |
| 1118 GetWindowThreadProcessId(window, &window_process_id); | 1118 GetWindowThreadProcessId(window, &window_process_id); |
| 1119 // TrackPopupMenu fails if the window passed in belongs to a different | 1119 // TrackPopupMenu fails if the window passed in belongs to a different |
| 1120 // thread. | 1120 // thread. |
| 1121 if (::GetCurrentThreadId() != window_thread_id) { | 1121 if (::GetCurrentThreadId() != window_thread_id) { |
| 1122 window = current_plugin_instance_->dummy_window_for_activation_; | 1122 window = current_plugin_instance_->dummy_window_for_activation_; |
| 1123 } | 1123 } |
| 1124 } | 1124 } |
| 1125 return TrackPopupMenu(menu, flags, x, y, reserved, window, rect); | 1125 return TrackPopupMenu(menu, flags, x, y, reserved, window, rect); |
| 1126 } | 1126 } |
| OLD | NEW |