| Index: content/browser/renderer_host/render_widget_host_impl.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
|
| index 2c9d0d2cb200ad954da2e802efaa9533c3f01721..1495a397899f6062fd849f785eec6e2726eb73e2 100644
|
| --- a/content/browser/renderer_host/render_widget_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
| @@ -391,6 +391,7 @@ bool RenderWidgetHostImpl::OnMessageReceived(const IPC::Message &msg) {
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_WindowlessPluginDummyWindowDestroyed,
|
| OnWindowlessPluginDummyWindowDestroyed)
|
| #endif
|
| + IPC_MESSAGE_HANDLER(ViewHostMsg_Snapshot, OnSnapshot)
|
| IPC_MESSAGE_UNHANDLED(handled = false)
|
| IPC_END_MESSAGE_MAP_EX()
|
|
|
| @@ -598,6 +599,42 @@ void RenderWidgetHostImpl::CopyFromBackingStore(
|
| callback.Run(result, output.GetBitmap());
|
| }
|
|
|
| +void RenderWidgetHostImpl::GetSnapshotFromRenderer(
|
| + const gfx::Rect& src_subrect,
|
| + const gfx::Size& dst_size,
|
| + const base::Callback<void(bool, const SkBitmap&)>& callback) {
|
| + TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer");
|
| + pending_snapshots_.push(std::make_pair(dst_size, callback));
|
| + Send(new ViewMsg_Snapshot(routing_id_, src_subrect));
|
| +}
|
| +
|
| +void RenderWidgetHostImpl::OnSnapshot(bool success,
|
| + const SkBitmap& bitmap) {
|
| + if (pending_snapshots_.size() == 0) {
|
| + LOG(ERROR) << "RenderWidgetHostImpl::OnSnapshot: "
|
| + "Received a snapshot that was not requested.";
|
| + return;
|
| + }
|
| +
|
| + PendingSnapshotInfo snapshot_info = pending_snapshots_.front();
|
| + pending_snapshots_.pop();
|
| +
|
| + const gfx::Size& dst_size = snapshot_info.first;
|
| + const base::Callback<void(bool, const SkBitmap&)>& callback =
|
| + snapshot_info.second;
|
| +
|
| + if (!success) {
|
| + callback.Run(success, SkBitmap());
|
| + return;
|
| + }
|
| +
|
| + SkBitmap resized = skia::ImageOperations::Resize(
|
| + bitmap, skia::ImageOperations::RESIZE_GOOD, dst_size.width(),
|
| + dst_size.height());
|
| +
|
| + callback.Run(success, resized);
|
| +}
|
| +
|
| #if defined(TOOLKIT_GTK)
|
| bool RenderWidgetHostImpl::CopyFromBackingStoreToGtkWindow(
|
| const gfx::Rect& dest_rect, GdkWindow* target) {
|
|
|