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

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

Issue 1851093005: Remove content/child/npapi (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_combined_01_02
Patch Set: rebase Created 4 years, 8 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
6 #define CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
7
8 #include <stdint.h>
9
10 #include <string>
11 #include <vector>
12
13 #include "base/macros.h"
14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/memory/weak_ptr.h"
17 #include "base/sequenced_task_runner_helpers.h"
18 #include "base/timer/timer.h"
19 #include "build/build_config.h"
20 #include "content/child/npapi/webplugin_delegate.h"
21 #include "content/common/cursors/webcursor.h"
22 #include "third_party/npapi/bindings/npapi.h"
23 #include "ui/gfx/geometry/rect.h"
24 #include "ui/gfx/native_widget_types.h"
25
26 namespace base {
27 class FilePath;
28 }
29
30 #if defined(OS_MACOSX)
31 #ifdef __OBJC__
32 @class CALayer;
33 @class CARenderer;
34 #else
35 class CALayer;
36 class CARenderer;
37 #endif
38 #endif
39
40 namespace content {
41 class PluginInstance;
42 class WebPlugin;
43
44 #if defined(OS_MACOSX)
45 class WebPluginAcceleratedSurface;
46 class ExternalDragTracker;
47 #endif // OS_MACOSX
48
49 // An implementation of WebPluginDelegate that runs in the plugin process,
50 // proxied from the renderer by WebPluginDelegateProxy.
51 class WebPluginDelegateImpl : public WebPluginDelegate {
52 public:
53 enum PluginQuirks {
54 PLUGIN_QUIRK_SETWINDOW_TWICE = 1, // Win32
55 PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE = 2, // Win32
56 PLUGIN_QUIRK_DONT_CALL_WND_PROC_RECURSIVELY = 4, // Win32
57 PLUGIN_QUIRK_DONT_SET_NULL_WINDOW_HANDLE_ON_DESTROY = 8, // Win32
58 PLUGIN_QUIRK_DONT_ALLOW_MULTIPLE_INSTANCES = 16, // Win32
59 PLUGIN_QUIRK_DIE_AFTER_UNLOAD = 32, // Win32
60 PLUGIN_QUIRK_PATCH_SETCURSOR = 64, // Win32
61 PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS = 128, // Win32
62 PLUGIN_QUIRK_WINDOWLESS_OFFSET_WINDOW_TO_DRAW = 256, // Linux
63 PLUGIN_QUIRK_WINDOWLESS_INVALIDATE_AFTER_SET_WINDOW = 512, // Linux
64 PLUGIN_QUIRK_NO_WINDOWLESS = 1024, // Windows
65 PLUGIN_QUIRK_PATCH_REGENUMKEYEXW = 2048, // Windows
66 PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS = 4096, // Windows
67 PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE = 16384, // Windows
68 PLUGIN_QUIRK_WINDOWLESS_NO_RIGHT_CLICK = 32768, // Linux
69 PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL = 65536, // Windows.
70 PLUGIN_QUIRK_EMULATE_IME = 131072, // Windows.
71 PLUGIN_QUIRK_FAKE_WINDOW_FROM_POINT = 262144, // Windows.
72 PLUGIN_QUIRK_COPY_STREAM_DATA = 524288, // All platforms
73 };
74
75 static WebPluginDelegateImpl* Create(WebPlugin* plugin,
76 const base::FilePath& filename,
77 const std::string& mime_type);
78
79 // WebPluginDelegate implementation
80 bool Initialize(const GURL& url,
81 const std::vector<std::string>& arg_names,
82 const std::vector<std::string>& arg_values,
83 bool load_manually) override;
84 void PluginDestroyed() override;
85 void UpdateGeometry(const gfx::Rect& window_rect,
86 const gfx::Rect& clip_rect) override;
87 void Paint(SkCanvas* canvas, const gfx::Rect& rect) override;
88 void SetFocus(bool focused) override;
89 bool HandleInputEvent(const blink::WebInputEvent& event,
90 WebCursor::CursorInfo* cursor_info) override;
91 int GetProcessId() override;
92 // End of WebPluginDelegate implementation.
93
94 PluginInstance* instance() { return instance_.get(); }
95 gfx::Rect GetRect() const { return window_rect_; }
96 gfx::Rect GetClipRect() const { return clip_rect_; }
97
98 // Returns the path for the library implementing this plugin.
99 base::FilePath GetPluginPath();
100
101 // Returns a combination of PluginQuirks.
102 int GetQuirks() const { return quirks_; }
103
104 // Informs the plugin that the view it is in has gained or lost focus.
105 void SetContentAreaHasFocus(bool has_focus);
106
107 #if defined(OS_MACOSX) && !defined(USE_AURA)
108 // Informs the plugin that the geometry has changed, as with UpdateGeometry,
109 // but also includes the new buffer context for that new geometry.
110 void UpdateGeometryAndContext(const gfx::Rect& window_rect,
111 const gfx::Rect& clip_rect,
112 gfx::NativeDrawingContext context);
113 // Informs the delegate that the plugin called NPN_Invalidate*. Used as a
114 // trigger for Core Animation drawing.
115 void PluginDidInvalidate();
116 // Returns the delegate currently processing events.
117 static WebPluginDelegateImpl* GetActiveDelegate();
118 // Informs the plugin that the window it is in has gained or lost focus.
119 void SetWindowHasFocus(bool has_focus);
120 // Informs the plugin that its tab or window has been hidden or shown.
121 void SetContainerVisibility(bool is_visible);
122 // Informs the plugin that its containing window's frame has changed.
123 // Frames are in screen coordinates.
124 void WindowFrameChanged(const gfx::Rect& window_frame,
125 const gfx::Rect& view_frame);
126 // Informs the plugin that IME composition has completed.
127 // If |text| is empty, IME was cancelled.
128 void ImeCompositionCompleted(const base::string16& text);
129 // Informs the delegate that the plugin set a Cocoa NSCursor.
130 void SetNSCursor(NSCursor* cursor);
131
132 // Indicates that the windowless plugins will draw directly to the window
133 // context instead of a buffer context.
134 void SetNoBufferContext();
135
136 // TODO(caryclark): This is a temporary workaround to allow the Darwin / Skia
137 // port to share code with the Darwin / CG port. Later, this will be removed
138 // and all callers will use the Paint defined above.
139 void CGPaint(CGContextRef context, const gfx::Rect& rect);
140 #endif // OS_MACOSX && !USE_AURA
141
142 private:
143 friend class base::DeleteHelper<WebPluginDelegateImpl>;
144 friend class WebPluginDelegate;
145
146 WebPluginDelegateImpl(WebPlugin* plugin, PluginInstance* instance);
147 ~WebPluginDelegateImpl() override;
148
149 // Called by Initialize() for platform-specific initialization.
150 // If this returns false, the plugin shouldn't be started--see Initialize().
151 bool PlatformInitialize();
152
153 // Called by DestroyInstance(), used for platform-specific destruction.
154 void PlatformDestroyInstance();
155
156 //----------------------------
157 // used for windowless plugins
158 void WindowlessUpdateGeometry(const gfx::Rect& window_rect,
159 const gfx::Rect& clip_rect);
160 void WindowlessPaint(gfx::NativeDrawingContext hdc, const gfx::Rect& rect);
161
162 // Tells the plugin about the current state of the window.
163 // See NPAPI NPP_SetWindow for more information.
164 void WindowlessSetWindow();
165
166 // Informs the plugin that it has gained or lost keyboard focus (on the Mac,
167 // this just means window first responder status).
168 void SetPluginHasFocus(bool focused);
169
170 // Handles the platform specific details of setting plugin focus. Returns
171 // false if the platform cancelled the focus tranfer.
172 bool PlatformSetPluginHasFocus(bool focused);
173
174 //-----------------------------------------
175 // used for windowed and windowless plugins
176
177 // Does platform-specific event handling. Arguments and return are identical
178 // to HandleInputEvent.
179 bool PlatformHandleInputEvent(const blink::WebInputEvent& event,
180 WebCursor::CursorInfo* cursor_info);
181
182 // Closes down and destroys our plugin instance.
183 void DestroyInstance();
184
185
186 // Note: on Mac OS X, the only time the windowed handle is non-zero
187 // is the case of accelerated rendering, which uses a fake window handle to
188 // identify itself back to the browser. It still performs all of its
189 // work offscreen.
190
191 WebPlugin* plugin_;
192 scoped_refptr<PluginInstance> instance_;
193
194 NPWindow window_;
195 gfx::Rect window_rect_;
196 gfx::Rect clip_rect_;
197 int quirks_;
198
199 #if defined(OS_MACOSX) && !defined(USE_AURA)
200 // Sets window_rect_ to |rect|
201 void SetPluginRect(const gfx::Rect& rect);
202 // Sets content_area_origin to |origin|
203 void SetContentAreaOrigin(const gfx::Point& origin);
204 // Updates everything that depends on the plugin's absolute screen location.
205 void PluginScreenLocationChanged();
206 // Updates anything that depends on plugin visibility.
207 void PluginVisibilityChanged();
208
209 // Starts an IME session.
210 void StartIme();
211
212 // Informs the browser about the updated accelerated drawing surface.
213 void UpdateAcceleratedSurface();
214
215 // Uses a CARenderer to draw the plugin's layer in our OpenGL surface.
216 void DrawLayerInSurface();
217
218 bool use_buffer_context_;
219 CGContextRef buffer_context_; // Weak ref.
220
221 CALayer* layer_; // Used for CA drawing mode. Weak, retained by plugin.
222 WebPluginAcceleratedSurface* surface_; // Weak ref.
223 CARenderer* renderer_; // Renders layer_ to surface_.
224 scoped_ptr<base::RepeatingTimer> redraw_timer_;
225
226 // The upper-left corner of the web content area in screen coordinates,
227 // relative to an upper-left (0,0).
228 gfx::Point content_area_origin_;
229
230 bool containing_window_has_focus_;
231 bool initial_window_focus_;
232 bool container_is_visible_;
233 bool have_called_set_window_;
234
235 gfx::Rect cached_clip_rect_;
236
237 bool ime_enabled_;
238 int keyup_ignore_count_;
239
240 scoped_ptr<ExternalDragTracker> external_drag_tracker_;
241 #endif // OS_MACOSX && !USE_AURA
242
243 // Called by the message filter hook when the plugin enters a modal loop.
244 void OnModalLoopEntered();
245
246 // Returns true if the message passed in corresponds to a user gesture.
247 static bool IsUserGesture(const blink::WebInputEvent& event);
248
249 // The url with which the plugin was instantiated.
250 std::string plugin_url_;
251
252 // Holds the depth of the HandleEvent callstack.
253 int handle_event_depth_;
254
255 // Holds the current cursor set by the windowless plugin.
256 WebCursor current_windowless_cursor_;
257
258 // Set to true initially and indicates if this is the first npp_setwindow
259 // call received by the plugin.
260 bool first_set_window_call_;
261
262 // True if the plugin thinks it has keyboard focus
263 bool plugin_has_focus_;
264 // True if the plugin element has focus within the web content, regardless of
265 // whether its containing view currently has focus.
266 bool has_webkit_focus_;
267 // True if the containing view currently has focus.
268 // Initially set to true so that plugin focus still works in environments
269 // where SetContentAreaHasFocus is never called. See
270 // https://bugs.webkit.org/show_bug.cgi?id=46013 for details.
271 bool containing_view_has_focus_;
272
273 // True if NPP_New did not return an error.
274 bool creation_succeeded_;
275
276 #if defined(OS_WIN)
277 // Runnable Method Factory used to invoke the OnUserGestureEnd method
278 // asynchronously.
279 base::WeakPtrFactory<WebPluginDelegateImpl> user_gesture_msg_factory_;
280 #endif
281
282 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegateImpl);
283 };
284
285 } // namespace content
286
287 #endif // CONTENT_CHILD_NPAPI_WEBPLUGIN_DELEGATE_IMPL_H_
OLDNEW
« no previous file with comments | « content/child/npapi/webplugin_delegate.h ('k') | content/child/npapi/webplugin_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698