OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 5 #ifndef CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 6 #define CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
7 | 7 |
8 #include "third_party/WebKit/public/web/WebPlugin.h" | 8 #include "third_party/WebKit/public/web/WebPlugin.h" |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/sequenced_task_runner_helpers.h" | 12 #include "base/sequenced_task_runner_helpers.h" |
13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
14 #include "base/memory/shared_memory.h" | 14 #include "base/memory/shared_memory.h" |
15 #endif | 15 #endif |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "content/common/browser_plugin/browser_plugin_message_enums.h" | 17 #include "content/public/common/browser_plugin/browser_plugin_message_enums.h" |
18 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" | 18 #include "content/renderer/browser_plugin/browser_plugin_backing_store.h" |
19 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" | 19 #include "content/renderer/browser_plugin/browser_plugin_bindings.h" |
20 #include "content/renderer/mouse_lock_dispatcher.h" | 20 #include "content/renderer/mouse_lock_dispatcher.h" |
21 #include "content/renderer/render_view_impl.h" | 21 #include "content/renderer/render_view_impl.h" |
22 #include "third_party/WebKit/public/web/WebDragStatus.h" | 22 #include "third_party/WebKit/public/web/WebDragStatus.h" |
23 | 23 |
24 struct BrowserPluginHostMsg_AutoSize_Params; | 24 struct BrowserPluginHostMsg_AutoSize_Params; |
25 struct BrowserPluginHostMsg_ResizeGuest_Params; | 25 struct BrowserPluginHostMsg_ResizeGuest_Params; |
26 struct BrowserPluginMsg_Attach_ACK_Params; | 26 struct BrowserPluginMsg_Attach_ACK_Params; |
27 struct BrowserPluginMsg_BuffersSwapped_Params; | 27 struct BrowserPluginMsg_BuffersSwapped_Params; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // renderer. | 114 // renderer. |
115 void UpdateDeviceScaleFactor(float device_scale_factor); | 115 void UpdateDeviceScaleFactor(float device_scale_factor); |
116 | 116 |
117 // A request to enable hardware compositing. | 117 // A request to enable hardware compositing. |
118 void EnableCompositing(bool enable); | 118 void EnableCompositing(bool enable); |
119 // A request from content client to track lifetime of a JavaScript object. | 119 // A request from content client to track lifetime of a JavaScript object. |
120 // This is used to track permission request objects, and new window API | 120 // This is used to track permission request objects, and new window API |
121 // window objects. | 121 // window objects. |
122 void TrackObjectLifetime(const NPVariant* request, int id); | 122 void TrackObjectLifetime(const NPVariant* request, int id); |
123 | 123 |
124 // If the request with id |request_id| is pending then informs the | |
125 // BrowserPlugin that the guest's permission request has been allowed or | |
126 // denied by the embedder. Returns whether the request was pending. | |
127 bool RespondPermissionIfRequestIsPending(int request_id, | |
128 bool allow, | |
129 const std::string& user_input); | |
130 | |
131 // Returns true if |point| lies within the bounds of the plugin rectangle. | 124 // Returns true if |point| lies within the bounds of the plugin rectangle. |
132 // Not OK to use this function for making security-sensitive decision since it | 125 // Not OK to use this function for making security-sensitive decision since it |
133 // can return false positives when the plugin has rotation transformation | 126 // can return false positives when the plugin has rotation transformation |
134 // applied. | 127 // applied. |
135 bool InBounds(const gfx::Point& point) const; | 128 bool InBounds(const gfx::Point& point) const; |
136 | 129 |
137 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 130 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
138 | 131 |
139 // Called when a guest instance ID has been allocated by the browser process. | 132 // Called when a guest instance ID has been allocated by the browser process. |
140 void OnInstanceIDAllocated(int guest_instance_id); | 133 void OnInstanceIDAllocated(int guest_instance_id); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Indicates whether a damage buffer was used by the guest process for the | 278 // Indicates whether a damage buffer was used by the guest process for the |
286 // provided |params|. | 279 // provided |params|. |
287 static bool UsesDamageBuffer( | 280 static bool UsesDamageBuffer( |
288 const BrowserPluginMsg_UpdateRect_Params& params); | 281 const BrowserPluginMsg_UpdateRect_Params& params); |
289 | 282 |
290 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels | 283 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels |
291 // given the provided |params|. | 284 // given the provided |params|. |
292 bool UsesPendingDamageBuffer( | 285 bool UsesPendingDamageBuffer( |
293 const BrowserPluginMsg_UpdateRect_Params& params); | 286 const BrowserPluginMsg_UpdateRect_Params& params); |
294 | 287 |
295 void AddPermissionRequestToSet(int request_id); | |
296 | |
297 // Informs the BrowserPlugin that the guest's permission request has been | |
298 // allowed or denied by the embedder. | |
299 void RespondPermission(int request_id, | |
300 bool allow, | |
301 const std::string& user_input); | |
302 | |
303 // Called when the tracked object of |id| ID becomes unreachable in | 288 // Called when the tracked object of |id| ID becomes unreachable in |
304 // JavaScript. | 289 // JavaScript. |
305 void OnTrackedObjectGarbageCollected(int id); | 290 void OnTrackedObjectGarbageCollected(int id); |
306 // V8 garbage collection callback for |object|. | 291 // V8 garbage collection callback for |object|. |
307 static void WeakCallbackForTrackedObject(v8::Isolate* isolate, | 292 static void WeakCallbackForTrackedObject(v8::Isolate* isolate, |
308 v8::Persistent<v8::Value>* object, | 293 v8::Persistent<v8::Value>* object, |
309 void* param); | 294 void* param); |
310 | 295 |
311 // IPC message handlers. | 296 // IPC message handlers. |
312 // Please keep in alphabetical order. | 297 // Please keep in alphabetical order. |
313 void OnAdvanceFocus(int instance_id, bool reverse); | 298 void OnAdvanceFocus(int instance_id, bool reverse); |
314 void OnAttachACK(int instance_id, | 299 void OnAttachACK(int instance_id, |
315 const BrowserPluginMsg_Attach_ACK_Params& ack_params); | 300 const BrowserPluginMsg_Attach_ACK_Params& ack_params); |
316 void OnBuffersSwapped(int instance_id, | 301 void OnBuffersSwapped(int instance_id, |
317 const BrowserPluginMsg_BuffersSwapped_Params& params); | 302 const BrowserPluginMsg_BuffersSwapped_Params& params); |
318 void OnCompositorFrameSwapped(const IPC::Message& message); | 303 void OnCompositorFrameSwapped(const IPC::Message& message); |
319 void OnGuestContentWindowReady(int instance_id, | 304 void OnGuestContentWindowReady(int instance_id, |
320 int content_window_routing_id); | 305 int content_window_routing_id); |
321 void OnGuestGone(int instance_id); | 306 void OnGuestGone(int instance_id); |
322 void OnGuestResponsive(int instance_id, int process_id); | |
323 void OnGuestUnresponsive(int instance_id, int process_id); | |
324 // Requests permission from the embedder. | |
325 void OnRequestPermission(int instance_id, | |
326 BrowserPluginPermissionType permission_type, | |
327 int request_id, | |
328 const base::DictionaryValue& request_info); | |
329 void OnSetCursor(int instance_id, const WebCursor& cursor); | 307 void OnSetCursor(int instance_id, const WebCursor& cursor); |
330 void OnSetMouseLock(int instance_id, bool enable); | 308 void OnSetMouseLock(int instance_id, bool enable); |
331 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 309 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
332 void OnUpdatedName(int instance_id, const std::string& name); | 310 void OnUpdatedName(int instance_id, const std::string& name); |
333 void OnUpdateRect(int instance_id, | 311 void OnUpdateRect(int instance_id, |
334 const BrowserPluginMsg_UpdateRect_Params& params); | 312 const BrowserPluginMsg_UpdateRect_Params& params); |
335 | 313 |
336 // This is the browser-process-allocated instance ID that uniquely identifies | 314 // This is the browser-process-allocated instance ID that uniquely identifies |
337 // a guest WebContents. | 315 // a guest WebContents. |
338 int guest_instance_id_; | 316 int guest_instance_id_; |
(...skipping 28 matching lines...) Expand all Loading... |
367 // embedder RenderView's visibility. | 345 // embedder RenderView's visibility. |
368 bool visible_; | 346 bool visible_; |
369 | 347 |
370 WebCursor cursor_; | 348 WebCursor cursor_; |
371 | 349 |
372 gfx::Size last_view_size_; | 350 gfx::Size last_view_size_; |
373 bool size_changed_in_flight_; | 351 bool size_changed_in_flight_; |
374 bool before_first_navigation_; | 352 bool before_first_navigation_; |
375 bool mouse_locked_; | 353 bool mouse_locked_; |
376 | 354 |
377 // The set of permission request IDs that have not yet been processed. | |
378 typedef std::set<int> PendingPermissionRequests; | |
379 PendingPermissionRequests pending_permission_requests_; | |
380 | |
381 typedef std::pair<int, base::WeakPtr<BrowserPlugin> > TrackedV8ObjectID; | 355 typedef std::pair<int, base::WeakPtr<BrowserPlugin> > TrackedV8ObjectID; |
382 std::map<int, TrackedV8ObjectID*> tracked_v8_objects_; | 356 std::map<int, TrackedV8ObjectID*> tracked_v8_objects_; |
383 | 357 |
384 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 358 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
385 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 359 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
386 // avoid accessing the RenderViewImpl. | 360 // avoid accessing the RenderViewImpl. |
387 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 361 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
388 | 362 |
389 // Used for HW compositing. | 363 // Used for HW compositing. |
390 bool compositing_enabled_; | 364 bool compositing_enabled_; |
391 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; | 365 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; |
392 | 366 |
393 // Used to identify the plugin to WebBindings. | 367 // Used to identify the plugin to WebBindings. |
394 scoped_ptr<struct _NPP> npp_; | 368 scoped_ptr<struct _NPP> npp_; |
395 | 369 |
396 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might | 370 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
397 // get called after BrowserPlugin has been destroyed. | 371 // get called after BrowserPlugin has been destroyed. |
398 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; | 372 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
399 | 373 |
400 std::vector<EditCommand> edit_commands_; | 374 std::vector<EditCommand> edit_commands_; |
401 | 375 |
402 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 376 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
403 }; | 377 }; |
404 | 378 |
405 } // namespace content | 379 } // namespace content |
406 | 380 |
407 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 381 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
OLD | NEW |