| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 192 |
| 193 // Parses the attributes of the browser plugin from the element's attributes | 193 // Parses the attributes of the browser plugin from the element's attributes |
| 194 // and sets them appropriately. | 194 // and sets them appropriately. |
| 195 void ParseAttributes(const WebKit::WebPluginParams& params); | 195 void ParseAttributes(const WebKit::WebPluginParams& params); |
| 196 | 196 |
| 197 // Triggers the event-listeners for |event_name|. Note that the function | 197 // Triggers the event-listeners for |event_name|. Note that the function |
| 198 // frees all the values in |props|. | 198 // frees all the values in |props|. |
| 199 void TriggerEvent(const std::string& event_name, | 199 void TriggerEvent(const std::string& event_name, |
| 200 std::map<std::string, base::Value*>* props); | 200 std::map<std::string, base::Value*>* props); |
| 201 | 201 |
| 202 // Creates and maps transport dib. Overridden in tests. | 202 // Creates and maps a shared damage buffer. |
| 203 virtual TransportDIB* CreateTransportDIB(const size_t size); | 203 virtual base::SharedMemory* CreateDamageBuffer( |
| 204 // Frees up the damage buffer. Overridden in tests. | 204 const size_t size, |
| 205 virtual void FreeDamageBuffer(TransportDIB** damage_buffer); | 205 base::SharedMemoryHandle* shared_memory_handle); |
| 206 // Swaps out the |current_damage_buffer_| with the |pending_damage_buffer_|. | 206 // Swaps out the |current_damage_buffer_| with the |pending_damage_buffer_|. |
| 207 void SwapDamageBuffers(); | 207 void SwapDamageBuffers(); |
| 208 | 208 |
| 209 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state and | 209 // Populates BrowserPluginHostMsg_ResizeGuest_Params with resize state and |
| 210 // returns the newly allocated TransportDIB. | 210 // allocates a new |pending_damage_buffer_| if in software rendering mode. |
| 211 TransportDIB* PopulateResizeGuestParameters( | 211 void PopulateResizeGuestParameters( |
| 212 BrowserPluginHostMsg_ResizeGuest_Params* params, | 212 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 213 const gfx::Size& view_size); | 213 const gfx::Size& view_size); |
| 214 | 214 |
| 215 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. | 215 // Populates BrowserPluginHostMsg_AutoSize_Params object with autosize state. |
| 216 void PopulateAutoSizeParameters( | 216 void PopulateAutoSizeParameters( |
| 217 BrowserPluginHostMsg_AutoSize_Params* params); | 217 BrowserPluginHostMsg_AutoSize_Params* params); |
| 218 | 218 |
| 219 // Populates both AutoSize and ResizeGuest parameters based on the current | 219 // Populates both AutoSize and ResizeGuest parameters based on the current |
| 220 // autosize state. | 220 // autosize state. |
| 221 TransportDIB* GetDamageBufferWithSizeParams( | 221 void GetDamageBufferWithSizeParams( |
| 222 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, | 222 BrowserPluginHostMsg_AutoSize_Params* auto_size_params, |
| 223 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); | 223 BrowserPluginHostMsg_ResizeGuest_Params* resize_guest_params); |
| 224 | 224 |
| 225 // Informs the guest of an updated autosize state. | 225 // Informs the guest of an updated autosize state. |
| 226 void UpdateGuestAutoSizeState(); | 226 void UpdateGuestAutoSizeState(); |
| 227 | 227 |
| 228 // Informs the BrowserPlugin that guest has changed its size in autosize mode. | 228 // Informs the BrowserPlugin that guest has changed its size in autosize mode. |
| 229 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); | 229 void SizeChangedDueToAutoSize(const gfx::Size& old_view_size); |
| 230 | 230 |
| 231 #if defined(OS_MACOSX) | 231 // Indicates whether a damage buffer was used by the guest process for the |
| 232 bool DamageBufferMatches(const TransportDIB* damage_buffer, | 232 // provided |params|. |
| 233 const TransportDIB::Id& other_damage_buffer_id); | 233 static bool UsesDamageBuffer( |
| 234 #else | 234 const BrowserPluginMsg_UpdateRect_Params& params); |
| 235 bool DamageBufferMatches( | 235 |
| 236 const TransportDIB* damage_buffer, | 236 // Indicates whether the |pending_damage_buffer_| was used to copy over pixels |
| 237 const TransportDIB::Handle& other_damage_buffer_handle); | 237 // given the provided |params|. |
| 238 #endif | 238 bool UsesPendingDamageBuffer( |
| 239 const BrowserPluginMsg_UpdateRect_Params& params); |
| 239 | 240 |
| 240 // IPC message handlers. | 241 // IPC message handlers. |
| 241 // Please keep in alphabetical order. | 242 // Please keep in alphabetical order. |
| 242 void OnAdvanceFocus(int instance_id, bool reverse); | 243 void OnAdvanceFocus(int instance_id, bool reverse); |
| 243 void OnGuestContentWindowReady(int instance_id, | 244 void OnGuestContentWindowReady(int instance_id, |
| 244 int content_window_routing_id); | 245 int content_window_routing_id); |
| 245 void OnGuestGone(int instance_id, int process_id, int status); | 246 void OnGuestGone(int instance_id, int process_id, int status); |
| 246 void OnGuestResponsive(int instance_id, int process_id); | 247 void OnGuestResponsive(int instance_id, int process_id); |
| 247 void OnGuestUnresponsive(int instance_id, int process_id); | 248 void OnGuestUnresponsive(int instance_id, int process_id); |
| 248 void OnLoadAbort(int instance_id, | 249 void OnLoadAbort(int instance_id, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 265 | 266 |
| 266 int instance_id_; | 267 int instance_id_; |
| 267 base::WeakPtr<RenderViewImpl> render_view_; | 268 base::WeakPtr<RenderViewImpl> render_view_; |
| 268 // We cache the |render_view_|'s routing ID because we need it on destruction. | 269 // We cache the |render_view_|'s routing ID because we need it on destruction. |
| 269 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed | 270 // If the |render_view_| is destroyed before the BrowserPlugin is destroyed |
| 270 // then we will attempt to access a NULL pointer. | 271 // then we will attempt to access a NULL pointer. |
| 271 int render_view_routing_id_; | 272 int render_view_routing_id_; |
| 272 WebKit::WebPluginContainer* container_; | 273 WebKit::WebPluginContainer* container_; |
| 273 scoped_ptr<BrowserPluginBindings> bindings_; | 274 scoped_ptr<BrowserPluginBindings> bindings_; |
| 274 scoped_ptr<BrowserPluginBackingStore> backing_store_; | 275 scoped_ptr<BrowserPluginBackingStore> backing_store_; |
| 275 TransportDIB* current_damage_buffer_; | 276 scoped_ptr<base::SharedMemory> current_damage_buffer_; |
| 276 TransportDIB* pending_damage_buffer_; | 277 scoped_ptr<base::SharedMemory> pending_damage_buffer_; |
| 278 uint32 damage_buffer_sequence_id_; |
| 277 gfx::Rect plugin_rect_; | 279 gfx::Rect plugin_rect_; |
| 278 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. | 280 // Bitmap for crashed plugin. Lazily initialized, non-owning pointer. |
| 279 SkBitmap* sad_guest_; | 281 SkBitmap* sad_guest_; |
| 280 bool guest_crashed_; | 282 bool guest_crashed_; |
| 281 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; | 283 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> pending_resize_params_; |
| 282 // True if we have ever sent a NavigateGuest message to the embedder. | 284 // True if we have ever sent a NavigateGuest message to the embedder. |
| 283 bool navigate_src_sent_; | 285 bool navigate_src_sent_; |
| 284 std::string src_; | 286 std::string src_; |
| 285 bool auto_size_; | 287 bool auto_size_; |
| 286 int max_height_; | 288 int max_height_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // the changes are not always obvious. For example, there is a maximum | 321 // the changes are not always obvious. For example, there is a maximum |
| 320 // number of entries and earlier ones will automatically be pruned. | 322 // number of entries and earlier ones will automatically be pruned. |
| 321 int current_nav_entry_index_; | 323 int current_nav_entry_index_; |
| 322 int nav_entry_count_; | 324 int nav_entry_count_; |
| 323 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); | 325 DISALLOW_COPY_AND_ASSIGN(BrowserPlugin); |
| 324 }; | 326 }; |
| 325 | 327 |
| 326 } // namespace content | 328 } // namespace content |
| 327 | 329 |
| 328 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ | 330 #endif // CONTENT_RENDERER_BROWSER_PLUGIN_BROWSER_PLUGIN_H_ |
| OLD | NEW |