Index: content/browser/browser_plugin/browser_plugin_embedder.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc |
index 930db2726a3e556f6b711610177a1f13c68d73da..5fae7127c3a81fe702e88ed6b64253449d80578c 100644 |
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc |
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc |
@@ -14,6 +14,7 @@ |
#include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
#include "content/browser/renderer_host/render_view_host_impl.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
+#include "content/common/browser_plugin_messages.h" |
#include "content/public/browser/notification_details.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
@@ -77,11 +78,12 @@ void BrowserPluginEmbedder::AddGuest(int instance_id, |
guest_web_contents_by_instance_id_[instance_id] = guest_web_contents; |
} |
-void BrowserPluginEmbedder::NavigateGuest(RenderViewHost* render_view_host, |
- int instance_id, |
- int64 frame_id, |
- const std::string& src, |
- const gfx::Size& size) { |
+void BrowserPluginEmbedder::NavigateGuest( |
+ RenderViewHost* render_view_host, |
+ int instance_id, |
+ int64 frame_id, |
+ const std::string& src, |
+ const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { |
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
WebContentsImpl* guest_web_contents = NULL; |
GURL url(src); |
@@ -118,8 +120,8 @@ void BrowserPluginEmbedder::NavigateGuest(RenderViewHost* render_view_host, |
std::string()); |
} |
- if (!size.IsEmpty()) |
- guest_web_contents->GetView()->SizeContents(size); |
+ // Resize the guest if the resize parameter was set from the renderer. |
+ ResizeGuest(instance_id, resize_params); |
} |
void BrowserPluginEmbedder::UpdateRectACK(int instance_id, |
@@ -130,28 +132,65 @@ void BrowserPluginEmbedder::UpdateRectACK(int instance_id, |
guest->UpdateRectACK(message_id, size); |
} |
-void BrowserPluginEmbedder::ResizeGuest(int instance_id, |
- TransportDIB* damage_buffer, |
-#if defined(OS_WIN) |
- int damage_buffer_size, |
-#endif |
- int width, |
- int height, |
- bool resize_pending, |
- float scale_factor) { |
+void BrowserPluginEmbedder::ResizeGuest( |
+ int instance_id, |
+ const BrowserPluginHostMsg_ResizeGuest_Params& params) { |
+ // TODO(fsamuel): Schedule this later so that we don't stall the embedder for |
+ // too long. |
Charlie Reis
2012/09/25 22:44:24
How would you delay the ResizeGuest? Would that r
Fady Samuel
2012/09/25 22:49:38
This TODO is outdated actually. SetDamageBuffer ne
lazyboy
2012/09/25 23:15:30
Removed the TODO.
On 2012/09/25 22:49:38, Fady
|
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
if (!guest) |
return; |
WebContentsImpl* guest_web_contents = |
static_cast<WebContentsImpl*>(guest->GetWebContents()); |
+ |
+ if (!TransportDIB::is_valid_id(params.damage_buffer_id)) { |
+ // Invalid transport dib, just resize the WebContents. |
Charlie Reis
2012/09/25 22:44:24
nit: so just
lazyboy
2012/09/25 23:15:30
Done.
|
+ if (params.width && params.height) { |
+ guest_web_contents->GetView()->SizeContents(gfx::Size(params.width, |
+ params.height)); |
+ } |
+ return; |
+ } |
+ |
+ TransportDIB* damage_buffer = GetDamageBuffer(params.damage_buffer_id); |
guest->SetDamageBuffer(damage_buffer, |
#if defined(OS_WIN) |
- damage_buffer_size, |
+ params.damage_buffer_size, |
#endif |
- gfx::Size(width, height), |
- scale_factor); |
- if (!resize_pending) |
- guest_web_contents->GetView()->SizeContents(gfx::Size(width, height)); |
+ gfx::Size(params.width, params.height), |
+ params.scale_factor); |
+ if (!params.resize_pending) { |
+ guest_web_contents->GetView()->SizeContents(gfx::Size(params.width, |
+ params.height)); |
+ } |
+} |
+ |
+TransportDIB* BrowserPluginEmbedder::GetDamageBuffer( |
+ const TransportDIB::Id& damage_buffer_id) { |
+ TransportDIB* damage_buffer = NULL; |
+#if defined(OS_WIN) |
+ // On Windows we need to duplicate the handle from the remote process. |
+ HANDLE section; |
+ DuplicateHandle(render_view_host()->GetProcess()->GetHandle(), |
+ damage_buffer_id.handle, |
+ GetCurrentProcess(), |
+ §ion, |
+ STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, |
+ FALSE, |
+ 0); |
+ damage_buffer = TransportDIB::Map(section); |
+#elif defined(OS_MACOSX) |
+ // On OSX, the browser allocates all DIBs and keeps a file descriptor around |
+ // for each. |
+ damage_buffer = render_view_host()->GetProcess()-> |
+ GetTransportDIB(damage_buffer_id); |
+#elif defined(OS_ANDROID) |
+ damage_buffer = TransportDIB::Map(damage_buffer_id); |
+#elif defined(OS_POSIX) |
+ damage_buffer = TransportDIB::Map(damage_buffer_id.shmkey); |
+#endif // defined(OS_POSIX) |
+ DCHECK(damage_buffer); |
+ return damage_buffer; |
} |
void BrowserPluginEmbedder::SetFocus(int instance_id, |