| 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 #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 Loading... |
| 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 |
| 49 // An implementation of WebPluginDelegate that runs in the plugin process, | 53 // An implementation of WebPluginDelegate that runs in the plugin process, |
| 50 // proxied from the renderer by WebPluginDelegateProxy. | 54 // proxied from the renderer by WebPluginDelegateProxy. |
| 51 class WebPluginDelegateImpl : public WebPluginDelegate { | 55 class WebPluginDelegateImpl : public WebPluginDelegate { |
| 52 public: | 56 public: |
| 53 enum PluginQuirks { | 57 enum PluginQuirks { |
| 54 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32 | 58 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32 |
| 55 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32 | 59 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32 |
| 56 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32 | 60 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32 |
| 57 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32 | 61 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32 |
| 58 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32 | 62 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 104 |
| 101 // Returns the path for the library implementing this plugin. | 105 // Returns the path for the library implementing this plugin. |
| 102 base::FilePath GetPluginPath(); | 106 base::FilePath GetPluginPath(); |
| 103 | 107 |
| 104 // Returns a combination of PluginQuirks. | 108 // Returns a combination of PluginQuirks. |
| 105 int GetQuirks() const { return quirks_; } | 109 int GetQuirks() const { return quirks_; } |
| 106 | 110 |
| 107 // Informs the plugin that the view it is in has gained or lost focus. | 111 // Informs the plugin that the view it is in has gained or lost focus. |
| 108 void SetContentAreaHasFocus(bool has_focus); | 112 void SetContentAreaHasFocus(bool has_focus); |
| 109 | 113 |
| 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 |
| 110 #if defined(OS_MACOSX) && !defined(USE_AURA) | 129 #if defined(OS_MACOSX) && !defined(USE_AURA) |
| 111 // Informs the plugin that the geometry has changed, as with UpdateGeometry, | 130 // Informs the plugin that the geometry has changed, as with UpdateGeometry, |
| 112 // but also includes the new buffer context for that new geometry. | 131 // but also includes the new buffer context for that new geometry. |
| 113 void UpdateGeometryAndContext(const gfx::Rect& window_rect, | 132 void UpdateGeometryAndContext(const gfx::Rect& window_rect, |
| 114 const gfx::Rect& clip_rect, | 133 const gfx::Rect& clip_rect, |
| 115 gfx::NativeDrawingContext context); | 134 gfx::NativeDrawingContext context); |
| 116 // Informs the delegate that the plugin called NPN_Invalidate*. Used as a | 135 // Informs the delegate that the plugin called NPN_Invalidate*. Used as a |
| 117 // trigger for Core Animation drawing. | 136 // trigger for Core Animation drawing. |
| 118 void PluginDidInvalidate(); | 137 void PluginDidInvalidate(); |
| 119 // Returns the delegate currently processing events. | 138 // Returns the delegate currently processing events. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 149 WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance); | 168 WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance); |
| 150 ~WebPluginDelegateImpl() override; | 169 ~WebPluginDelegateImpl() override; |
| 151 | 170 |
| 152 // Called by Initialize() for platform-specific initialization. | 171 // Called by Initialize() for platform-specific initialization. |
| 153 // If this returns false, the plugin shouldn't be started--see Initialize(). | 172 // If this returns false, the plugin shouldn't be started--see Initialize(). |
| 154 bool PlatformInitialize(); | 173 bool PlatformInitialize(); |
| 155 | 174 |
| 156 // Called by DestroyInstance(), used for platform-specific destruction. | 175 // Called by DestroyInstance(), used for platform-specific destruction. |
| 157 void PlatformDestroyInstance(); | 176 void PlatformDestroyInstance(); |
| 158 | 177 |
| 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 |
| 159 //---------------------------- | 192 //---------------------------- |
| 160 // used for windowless plugins | 193 // used for windowless plugins |
| 161 void WindowlessUpdateGeometry(const gfx::Rect& window_rect, | 194 void WindowlessUpdateGeometry(const gfx::Rect& window_rect, |
| 162 const gfx::Rect& clip_rect); | 195 const gfx::Rect& clip_rect); |
| 163 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect); | 196 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect); |
| 164 | 197 |
| 165 // Tells the plugin about the current state of the window. | 198 // Tells the plugin about the current state of the window. |
| 166 // See NPAPI NPP_SetWindow for more information. | 199 // See NPAPI NPP_SetWindow for more information. |
| 167 void WindowlessSetWindow(); | 200 void WindowlessSetWindow(); |
| 168 | 201 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 187 | 220 |
| 188 | 221 |
| 189 // Note: on Mac OS X, the only time the windowed handle is non-zero | 222 // Note: on Mac OS X, the only time the windowed handle is non-zero |
| 190 // is the case of accelerated rendering, which uses a fake window handle to | 223 // is the case of accelerated rendering, which uses a fake window handle to |
| 191 // identify itself back to the browser. It still performs all of its | 224 // identify itself back to the browser. It still performs all of its |
| 192 // work offscreen. | 225 // work offscreen. |
| 193 | 226 |
| 194 WebPlugin* plugin_; | 227 WebPlugin* plugin_; |
| 195 scoped_refptr<PluginInstance> instance_; | 228 scoped_refptr<PluginInstance> instance_; |
| 196 | 229 |
| 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 |
| 197 NPWindow window_; | 236 NPWindow window_; |
| 198 gfx::Rect window_rect_; | 237 gfx::Rect window_rect_; |
| 199 gfx::Rect clip_rect_; | 238 gfx::Rect clip_rect_; |
| 200 int quirks_; | 239 int quirks_; |
| 201 | 240 |
| 202 #if defined(OS_MACOSX) && !defined(USE_AURA) | 241 #if defined(OS_WIN) |
| 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) |
| 203 // Sets window_rect_ to |rect| | 291 // Sets window_rect_ to |rect| |
| 204 void SetPluginRect(const gfx::Rect& rect); | 292 void SetPluginRect(const gfx::Rect& rect); |
| 205 // Sets content_area_origin to |origin| | 293 // Sets content_area_origin to |origin| |
| 206 void SetContentAreaOrigin(const gfx::Point& origin); | 294 void SetContentAreaOrigin(const gfx::Point& origin); |
| 207 // Updates everything that depends on the plugin's absolute screen location. | 295 // Updates everything that depends on the plugin's absolute screen location. |
| 208 void PluginScreenLocationChanged(); | 296 void PluginScreenLocationChanged(); |
| 209 // Updates anything that depends on plugin visibility. | 297 // Updates anything that depends on plugin visibility. |
| 210 void PluginVisibilityChanged(); | 298 void PluginVisibilityChanged(); |
| 211 | 299 |
| 212 // Starts an IME session. | 300 // Starts an IME session. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 333 |
| 246 // Called by the message filter hook when the plugin enters a modal loop. | 334 // Called by the message filter hook when the plugin enters a modal loop. |
| 247 void OnModalLoopEntered(); | 335 void OnModalLoopEntered(); |
| 248 | 336 |
| 249 // Returns true if the message passed in corresponds to a user gesture. | 337 // Returns true if the message passed in corresponds to a user gesture. |
| 250 static bool IsUserGesture(const blink::WebInputEvent& event); | 338 static bool IsUserGesture(const blink::WebInputEvent& event); |
| 251 | 339 |
| 252 // The url with which the plugin was instantiated. | 340 // The url with which the plugin was instantiated. |
| 253 std::string plugin_url_; | 341 std::string plugin_url_; |
| 254 | 342 |
| 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 |
| 255 // Holds the depth of the HandleEvent callstack. | 352 // Holds the depth of the HandleEvent callstack. |
| 256 int handle_event_depth_; | 353 int handle_event_depth_; |
| 257 | 354 |
| 258 // Holds the current cursor set by the windowless plugin. | 355 // Holds the current cursor set by the windowless plugin. |
| 259 WebCursor current_windowless_cursor_; | 356 WebCursor current_windowless_cursor_; |
| 260 | 357 |
| 261 // Set to true initially and indicates if this is the first npp_setwindow | 358 // Set to true initially and indicates if this is the first npp_setwindow |
| 262 // call received by the plugin. | 359 // call received by the plugin. |
| 263 bool first_set_window_call_; | 360 bool first_set_window_call_; |
| 264 | 361 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 281 // asynchronously. | 378 // asynchronously. |
| 282 base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; | 379 base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_; |
| 283 #endif | 380 #endif |
| 284 | 381 |
| 285 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl); | 382 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl); |
| 286 }; | 383 }; |
| 287 | 384 |
| 288 } // namespace content | 385 } // namespace content |
| 289 | 386 |
| 290 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ | 387 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_ |
| OLD | NEW |