Index: content/browser/renderer_host/render_view_host_impl.cc |
diff --git a/content/browser/renderer_host/render_view_host_impl.cc b/content/browser/renderer_host/render_view_host_impl.cc |
index bfcb2d1fe9cbc55bf0ba41ef7ebf0462a295097b..a7b565a4870c3de7d2dfdc267d124aa1ad574d79 100644 |
--- a/content/browser/renderer_host/render_view_host_impl.cc |
+++ b/content/browser/renderer_host/render_view_host_impl.cc |
@@ -65,6 +65,7 @@ |
#include "ui/base/dialogs/selected_file_info.h" |
#include "ui/gfx/image/image_skia.h" |
#include "ui/gfx/native_widget_types.h" |
+#include "ui/snapshot/snapshot.h" |
#include "webkit/fileapi/isolated_context.h" |
#include "webkit/glue/webdropdata.h" |
#include "webkit/glue/webkit_glue.h" |
@@ -1020,6 +1021,7 @@ bool RenderViewHostImpl::OnMessageReceived(const IPC::Message& msg) { |
IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) |
IPC_MESSAGE_HANDLER(ViewHostMsg_MediaNotification, OnMediaNotification) |
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot) |
#if defined(OS_ANDROID) |
IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) |
IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, |
@@ -2039,4 +2041,31 @@ void RenderViewHostImpl::ClearPowerSaveBlockers() { |
STLDeleteValues(&power_save_blockers_); |
} |
+void RenderViewHostImpl::OnGetWindowSnapshot(const int snapshot_id) { |
+ std::vector<unsigned char> png; |
+ |
+ // This feature is behind the kEnableGpuBenchmarking command line switch |
+ // because it poses security concerns and should only be used for testing. |
Nico
2012/12/12 23:46:20
nit: Might be worth mentioning that if this was co
|
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) { |
+ gfx::Size snapshot_size; |
+ gfx::Rect view_bounds = GetView()->GetViewBounds(); |
+ gfx::Rect snapshot_bounds( |
piman
2012/12/12 23:59:50
nit: this should work:
gfx::Rect snapshot_bounds(v
|
+ 0, 0, view_bounds.width(), view_bounds.height()); |
+ |
+ snapshot_size.SetSize(snapshot_bounds.width(), |
piman
2012/12/12 23:59:50
nit: snapshot_size = snapshot_bounds.size();
Even
|
+ snapshot_bounds.height()); |
+ |
+ if (ui::GrabViewSnapshot(GetView()->GetNativeView(), |
+ &png, snapshot_bounds)) { |
piman
2012/12/12 23:59:50
nit: arguments should align in function call:
|
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), snapshot_id, snapshot_size, png)); |
+ return; |
+ } |
+ } |
+ |
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), snapshot_id, gfx::Size(), png)); |
+} |
+ |
} // namespace content |