OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/plugins/npapi/webplugin_delegate_impl.h" | 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "app/win/iat_patch_function.h" | 11 #include "app/win/iat_patch_function.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/metrics/stats_counters.h" | 15 #include "base/metrics/stats_counters.h" |
16 #include "base/scoped_ptr.h" | 16 #include "base/scoped_ptr.h" |
17 #include "base/string_number_conversions.h" | 17 #include "base/string_number_conversions.h" |
18 #include "base/string_split.h" | 18 #include "base/string_split.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
21 #include "base/win/registry.h" | 21 #include "base/win/registry.h" |
22 #include "base/win/windows_version.h" | 22 #include "base/win/windows_version.h" |
23 #include "skia/ext/platform_canvas.h" | 23 #include "skia/ext/platform_canvas.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
| 25 #include "webkit/glue/plugins/default_plugin_shared.h" |
| 26 #include "webkit/glue/plugins/plugin_constants_win.h" |
| 27 #include "webkit/glue/plugins/plugin_instance.h" |
| 28 #include "webkit/glue/plugins/plugin_lib.h" |
| 29 #include "webkit/glue/plugins/plugin_list.h" |
| 30 #include "webkit/glue/plugins/plugin_stream_url.h" |
| 31 #include "webkit/glue/plugins/webplugin.h" |
25 #include "webkit/glue/webkit_glue.h" | 32 #include "webkit/glue/webkit_glue.h" |
26 #include "webkit/plugins/npapi/default_plugin_shared.h" | |
27 #include "webkit/plugins/npapi/plugin_constants_win.h" | |
28 #include "webkit/plugins/npapi/plugin_instance.h" | |
29 #include "webkit/plugins/npapi/plugin_lib.h" | |
30 #include "webkit/plugins/npapi/plugin_list.h" | |
31 #include "webkit/plugins/npapi/plugin_stream_url.h" | |
32 #include "webkit/plugins/npapi/webplugin.h" | |
33 | 33 |
34 using WebKit::WebCursorInfo; | 34 using WebKit::WebCursorInfo; |
35 using WebKit::WebKeyboardEvent; | 35 using WebKit::WebKeyboardEvent; |
36 using WebKit::WebInputEvent; | 36 using WebKit::WebInputEvent; |
37 using WebKit::WebMouseEvent; | 37 using WebKit::WebMouseEvent; |
38 | 38 |
39 namespace webkit { | |
40 namespace npapi { | |
41 | |
42 namespace { | 39 namespace { |
43 | 40 |
44 const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty"; | 41 const wchar_t kWebPluginDelegateProperty[] = L"WebPluginDelegateProperty"; |
45 const wchar_t kPluginNameAtomProperty[] = L"PluginNameAtom"; | 42 const wchar_t kPluginNameAtomProperty[] = L"PluginNameAtom"; |
46 const wchar_t kDummyActivationWindowName[] = L"DummyWindowForActivation"; | 43 const wchar_t kDummyActivationWindowName[] = L"DummyWindowForActivation"; |
47 const wchar_t kPluginFlashThrottle[] = L"FlashThrottle"; | 44 const wchar_t kPluginFlashThrottle[] = L"FlashThrottle"; |
48 | 45 |
49 // The fastest we are willing to process WM_USER+1 events for Flash. | 46 // The fastest we are willing to process WM_USER+1 events for Flash. |
50 // Flash can easily exceed the limits of our CPU if we don't throttle it. | 47 // Flash can easily exceed the limits of our CPU if we don't throttle it. |
51 // The throttle has been chosen by testing various delays and compromising | 48 // The throttle has been chosen by testing various delays and compromising |
(...skipping 125 matching lines...) Loading... |
177 return L""; | 174 return L""; |
178 | 175 |
179 KEY_NAME_INFORMATION* info = | 176 KEY_NAME_INFORMATION* info = |
180 reinterpret_cast<KEY_NAME_INFORMATION*>(buffer.get()); | 177 reinterpret_cast<KEY_NAME_INFORMATION*>(buffer.get()); |
181 return std::wstring(info->Name, info->NameLength / sizeof(wchar_t)); | 178 return std::wstring(info->Name, info->NameLength / sizeof(wchar_t)); |
182 } | 179 } |
183 | 180 |
184 } // namespace | 181 } // namespace |
185 | 182 |
186 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) { | 183 bool WebPluginDelegateImpl::IsPluginDelegateWindow(HWND window) { |
187 static const int kBufLen = 64; | 184 // We use a buffer that is one char longer than we need to detect cases where |
188 wchar_t class_name[kBufLen]; | 185 // kNativeWindowClassName is a prefix of the given window's class name. It |
189 if (!GetClassNameW(window, class_name, kBufLen)) | 186 // happens that GetClassNameW will just silently truncate the class name to |
| 187 // fit into the given buffer. |
| 188 wchar_t class_name[arraysize(kNativeWindowClassName) + 1]; |
| 189 if (!GetClassNameW(window, class_name, arraysize(class_name))) |
190 return false; | 190 return false; |
191 return wcscmp(class_name, kNativeWindowClassName) == 0; | 191 return wcscmp(class_name, kNativeWindowClassName) == 0; |
192 } | 192 } |
193 | 193 |
194 bool WebPluginDelegateImpl::GetPluginNameFromWindow( | 194 bool WebPluginDelegateImpl::GetPluginNameFromWindow( |
195 HWND window, std::wstring *plugin_name) { | 195 HWND window, std::wstring *plugin_name) { |
196 if (NULL == plugin_name) { | 196 if (NULL == plugin_name) { |
197 return false; | 197 return false; |
198 } | 198 } |
199 if (!IsPluginDelegateWindow(window)) { | 199 if (!IsPluginDelegateWindow(window)) { |
(...skipping 39 matching lines...) Loading... |
239 MOUSEHOOKSTRUCT* hook_struct = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam); | 239 MOUSEHOOKSTRUCT* hook_struct = reinterpret_cast<MOUSEHOOKSTRUCT*>(lParam); |
240 if (hook_struct) | 240 if (hook_struct) |
241 HandleCaptureForMessage(hook_struct->hwnd, wParam); | 241 HandleCaptureForMessage(hook_struct->hwnd, wParam); |
242 } | 242 } |
243 | 243 |
244 return CallNextHookEx(NULL, code, wParam, lParam); | 244 return CallNextHookEx(NULL, code, wParam, lParam); |
245 } | 245 } |
246 | 246 |
247 WebPluginDelegateImpl::WebPluginDelegateImpl( | 247 WebPluginDelegateImpl::WebPluginDelegateImpl( |
248 gfx::PluginWindowHandle containing_view, | 248 gfx::PluginWindowHandle containing_view, |
249 PluginInstance *instance) | 249 NPAPI::PluginInstance *instance) |
250 : parent_(containing_view), | 250 : parent_(containing_view), |
251 instance_(instance), | 251 instance_(instance), |
252 quirks_(0), | 252 quirks_(0), |
253 plugin_(NULL), | 253 plugin_(NULL), |
254 windowless_(false), | 254 windowless_(false), |
255 windowed_handle_(NULL), | 255 windowed_handle_(NULL), |
256 windowed_did_set_window_(false), | 256 windowed_did_set_window_(false), |
257 plugin_wnd_proc_(NULL), | 257 plugin_wnd_proc_(NULL), |
258 last_message_(0), | 258 last_message_(0), |
259 is_calling_wndproc(false), | 259 is_calling_wndproc(false), |
(...skipping 260 matching lines...) Loading... |
520 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); | 520 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); |
521 SetParent(windowed_handle_, parent_); | 521 SetParent(windowed_handle_, parent_); |
522 } | 522 } |
523 | 523 |
524 BOOL result = SetProp(windowed_handle_, kWebPluginDelegateProperty, this); | 524 BOOL result = SetProp(windowed_handle_, kWebPluginDelegateProperty, this); |
525 DCHECK(result == TRUE) << "SetProp failed, last error = " << GetLastError(); | 525 DCHECK(result == TRUE) << "SetProp failed, last error = " << GetLastError(); |
526 // Get the name of the plugin, create an atom and set that in a window | 526 // Get the name of the plugin, create an atom and set that in a window |
527 // property. Use an atom so that other processes can access the name of | 527 // property. Use an atom so that other processes can access the name of |
528 // the plugin that this window is hosting | 528 // the plugin that this window is hosting |
529 if (instance_ != NULL) { | 529 if (instance_ != NULL) { |
530 PluginLib* plugin_lib = instance()->plugin_lib(); | 530 NPAPI::PluginLib* plugin_lib = instance()->plugin_lib(); |
531 if (plugin_lib != NULL) { | 531 if (plugin_lib != NULL) { |
532 std::wstring plugin_name = plugin_lib->plugin_info().name; | 532 std::wstring plugin_name = plugin_lib->plugin_info().name; |
533 if (!plugin_name.empty()) { | 533 if (!plugin_name.empty()) { |
534 ATOM plugin_name_atom = GlobalAddAtomW(plugin_name.c_str()); | 534 ATOM plugin_name_atom = GlobalAddAtomW(plugin_name.c_str()); |
535 DCHECK(0 != plugin_name_atom); | 535 DCHECK(0 != plugin_name_atom); |
536 result = SetProp(windowed_handle_, | 536 result = SetProp(windowed_handle_, |
537 kPluginNameAtomProperty, | 537 kPluginNameAtomProperty, |
538 reinterpret_cast<HANDLE>(plugin_name_atom)); | 538 reinterpret_cast<HANDLE>(plugin_name_atom)); |
539 DCHECK(result == TRUE) << "SetProp failed, last error = " << | 539 DCHECK(result == TRUE) << "SetProp failed, last error = " << |
540 GetLastError(); | 540 GetLastError(); |
(...skipping 860 matching lines...) Loading... |
1401 case WM_LBUTTONUP: | 1401 case WM_LBUTTONUP: |
1402 case WM_MBUTTONUP: | 1402 case WM_MBUTTONUP: |
1403 case WM_RBUTTONUP: | 1403 case WM_RBUTTONUP: |
1404 ::ReleaseCapture(); | 1404 ::ReleaseCapture(); |
1405 break; | 1405 break; |
1406 | 1406 |
1407 default: | 1407 default: |
1408 break; | 1408 break; |
1409 } | 1409 } |
1410 } | 1410 } |
1411 | |
1412 } // namespace npapi | |
1413 } // namespace webkit | |
OLD | NEW |