Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: content/child/npapi/webplugin_delegate_impl.h

Issue 1813143002: Remove a bunch of NPAPI quirks and related support code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_windowed_plugins
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/child/npapi/webplugin.h ('k') | content/child/npapi/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ 5 #ifndef CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
6 #define CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ 6 #define CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 28 matching lines...) Expand all
39 39
40 namespace content { 40 namespace content {
41 class PluginInstance; 41 class PluginInstance;
42 class WebPlugin; 42 class WebPlugin;
43 43
44 #if defined(OS_MACOSX) 44 #if defined(OS_MACOSX)
45 class WebPluginAcceleratedSurface; 45 class WebPluginAcceleratedSurface;
46 class ExternalDragTracker; 46 class ExternalDragTracker;
47 #endif // OS_MACOSX 47 #endif // OS_MACOSX
48 48
49 #if defined(OS_WIN)
50 class WebPluginIMEWin;
51 #endif // OS_WIN
52
53 // An implementation of WebPluginDelegate that runs in the plugin process, 49 // An implementation of WebPluginDelegate that runs in the plugin process,
54 // proxied from the renderer by WebPluginDelegateProxy. 50 // proxied from the renderer by WebPluginDelegateProxy.
55 class WebPluginDelegateImpl : public WebPluginDelegate { 51 class WebPluginDelegateImpl : public WebPluginDelegate {
56 public: 52 public:
57 enum PluginQuirks { 53 enum PluginQuirks {
58 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32 54 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32
59 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32 55 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32
60 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32 56 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32
61 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32 57 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32
62 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32 58 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 100
105 // Returns the path for the library implementing this plugin. 101 // Returns the path for the library implementing this plugin.
106 base::FilePath GetPluginPath(); 102 base::FilePath GetPluginPath();
107 103
108 // Returns a combination of PluginQuirks. 104 // Returns a combination of PluginQuirks.
109 int GetQuirks() const { return quirks_; } 105 int GetQuirks() const { return quirks_; }
110 106
111 // Informs the plugin that the view it is in has gained or lost focus. 107 // Informs the plugin that the view it is in has gained or lost focus.
112 void SetContentAreaHasFocus(bool has_focus); 108 void SetContentAreaHasFocus(bool has_focus);
113 109
114 #if defined(OS_WIN)
115 // Informs the plugin that an IME has changed its status.
116 void ImeCompositionUpdated(const base::string16& text,
117 const std::vector<int>& clauses,
118 const std::vector<int>& target,
119 int cursor_position);
120
121 // Informs the plugin that IME composition has completed./ If |text| is empty,
122 // IME was cancelled.
123 void ImeCompositionCompleted(const base::string16& text);
124
125 // Returns the IME status retrieved from a plugin.
126 bool GetIMEStatus(int* input_type, gfx::Rect* caret_rect);
127 #endif
128
129 #if defined(OS_MACOSX) && !defined(USE_AURA) 110 #if defined(OS_MACOSX) && !defined(USE_AURA)
130 // Informs the plugin that the geometry has changed, as with UpdateGeometry, 111 // Informs the plugin that the geometry has changed, as with UpdateGeometry,
131 // but also includes the new buffer context for that new geometry. 112 // but also includes the new buffer context for that new geometry.
132 void UpdateGeometryAndContext(const gfx::Rect& window_rect, 113 void UpdateGeometryAndContext(const gfx::Rect& window_rect,
133 const gfx::Rect& clip_rect, 114 const gfx::Rect& clip_rect,
134 gfx::NativeDrawingContext context); 115 gfx::NativeDrawingContext context);
135 // Informs the delegate that the plugin called NPN_Invalidate*. Used as a 116 // Informs the delegate that the plugin called NPN_Invalidate*. Used as a
136 // trigger for Core Animation drawing. 117 // trigger for Core Animation drawing.
137 void PluginDidInvalidate(); 118 void PluginDidInvalidate();
138 // Returns the delegate currently processing events. 119 // Returns the delegate currently processing events.
(...skipping 29 matching lines...) Expand all
168 WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance); 149 WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance);
169 ~WebPluginDelegateImpl() override; 150 ~WebPluginDelegateImpl() override;
170 151
171 // Called by Initialize() for platform-specific initialization. 152 // Called by Initialize() for platform-specific initialization.
172 // If this returns false, the plugin shouldn't be started--see Initialize(). 153 // If this returns false, the plugin shouldn't be started--see Initialize().
173 bool PlatformInitialize(); 154 bool PlatformInitialize();
174 155
175 // Called by DestroyInstance(), used for platform-specific destruction. 156 // Called by DestroyInstance(), used for platform-specific destruction.
176 void PlatformDestroyInstance(); 157 void PlatformDestroyInstance();
177 158
178 #if defined(OS_WIN)
179 // Our WndProc functions.
180 static LRESULT CALLBACK FlashWindowlessWndProc(
181 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
182 static LRESULT CALLBACK DummyWindowProc(
183 HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
184
185 // Used for throttling Flash messages.
186 static void ClearThrottleQueueForWindow(HWND window);
187 static void OnThrottleMessage();
188 static void ThrottleMessage(WNDPROC proc, HWND hwnd, UINT message,
189 WPARAM wParam, LPARAM lParam);
190 #endif
191
192 //---------------------------- 159 //----------------------------
193 // used for windowless plugins 160 // used for windowless plugins
194 void WindowlessUpdateGeometry(const gfx::Rect& window_rect, 161 void WindowlessUpdateGeometry(const gfx::Rect& window_rect,
195 const gfx::Rect& clip_rect); 162 const gfx::Rect& clip_rect);
196 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect); 163 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect);
197 164
198 // Tells the plugin about the current state of the window. 165 // Tells the plugin about the current state of the window.
199 // See NPAPI NPP_SetWindow for more information. 166 // See NPAPI NPP_SetWindow for more information.
200 void WindowlessSetWindow(); 167 void WindowlessSetWindow();
201 168
(...skipping 18 matching lines...) Expand all
220 187
221 188
222 // Note: on Mac OS X, the only time the windowed handle is non-zero 189 // Note: on Mac OS X, the only time the windowed handle is non-zero
223 // is the case of accelerated rendering, which uses a fake window handle to 190 // is the case of accelerated rendering, which uses a fake window handle to
224 // identify itself back to the browser. It still performs all of its 191 // identify itself back to the browser. It still performs all of its
225 // work offscreen. 192 // work offscreen.
226 193
227 WebPlugin* plugin_; 194 WebPlugin* plugin_;
228 scoped_refptr<PluginInstance> instance_; 195 scoped_refptr<PluginInstance> instance_;
229 196
230 #if defined(OS_WIN)
231 // An IME emulator used by a windowless plugin to retrieve IME data through
232 // IMM32 functions.
233 scoped_ptr<WebPluginIMEWin> plugin_ime_;
234 #endif // defined(OS_WIN)
235
236 NPWindow window_; 197 NPWindow window_;
237 gfx::Rect window_rect_; 198 gfx::Rect window_rect_;
238 gfx::Rect clip_rect_; 199 gfx::Rect clip_rect_;
239 int quirks_; 200 int quirks_;
240 201
241 #if defined(OS_WIN) 202 #if defined(OS_MACOSX) && !defined(USE_AURA)
242 // Windowless plugins don't have keyboard focus causing issues with the
243 // plugin not receiving keyboard events if the plugin enters a modal
244 // loop like TrackPopupMenuEx or MessageBox, etc.
245 // This is a basic issue with windows activation and focus arising due to
246 // the fact that these windows are created by different threads. Activation
247 // and focus are thread specific states, and if the browser has focus,
248 // the plugin may not have focus.
249 // To fix a majority of these activation issues we create a dummy visible
250 // child window to which we set focus whenever the windowless plugin
251 // receives a WM_LBUTTONDOWN/WM_RBUTTONDOWN message via NPP_HandleEvent.
252
253 HWND dummy_window_for_activation_;
254 HWND dummy_window_parent_;
255 WNDPROC old_dummy_window_proc_;
256 bool CreateDummyWindowForActivation();
257
258 // Returns true if the event passed in needs to be tracked for a potential
259 // modal loop.
260 static bool ShouldTrackEventForModalLoops(NPEvent* event);
261
262 // The message filter hook procedure, which tracks modal loops entered by
263 // a plugin in the course of a NPP_HandleEvent call.
264 static LRESULT CALLBACK HandleEventMessageFilterHook(int code, WPARAM wParam,
265 LPARAM lParam);
266
267 // TrackPopupMenu interceptor. Parameters are the same as the Win32 function
268 // TrackPopupMenu.
269 static BOOL WINAPI TrackPopupMenuPatch(HMENU menu, unsigned int flags, int x,
270 int y, int reserved, HWND window,
271 const RECT* rect);
272
273 // SetCursor interceptor for windowless plugins.
274 static HCURSOR WINAPI SetCursorPatch(HCURSOR cursor);
275
276 // RegEnumKeyExW interceptor.
277 static LONG WINAPI RegEnumKeyExWPatch(
278 HKEY key, DWORD index, LPWSTR name, LPDWORD name_size, LPDWORD reserved,
279 LPWSTR class_name, LPDWORD class_size, PFILETIME last_write_time);
280
281 // GetProcAddress intercepter for windowless plugins.
282 static FARPROC WINAPI GetProcAddressPatch(HMODULE module, LPCSTR name);
283
284 // WindowFromPoint patch for Flash windowless plugins. When flash receives
285 // mouse move messages it calls the WindowFromPoint API to eventually convert
286 // the mouse coordinates to screen. We need to return the dummy plugin parent
287 // window for Aura to ensure that these conversions occur correctly.
288 static HWND WINAPI WindowFromPointPatch(POINT point);
289
290 #elif defined(OS_MACOSX) && !defined(USE_AURA)
291 // Sets window_rect_ to |rect| 203 // Sets window_rect_ to |rect|
292 void SetPluginRect(const gfx::Rect& rect); 204 void SetPluginRect(const gfx::Rect& rect);
293 // Sets content_area_origin to |origin| 205 // Sets content_area_origin to |origin|
294 void SetContentAreaOrigin(const gfx::Point& origin); 206 void SetContentAreaOrigin(const gfx::Point& origin);
295 // Updates everything that depends on the plugin's absolute screen location. 207 // Updates everything that depends on the plugin's absolute screen location.
296 void PluginScreenLocationChanged(); 208 void PluginScreenLocationChanged();
297 // Updates anything that depends on plugin visibility. 209 // Updates anything that depends on plugin visibility.
298 void PluginVisibilityChanged(); 210 void PluginVisibilityChanged();
299 211
300 // Starts an IME session. 212 // Starts an IME session.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 245
334 // Called by the message filter hook when the plugin enters a modal loop. 246 // Called by the message filter hook when the plugin enters a modal loop.
335 void OnModalLoopEntered(); 247 void OnModalLoopEntered();
336 248
337 // Returns true if the message passed in corresponds to a user gesture. 249 // Returns true if the message passed in corresponds to a user gesture.
338 static bool IsUserGesture(const blink::WebInputEvent& event); 250 static bool IsUserGesture(const blink::WebInputEvent& event);
339 251
340 // The url with which the plugin was instantiated. 252 // The url with which the plugin was instantiated.
341 std::string plugin_url_; 253 std::string plugin_url_;
342 254
343 #if defined(OS_WIN)
344 // Handle to the message filter hook
345 HHOOK handle_event_message_filter_hook_;
346
347 // Event which is set when the plugin enters a modal loop in the course
348 // of a NPP_HandleEvent call.
349 HANDLE handle_event_pump_messages_event_;
350 #endif
351
352 // Holds the depth of the HandleEvent callstack. 255 // Holds the depth of the HandleEvent callstack.
353 int handle_event_depth_; 256 int handle_event_depth_;
354 257
355 // Holds the current cursor set by the windowless plugin. 258 // Holds the current cursor set by the windowless plugin.
356 WebCursor current_windowless_cursor_; 259 WebCursor current_windowless_cursor_;
357 260
358 // Set to true initially and indicates if this is the first npp_setwindow 261 // Set to true initially and indicates if this is the first npp_setwindow
359 // call received by the plugin. 262 // call received by the plugin.
360 bool first_set_window_call_; 263 bool first_set_window_call_;
361 264
(...skipping 16 matching lines...) Expand all
378 // asynchronously. 281 // asynchronously.
379 base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; 282 base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_;
380 #endif 283 #endif
381 284
382 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl); 285 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
383 }; 286 };
384 287
385 } // namespace content 288 } // namespace content
386 289
387 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ 290 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/npapi/webplugin.h ('k') | content/child/npapi/webplugin_delegate_impl_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698