| 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 // A BrowserPluginGuest represents the browser side of browser <--> renderer | 5 // A BrowserPluginGuest represents the browser side of browser <--> renderer |
| 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of | 6 // communication. A BrowserPlugin (a WebPlugin) is on the renderer side of |
| 7 // browser <--> guest renderer communication. The 'guest' renderer is a | 7 // browser <--> guest renderer communication. The 'guest' renderer is a |
| 8 // <browser> tag. | 8 // <browser> tag. |
| 9 // | 9 // |
| 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a | 10 // BrowserPluginGuest lives on the UI thread of the browser process. It has a |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // to the BrowserPlugin. BrowserPluginGuest is a WebContentsDelegate and | 26 // to the BrowserPlugin. BrowserPluginGuest is a WebContentsDelegate and |
| 27 // WebContentsObserver for the WebContents. | 27 // WebContentsObserver for the WebContents. |
| 28 | 28 |
| 29 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 29 #ifndef CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| 30 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 30 #define CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| 31 | 31 |
| 32 #include <map> | 32 #include <map> |
| 33 | 33 |
| 34 #include "base/compiler_specific.h" | 34 #include "base/compiler_specific.h" |
| 35 #include "base/id_map.h" | 35 #include "base/id_map.h" |
| 36 #include "base/shared_memory.h" |
| 36 #include "base/time.h" | 37 #include "base/time.h" |
| 37 #include "content/public/browser/notification_observer.h" | 38 #include "content/public/browser/notification_observer.h" |
| 38 #include "content/public/browser/notification_registrar.h" | 39 #include "content/public/browser/notification_registrar.h" |
| 39 #include "content/public/browser/web_contents_delegate.h" | 40 #include "content/public/browser/web_contents_delegate.h" |
| 40 #include "content/public/browser/web_contents_observer.h" | 41 #include "content/public/browser/web_contents_observer.h" |
| 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" | 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragStatus.h" |
| 42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" | 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDragOperation.h" |
| 43 #include "ui/gfx/rect.h" | 44 #include "ui/gfx/rect.h" |
| 44 #include "ui/surface/transport_dib.h" | 45 #include "ui/surface/transport_dib.h" |
| 45 | 46 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // If possible, navigate the guest to |relative_index| entries away from the | 230 // If possible, navigate the guest to |relative_index| entries away from the |
| 230 // current navigation entry. | 231 // current navigation entry. |
| 231 virtual void Go(int relative_index); | 232 virtual void Go(int relative_index); |
| 232 // Overridden in tests. | 233 // Overridden in tests. |
| 233 virtual void SetFocus(bool focused); | 234 virtual void SetFocus(bool focused); |
| 234 // Reload the guest. | 235 // Reload the guest. |
| 235 virtual void Reload(); | 236 virtual void Reload(); |
| 236 // Stop loading the guest. | 237 // Stop loading the guest. |
| 237 virtual void Stop(); | 238 virtual void Stop(); |
| 238 // Overridden in tests. | 239 // Overridden in tests. |
| 239 virtual void SetDamageBuffer(TransportDIB* damage_buffer, | 240 virtual void SetDamageBuffer( |
| 240 #if defined(OS_WIN) | 241 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 241 int damage_buffer_size, | 242 |
| 242 TransportDIB::Handle remote_handle, | |
| 243 #endif | |
| 244 const gfx::Size& damage_view_size, | |
| 245 float scale_factor); | |
| 246 // Overridden in tests. | 243 // Overridden in tests. |
| 247 virtual void SetCompositingBufferData(int gpu_process_id, | 244 virtual void SetCompositingBufferData(int gpu_process_id, |
| 248 uint32 client_id, | 245 uint32 client_id, |
| 249 uint32 context_id, | 246 uint32 context_id, |
| 250 uint32 texture_id_0, | 247 uint32 texture_id_0, |
| 251 uint32 texture_id_1, | 248 uint32 texture_id_1, |
| 252 uint32 sync_point); | 249 uint32 sync_point); |
| 253 | 250 |
| 254 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; | 251 gfx::Point GetScreenCoordinates(const gfx::Point& relative_position) const; |
| 255 | 252 |
| 256 private: | 253 private: |
| 257 friend class TestBrowserPluginGuest; | 254 friend class TestBrowserPluginGuest; |
| 258 | 255 |
| 259 BrowserPluginGuest(int instance_id, | 256 BrowserPluginGuest(int instance_id, |
| 260 WebContentsImpl* web_contents, | 257 WebContentsImpl* web_contents, |
| 261 const BrowserPluginHostMsg_CreateGuest_Params& params); | 258 const BrowserPluginHostMsg_CreateGuest_Params& params); |
| 262 | 259 |
| 263 // Returns the identifier that uniquely identifies a browser plugin guest | 260 // Returns the identifier that uniquely identifies a browser plugin guest |
| 264 // within an embedder. | 261 // within an embedder. |
| 265 int instance_id() const { return instance_id_; } | 262 int instance_id() const { return instance_id_; } |
| 266 TransportDIB* damage_buffer() const { return damage_buffer_.get(); } | 263 base::SharedMemory* damage_buffer() const { return damage_buffer_.get(); } |
| 267 const gfx::Size& damage_view_size() const { return damage_view_size_; } | 264 const gfx::Size& damage_view_size() const { return damage_view_size_; } |
| 268 float damage_buffer_scale_factor() const { | 265 float damage_buffer_scale_factor() const { |
| 269 return damage_buffer_scale_factor_; | 266 return damage_buffer_scale_factor_; |
| 270 } | 267 } |
| 271 // Returns the transport DIB associated with the dib in resize |params|. | 268 // Returns the damage buffer corresponding to the handle in resize |params|. |
| 272 TransportDIB* GetDamageBufferFromEmbedder( | 269 base::SharedMemory* GetDamageBufferFromEmbedder( |
| 273 RenderViewHost* embedder_rvh, | |
| 274 const BrowserPluginHostMsg_ResizeGuest_Params& params); | 270 const BrowserPluginHostMsg_ResizeGuest_Params& params); |
| 275 | 271 |
| 276 // Returns the embedder's routing ID. | 272 // Returns the embedder's routing ID. |
| 277 int embedder_routing_id() const; | 273 int embedder_routing_id() const; |
| 278 | 274 |
| 279 // Helper to send messages to embedder. Overridden in test implementation | 275 // Helper to send messages to embedder. Overridden in test implementation |
| 280 // since we want to intercept certain messages for testing. | 276 // since we want to intercept certain messages for testing. |
| 281 virtual void SendMessageToEmbedder(IPC::Message* msg); | 277 virtual void SendMessageToEmbedder(IPC::Message* msg); |
| 282 | 278 |
| 283 // Called when a redirect notification occurs. | 279 // Called when a redirect notification occurs. |
| 284 void LoadRedirect(const GURL& old_url, | 280 void LoadRedirect(const GURL& old_url, |
| 285 const GURL& new_url, | 281 const GURL& new_url, |
| 286 bool is_top_level); | 282 bool is_top_level); |
| 287 | 283 |
| 288 bool InAutoSizeBounds(const gfx::Size& size) const; | 284 bool InAutoSizeBounds(const gfx::Size& size) const; |
| 289 // Static factory instance (always NULL for non-test). | 285 // Static factory instance (always NULL for non-test). |
| 290 static content::BrowserPluginHostFactory* factory_; | 286 static content::BrowserPluginHostFactory* factory_; |
| 291 | 287 |
| 292 NotificationRegistrar notification_registrar_; | 288 NotificationRegistrar notification_registrar_; |
| 293 WebContentsImpl* embedder_web_contents_; | 289 WebContentsImpl* embedder_web_contents_; |
| 294 // An identifier that uniquely identifies a browser plugin guest within an | 290 // An identifier that uniquely identifies a browser plugin guest within an |
| 295 // embedder. | 291 // embedder. |
| 296 int instance_id_; | 292 int instance_id_; |
| 297 scoped_ptr<TransportDIB> damage_buffer_; | 293 scoped_ptr<base::SharedMemory> damage_buffer_; |
| 298 #if defined(OS_WIN) | 294 // An identifier that uniquely identifies a damage buffer. |
| 295 uint32 damage_buffer_sequence_id_; |
| 299 size_t damage_buffer_size_; | 296 size_t damage_buffer_size_; |
| 300 TransportDIB::Handle remote_damage_buffer_handle_; | |
| 301 #endif | |
| 302 gfx::Size damage_view_size_; | 297 gfx::Size damage_view_size_; |
| 303 float damage_buffer_scale_factor_; | 298 float damage_buffer_scale_factor_; |
| 304 gfx::Rect guest_window_rect_; | 299 gfx::Rect guest_window_rect_; |
| 305 gfx::Rect guest_screen_rect_; | 300 gfx::Rect guest_screen_rect_; |
| 306 IDMap<RenderViewHost> pending_updates_; | 301 IDMap<RenderViewHost> pending_updates_; |
| 307 int pending_update_counter_; | 302 int pending_update_counter_; |
| 308 base::TimeDelta guest_hang_timeout_; | 303 base::TimeDelta guest_hang_timeout_; |
| 309 bool focused_; | 304 bool focused_; |
| 310 bool visible_; | 305 bool visible_; |
| 311 bool auto_size_enabled_; | 306 bool auto_size_enabled_; |
| 312 gfx::Size max_auto_size_; | 307 gfx::Size max_auto_size_; |
| 313 gfx::Size min_auto_size_; | 308 gfx::Size min_auto_size_; |
| 314 | 309 |
| 315 // Hardware Accelerated Surface Params | 310 // Hardware Accelerated Surface Params |
| 316 gfx::GLSurfaceHandle surface_handle_; | 311 gfx::GLSurfaceHandle surface_handle_; |
| 317 | 312 |
| 318 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); | 313 DISALLOW_COPY_AND_ASSIGN(BrowserPluginGuest); |
| 319 }; | 314 }; |
| 320 | 315 |
| 321 } // namespace content | 316 } // namespace content |
| 322 | 317 |
| 323 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ | 318 #endif // CONTENT_BROWSER_BROWSER_PLUGIN_BROWSER_PLUGIN_GUEST_H_ |
| OLD | NEW |