| 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_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/Source/WebKit/chromium/public/WebPlugin.h" | 8 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 void Go(int relativeIndex); | 113 void Go(int relativeIndex); |
| 114 // Tells the BrowserPlugin to terminate the guest process. | 114 // Tells the BrowserPlugin to terminate the guest process. |
| 115 void TerminateGuest(); | 115 void TerminateGuest(); |
| 116 | 116 |
| 117 // A request from Javascript has been made to stop the loading of the page. | 117 // A request from Javascript has been made to stop the loading of the page. |
| 118 void Stop(); | 118 void Stop(); |
| 119 // A request from Javascript has been made to reload the page. | 119 // A request from Javascript has been made to reload the page. |
| 120 void Reload(); | 120 void Reload(); |
| 121 // A request to enable hardware compositing. | 121 // A request to enable hardware compositing. |
| 122 void EnableCompositing(bool enable); | 122 void EnableCompositing(bool enable); |
| 123 // A request from content client to track lifetime of a Javascript object |
| 124 // related to a permission request object. |
| 125 // This is used to clean up hanging permission request objects. |
| 126 void PersistRequestObject(const NPVariant* request, |
| 127 const std::string& type, |
| 128 int id); |
| 123 | 129 |
| 124 // Returns true if |point| lies within the bounds of the plugin rectangle. | 130 // Returns true if |point| lies within the bounds of the plugin rectangle. |
| 125 // Not OK to use this function for making security-sensitive decision since it | 131 // Not OK to use this function for making security-sensitive decision since it |
| 126 // can return false positives when the plugin has rotation transformation | 132 // can return false positives when the plugin has rotation transformation |
| 127 // applied. | 133 // applied. |
| 128 bool InBounds(const gfx::Point& point) const; | 134 bool InBounds(const gfx::Point& point) const; |
| 129 | 135 |
| 130 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; | 136 gfx::Point ToLocalCoordinates(const gfx::Point& point) const; |
| 137 // Called by browser plugin binding. |
| 138 void OnEmbedderDecidedPermission(int request_id, bool allow); |
| 139 |
| 131 | 140 |
| 132 // WebKit::WebPlugin implementation. | 141 // WebKit::WebPlugin implementation. |
| 133 virtual WebKit::WebPluginContainer* container() const OVERRIDE; | 142 virtual WebKit::WebPluginContainer* container() const OVERRIDE; |
| 134 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; | 143 virtual bool initialize(WebKit::WebPluginContainer* container) OVERRIDE; |
| 135 virtual void destroy() OVERRIDE; | 144 virtual void destroy() OVERRIDE; |
| 136 virtual NPObject* scriptableObject() OVERRIDE; | 145 virtual NPObject* scriptableObject() OVERRIDE; |
| 137 virtual bool supportsKeyboardFocus() const OVERRIDE; | 146 virtual bool supportsKeyboardFocus() const OVERRIDE; |
| 138 virtual bool canProcessDrag() const OVERRIDE; | 147 virtual bool canProcessDrag() const OVERRIDE; |
| 139 virtual void paint( | 148 virtual void paint( |
| 140 WebKit::WebCanvas* canvas, | 149 WebKit::WebCanvas* canvas, |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 void GetDamageBufferWithSizeParams( | 247 void GetDamageBufferWithSizeParams( |
| 239 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 248 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 240 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); | 249 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); |
| 241 | 250 |
| 242 // Informs the guest of an updated autosize state. | 251 // Informs the guest of an updated autosize state. |
| 243 void UpdateGuestAutoSizeState(bool current_auto_size); | 252 void UpdateGuestAutoSizeState(bool current_auto_size); |
| 244 | 253 |
| 245 // Informs the BrowserPlugin that guest has changed its size in autosize mode. | 254 // Informs the BrowserPlugin that guest has changed its size in autosize mode. |
| 246 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); | 255 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); |
| 247 | 256 |
| 257 bool HasEventListeners(const std::string& event_name); |
| 258 |
| 248 // Indicates whether a damage buffer was used by the guest process for the | 259 // Indicates whether a damage buffer was used by the guest process for the |
| 249 // provided |params|. | 260 // provided |params|. |
| 250 static bool UsesDamageBuffer( | 261 static bool UsesDamageBuffer( |
| 251 const BrowserPluginMsg_UpdateRect_Params& params); | 262 const BrowserPluginMsg_UpdateRect_Params& params); |
| 252 | 263 |
| 253 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels | 264 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels |
| 254 // given the provided |params|. | 265 // given the provided |params|. |
| 255 bool UsesPendingDamageBuffer( | 266 bool UsesPendingDamageBuffer( |
| 256 const BrowserPluginMsg_UpdateRect_Params& params); | 267 const BrowserPluginMsg_UpdateRect_Params& params); |
| 257 | 268 |
| 258 // Sets the instance ID of the BrowserPlugin and requests a guest from the | 269 // Sets the instance ID of the BrowserPlugin and requests a guest from the |
| 259 // browser process. | 270 // browser process. |
| 260 void SetInstanceID(int instance_id); | 271 void SetInstanceID(int instance_id); |
| 261 | 272 |
| 273 // Populates the ancestor set with the ancestors of the BrowserPlugin. A new |
| 274 // BrowserPlugin gets created when we reparent the <object> node, so this |
| 275 // set should always be valid. |
| 276 void PopulateAncestorList(); |
| 277 |
| 278 // Requests media access permission from the embedder. |
| 279 void RequestMediaPermission(int request_id, |
| 280 const base::DictionaryValue& request_info); |
| 281 // Informs the BrowserPlugin that the guest's permission request has been |
| 282 // allowed or denied by the embedder. |
| 283 // |permission_type| is of type BrowserPluginPermissionType, we pass it as int |
| 284 // so that we don't include message header here. |
| 285 void AllowPermission(int permission_type, int request_id, bool allow); |
| 286 |
| 287 // If the request with id |request_id| is pending then informs the |
| 288 // BrowserPlugin that the guest's permission request has been allowed or |
| 289 // denied by the embedder. |
| 290 void AllowPermissionIfRequestIsPending(int request_id, bool allow); |
| 291 // Cleans up pending permission request once the associated event.request |
| 292 // object goes out of scope in Javascript. |
| 293 void OnRequestObjectGarbageCollected(int request_id); |
| 294 // V8 garbage collection callback for |object|. |
| 295 static void WeakCallbackForPersistObject(v8::Persistent<v8::Value> object, |
| 296 void* param); |
| 297 |
| 262 // IPC message handlers. | 298 // IPC message handlers. |
| 263 // Please keep in alphabetical order. | 299 // Please keep in alphabetical order. |
| 264 void OnAdvanceFocus(int instance_id, bool reverse); | 300 void OnAdvanceFocus(int instance_id, bool reverse); |
| 265 void OnBuffersSwapped(int instance_id, | 301 void OnBuffersSwapped(int instance_id, |
| 266 const gfx::Size& size, | 302 const gfx::Size& size, |
| 267 std::string mailbox_name, | 303 std::string mailbox_name, |
| 268 int gpu_route_id, | 304 int gpu_route_id, |
| 269 int gpu_host_id); | 305 int gpu_host_id); |
| 270 void OnGuestContentWindowReady(int instance_id, | 306 void OnGuestContentWindowReady(int instance_id, |
| 271 int content_window_routing_id); | 307 int content_window_routing_id); |
| 272 void OnGuestGone(int instance_id, int process_id, int status); | 308 void OnGuestGone(int instance_id, int process_id, int status); |
| 273 void OnGuestResponsive(int instance_id, int process_id); | 309 void OnGuestResponsive(int instance_id, int process_id); |
| 274 void OnGuestUnresponsive(int instance_id, int process_id); | 310 void OnGuestUnresponsive(int instance_id, int process_id); |
| 275 void OnLoadAbort(int instance_id, | 311 void OnLoadAbort(int instance_id, |
| 276 const GURL& url, | 312 const GURL& url, |
| 277 bool is_top_level, | 313 bool is_top_level, |
| 278 const std::string& type); | 314 const std::string& type); |
| 279 void OnLoadCommit(int instance_id, | 315 void OnLoadCommit(int instance_id, |
| 280 const BrowserPluginMsg_LoadCommit_Params& params); | 316 const BrowserPluginMsg_LoadCommit_Params& params); |
| 281 void OnLoadRedirect(int instance_id, | 317 void OnLoadRedirect(int instance_id, |
| 282 const GURL& old_url, | 318 const GURL& old_url, |
| 283 const GURL& new_url, | 319 const GURL& new_url, |
| 284 bool is_top_level); | 320 bool is_top_level); |
| 285 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); | 321 void OnLoadStart(int instance_id, const GURL& url, bool is_top_level); |
| 286 void OnLoadStop(int instance_id); | 322 void OnLoadStop(int instance_id); |
| 323 // Requests permission from the embedder. |
| 324 // |permission_type| is of type BrowserPluginPermissionType, we pass it as int |
| 325 // so that we don't include message header here. |
| 326 void OnRequestPermission(int instance_id, |
| 327 int permission_type, |
| 328 int request_id, |
| 329 const base::DictionaryValue& request_info); |
| 287 void OnSetCursor(int instance_id, const WebCursor& cursor); | 330 void OnSetCursor(int instance_id, const WebCursor& cursor); |
| 288 void OnShouldAcceptTouchEvents(int instance_id, bool accept); | 331 void OnShouldAcceptTouchEvents(int instance_id, bool accept); |
| 289 void OnUpdatedName(int instance_id, const std::string& name); | 332 void OnUpdatedName(int instance_id, const std::string& name); |
| 290 void OnUpdateRect(int instance_id, | 333 void OnUpdateRect(int instance_id, |
| 291 const BrowserPluginMsg_UpdateRect_Params& params); | 334 const BrowserPluginMsg_UpdateRect_Params& params); |
| 292 | 335 |
| 293 int instance_id_; | 336 int instance_id_; |
| 294 base::WeakPtr<RenderViewImpl> render_view_; | 337 base::WeakPtr<RenderViewImpl> render_view_; |
| 295 // We cache the |render_view_|'s routing ID because we need it on destruction. | 338 // We cache the |render_view_|'s routing ID because we need it on destruction. |
| 296 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 339 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
| (...skipping 24 matching lines...) Expand all Loading... |
| 321 // Tracks the visibility of the browser plugin regardless of the whole | 364 // Tracks the visibility of the browser plugin regardless of the whole |
| 322 // embedder RenderView's visibility. | 365 // embedder RenderView's visibility. |
| 323 bool visible_; | 366 bool visible_; |
| 324 | 367 |
| 325 WebCursor cursor_; | 368 WebCursor cursor_; |
| 326 | 369 |
| 327 gfx::Size last_view_size_; | 370 gfx::Size last_view_size_; |
| 328 bool size_changed_in_flight_; | 371 bool size_changed_in_flight_; |
| 329 bool allocate_instance_id_sent_; | 372 bool allocate_instance_id_sent_; |
| 330 | 373 |
| 374 // Each permission request item in the map is a pair of request id and |
| 375 // permission type (BrowserPluginPermissionType). |
| 376 typedef std::map<int, std::pair<int, int> > |
| 377 PendingPermissionRequests; |
| 378 PendingPermissionRequests pending_permission_requests_; |
| 379 |
| 380 typedef std::pair<int, base::WeakPtr<BrowserPlugin> > |
| 381 AliveV8PermissionRequestItem; |
| 382 std::map<int, AliveV8PermissionRequestItem*> |
| 383 alive_v8_permission_request_objects_; |
| 384 |
| 331 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to | 385 // BrowserPlugin outlives RenderViewImpl in Chrome Apps and so we need to |
| 332 // store the BrowserPlugin's BrowserPluginManager in a member variable to | 386 // store the BrowserPlugin's BrowserPluginManager in a member variable to |
| 333 // avoid accessing the RenderViewImpl. | 387 // avoid accessing the RenderViewImpl. |
| 334 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; | 388 scoped_refptr<BrowserPluginManager> browser_plugin_manager_; |
| 335 | 389 |
| 336 // Important: Do not add more history state here. | 390 // Important: Do not add more history state here. |
| 337 // We strongly discourage storing additional history state (such as page IDs) | 391 // We strongly discourage storing additional history state (such as page IDs) |
| 338 // in the embedder process, at the risk of having incorrect information that | 392 // in the embedder process, at the risk of having incorrect information that |
| 339 // can lead to broken back/forward logic in apps. | 393 // can lead to broken back/forward logic in apps. |
| 340 // It's also important that this state does not get modified by any logic in | 394 // It's also important that this state does not get modified by any logic in |
| 341 // the embedder process. It should only be updated in response to navigation | 395 // the embedder process. It should only be updated in response to navigation |
| 342 // events in the guest. No assumptions should be made about how the index | 396 // events in the guest. No assumptions should be made about how the index |
| 343 // will change after a navigation (e.g., for back, forward, or go), because | 397 // will change after a navigation (e.g., for back, forward, or go), because |
| 344 // the changes are not always obvious. For example, there is a maximum | 398 // the changes are not always obvious. For example, there is a maximum |
| 345 // number of entries and earlier ones will automatically be pruned. | 399 // number of entries and earlier ones will automatically be pruned. |
| 346 int current_nav_entry_index_; | 400 int current_nav_entry_index_; |
| 347 int nav_entry_count_; | 401 int nav_entry_count_; |
| 348 | 402 |
| 349 // Used for HW compositing. | 403 // Used for HW compositing. |
| 350 bool compositing_enabled_; | 404 bool compositing_enabled_; |
| 351 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; | 405 scoped_refptr<BrowserPluginCompositingHelper> compositing_helper_; |
| 352 | 406 |
| 407 // Weak factory used in v8 |MakeWeak| callback, since the v8 callback might |
| 408 // get called after BrowserPlugin has been destroyed. |
| 409 base::WeakPtrFactory<BrowserPlugin> weak_ptr_factory_; |
| 410 |
| 411 // Set of ancestor nodes. |
| 412 std::vector<WebKit::WebNode> ancestors_; |
| 413 |
| 353 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 414 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 354 }; | 415 }; |
| 355 | 416 |
| 356 } // namespace content | 417 } // namespace content |
| 357 | 418 |
| 358 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 419 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |