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 <stdint.h> |
| 8 #include <string.h> |
| 9 |
7 #include <map> | 10 #include <map> |
8 #include <set> | 11 #include <set> |
9 #include <string> | 12 #include <string> |
10 #include <vector> | 13 #include <vector> |
11 | 14 |
12 #include "base/bind.h" | 15 #include "base/bind.h" |
13 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
14 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 18 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
17 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 22 #include "base/strings/stringprintf.h" |
19 #include "base/synchronization/lock.h" | 23 #include "base/synchronization/lock.h" |
20 #include "base/version.h" | 24 #include "base/version.h" |
21 #include "base/win/iat_patch_function.h" | 25 #include "base/win/iat_patch_function.h" |
22 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
23 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
24 #include "content/child/npapi/plugin_instance.h" | 28 #include "content/child/npapi/plugin_instance.h" |
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We | 922 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We |
919 // prevent this by throttling the messages. | 923 // prevent this by throttling the messages. |
920 if (message == WM_USER + 1 && | 924 if (message == WM_USER + 1 && |
921 delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) { | 925 delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) { |
922 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, | 926 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, |
923 message, wparam, lparam); | 927 message, wparam, lparam); |
924 return FALSE; | 928 return FALSE; |
925 } | 929 } |
926 | 930 |
927 LRESULT result; | 931 LRESULT result; |
928 uint32 old_message = delegate->last_message_; | 932 uint32_t old_message = delegate->last_message_; |
929 delegate->last_message_ = message; | 933 delegate->last_message_ = message; |
930 | 934 |
931 static UINT custom_msg = RegisterWindowMessage(kPaintMessageName); | 935 static UINT custom_msg = RegisterWindowMessage(kPaintMessageName); |
932 if (message == custom_msg) { | 936 if (message == custom_msg) { |
933 // Get the invalid rect which is in screen coordinates and convert to | 937 // Get the invalid rect which is in screen coordinates and convert to |
934 // window coordinates. | 938 // window coordinates. |
935 gfx::Rect invalid_rect; | 939 gfx::Rect invalid_rect; |
936 invalid_rect.set_x(static_cast<short>(LOWORD(wparam))); | 940 invalid_rect.set_x(static_cast<short>(LOWORD(wparam))); |
937 invalid_rect.set_y(static_cast<short>(HIWORD(wparam))); | 941 invalid_rect.set_y(static_cast<short>(HIWORD(wparam))); |
938 invalid_rect.set_width(static_cast<short>(LOWORD(lparam))); | 942 invalid_rect.set_width(static_cast<short>(LOWORD(lparam))); |
939 invalid_rect.set_height(static_cast<short>(HIWORD(lparam))); | 943 invalid_rect.set_height(static_cast<short>(HIWORD(lparam))); |
940 | 944 |
941 RECT window_rect; | 945 RECT window_rect; |
942 GetWindowRect(hwnd, &window_rect); | 946 GetWindowRect(hwnd, &window_rect); |
943 invalid_rect.Offset(-window_rect.left, -window_rect.top); | 947 invalid_rect.Offset(-window_rect.left, -window_rect.top); |
944 | 948 |
945 // The plugin window might have non-client area. If we don't pass in | 949 // The plugin window might have non-client area. If we don't pass in |
946 // RDW_FRAME then the children don't receive WM_NCPAINT messages while | 950 // RDW_FRAME then the children don't receive WM_NCPAINT messages while |
947 // scrolling, which causes painting problems (http://b/issue?id=923945). | 951 // scrolling, which causes painting problems (http://b/issue?id=923945). |
948 uint32 flags = RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME; | 952 uint32_t flags = RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME; |
949 | 953 |
950 // If a plugin (like Google Earth or Java) has child windows that are hosted | 954 // If a plugin (like Google Earth or Java) has child windows that are hosted |
951 // in a different process, then RedrawWindow with UPDATENOW will | 955 // in a different process, then RedrawWindow with UPDATENOW will |
952 // synchronously wait for this call to complete. Some messages are pumped | 956 // synchronously wait for this call to complete. Some messages are pumped |
953 // but not others, which could lead to a deadlock. So avoid reentrancy by | 957 // but not others, which could lead to a deadlock. So avoid reentrancy by |
954 // only synchronously calling RedrawWindow once at a time. | 958 // only synchronously calling RedrawWindow once at a time. |
955 if (old_message != custom_msg) | 959 if (old_message != custom_msg) |
956 flags |= RDW_UPDATENOW; | 960 flags |= RDW_UPDATENOW; |
957 RECT rect = invalid_rect.ToRECT(); | 961 RECT rect = invalid_rect.ToRECT(); |
958 RedrawWindow(hwnd, &rect, NULL, flags); | 962 RedrawWindow(hwnd, &rect, NULL, flags); |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 focus_event.wParam = 0; | 1090 focus_event.wParam = 0; |
1087 focus_event.lParam = 0; | 1091 focus_event.lParam = 0; |
1088 | 1092 |
1089 instance()->NPP_HandleEvent(&focus_event); | 1093 instance()->NPP_HandleEvent(&focus_event); |
1090 return true; | 1094 return true; |
1091 } | 1095 } |
1092 | 1096 |
1093 static bool NPEventFromWebMouseEvent(const WebMouseEvent& event, | 1097 static bool NPEventFromWebMouseEvent(const WebMouseEvent& event, |
1094 NPEvent* np_event) { | 1098 NPEvent* np_event) { |
1095 np_event->lParam = | 1099 np_event->lParam = |
1096 static_cast<uint32>(MAKELPARAM(event.windowX, event.windowY)); | 1100 static_cast<uint32_t>(MAKELPARAM(event.windowX, event.windowY)); |
1097 np_event->wParam = 0; | 1101 np_event->wParam = 0; |
1098 | 1102 |
1099 if (event.modifiers & WebInputEvent::ControlKey) | 1103 if (event.modifiers & WebInputEvent::ControlKey) |
1100 np_event->wParam |= MK_CONTROL; | 1104 np_event->wParam |= MK_CONTROL; |
1101 if (event.modifiers & WebInputEvent::ShiftKey) | 1105 if (event.modifiers & WebInputEvent::ShiftKey) |
1102 np_event->wParam |= MK_SHIFT; | 1106 np_event->wParam |= MK_SHIFT; |
1103 if (event.modifiers & WebInputEvent::LeftButtonDown) | 1107 if (event.modifiers & WebInputEvent::LeftButtonDown) |
1104 np_event->wParam |= MK_LBUTTON; | 1108 np_event->wParam |= MK_LBUTTON; |
1105 if (event.modifiers & WebInputEvent::MiddleButtonDown) | 1109 if (event.modifiers & WebInputEvent::MiddleButtonDown) |
1106 np_event->wParam |= MK_MBUTTON; | 1110 np_event->wParam |= MK_MBUTTON; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 case WM_RBUTTONUP: | 1487 case WM_RBUTTONUP: |
1484 ::ReleaseCapture(); | 1488 ::ReleaseCapture(); |
1485 break; | 1489 break; |
1486 | 1490 |
1487 default: | 1491 default: |
1488 break; | 1492 break; |
1489 } | 1493 } |
1490 } | 1494 } |
1491 | 1495 |
1492 } // namespace content | 1496 } // namespace content |
OLD | NEW |