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