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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // window correctly in the given parent window (RenderWidgetHostViewWin or | 492 // window correctly in the given parent window (RenderWidgetHostViewWin or |
493 // RenderWidgetHostViewAura), this window should be a child window of the | 493 // RenderWidgetHostViewAura), this window should be a child window of the |
494 // parent window. To satisfy both of the above conditions, this code once | 494 // parent window. To satisfy both of the above conditions, this code once |
495 // creates a top-level window and change it to a child window of the parent | 495 // creates a top-level window and change it to a child window of the parent |
496 // window (in the browser process). | 496 // window (in the browser process). |
497 SetWindowLongPtr(windowed_handle_, GWL_STYLE, | 497 SetWindowLongPtr(windowed_handle_, GWL_STYLE, |
498 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); | 498 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); |
499 | 499 |
500 BOOL result = SetProp(windowed_handle_, kWebPluginDelegateProperty, this); | 500 BOOL result = SetProp(windowed_handle_, kWebPluginDelegateProperty, this); |
501 DCHECK(result == TRUE) << "SetProp failed, last error = " << GetLastError(); | 501 DCHECK(result == TRUE) << "SetProp failed, last error = " << GetLastError(); |
502 // Get the name and version of the plugin, create atoms and set them in a | |
503 // window property. Use atoms so that other processes can access the name and | |
504 // version of the plugin that this window is hosting. | |
505 if (instance_ != NULL) { | |
506 PluginLib* plugin_lib = instance()->plugin_lib(); | |
507 if (plugin_lib != NULL) { | |
508 std::wstring plugin_name = plugin_lib->plugin_info().name; | |
509 if (!plugin_name.empty()) { | |
510 ATOM plugin_name_atom = GlobalAddAtomW(plugin_name.c_str()); | |
511 DCHECK_NE(0, plugin_name_atom) << " last error = " << | |
512 GetLastError(); | |
513 result = SetProp(windowed_handle_, | |
514 kPluginNameAtomProperty, | |
515 reinterpret_cast<HANDLE>(plugin_name_atom)); | |
516 DCHECK(result == TRUE) << "SetProp failed, last error = " << | |
517 GetLastError(); | |
518 } | |
519 base::string16 plugin_version = plugin_lib->plugin_info().version; | |
520 if (!plugin_version.empty()) { | |
521 ATOM plugin_version_atom = GlobalAddAtomW(plugin_version.c_str()); | |
522 DCHECK_NE(0, plugin_version_atom); | |
523 result = SetProp(windowed_handle_, | |
524 kPluginVersionAtomProperty, | |
525 reinterpret_cast<HANDLE>(plugin_version_atom)); | |
526 DCHECK(result == TRUE) << "SetProp failed, last error = " << | |
527 GetLastError(); | |
528 } | |
529 } | |
530 } | |
531 | 502 |
532 // Calling SetWindowLongPtrA here makes the window proc ASCII, which is | 503 // Calling SetWindowLongPtrA here makes the window proc ASCII, which is |
533 // required by at least the Shockwave Director plug-in. | 504 // required by at least the Shockwave Director plug-in. |
534 SetWindowLongPtrA(windowed_handle_, | 505 SetWindowLongPtrA(windowed_handle_, |
535 GWLP_WNDPROC, | 506 GWLP_WNDPROC, |
536 reinterpret_cast<LONG_PTR>(DefWindowProcA)); | 507 reinterpret_cast<LONG_PTR>(DefWindowProcA)); |
537 | 508 |
538 return true; | 509 return true; |
539 } | 510 } |
540 | 511 |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 // above. This will also destroy the plugin window. Before attempting to | 991 // above. This will also destroy the plugin window. Before attempting to |
1021 // access the WebPluginDelegateImpl instance we validate if the window is | 992 // access the WebPluginDelegateImpl instance we validate if the window is |
1022 // still valid. | 993 // still valid. |
1023 if (::IsWindow(hwnd)) | 994 if (::IsWindow(hwnd)) |
1024 delegate->is_calling_wndproc = false; | 995 delegate->is_calling_wndproc = false; |
1025 | 996 |
1026 g_current_plugin_instance = last_plugin_instance; | 997 g_current_plugin_instance = last_plugin_instance; |
1027 | 998 |
1028 if (message == WM_NCDESTROY) { | 999 if (message == WM_NCDESTROY) { |
1029 RemoveProp(hwnd, kWebPluginDelegateProperty); | 1000 RemoveProp(hwnd, kWebPluginDelegateProperty); |
1030 ATOM plugin_name_atom = reinterpret_cast<ATOM>( | |
1031 RemoveProp(hwnd, kPluginNameAtomProperty)); | |
1032 if (plugin_name_atom != 0) | |
1033 GlobalDeleteAtom(plugin_name_atom); | |
1034 ATOM plugin_version_atom = reinterpret_cast<ATOM>( | |
1035 RemoveProp(hwnd, kPluginVersionAtomProperty)); | |
1036 if (plugin_version_atom != 0) | |
1037 GlobalDeleteAtom(plugin_version_atom); | |
1038 ClearThrottleQueueForWindow(hwnd); | 1001 ClearThrottleQueueForWindow(hwnd); |
1039 } | 1002 } |
1040 } | 1003 } |
1041 if (::IsWindow(hwnd)) | 1004 if (::IsWindow(hwnd)) |
1042 delegate->last_message_ = old_message; | 1005 delegate->last_message_ = old_message; |
1043 return result; | 1006 return result; |
1044 } | 1007 } |
1045 | 1008 |
1046 void WebPluginDelegateImpl::WindowlessUpdateGeometry( | 1009 void WebPluginDelegateImpl::WindowlessUpdateGeometry( |
1047 const gfx::Rect& window_rect, | 1010 const gfx::Rect& window_rect, |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1522 case WM_RBUTTONUP: | 1485 case WM_RBUTTONUP: |
1523 ::ReleaseCapture(); | 1486 ::ReleaseCapture(); |
1524 break; | 1487 break; |
1525 | 1488 |
1526 default: | 1489 default: |
1527 break; | 1490 break; |
1528 } | 1491 } |
1529 } | 1492 } |
1530 | 1493 |
1531 } // namespace content | 1494 } // namespace content |
OLD | NEW |