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 007de7fe5862f02dcc13dc4bf4eaf54b82d13fa0..2951048b8ff2e82cc1d9d5f041afadb4be5a97c2 100644 |
--- a/content/browser/renderer_host/render_view_host_impl.cc |
+++ b/content/browser/renderer_host/render_view_host_impl.cc |
@@ -63,6 +63,7 @@ |
#include "net/url_request/url_request_context_getter.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
#include "ui/base/dialogs/selected_file_info.h" |
+#include "ui/base/snapshot/snapshot.h" |
#include "ui/gfx/image/image_skia.h" |
#include "ui/gfx/native_widget_types.h" |
#include "webkit/fileapi/isolated_context.h" |
@@ -1027,6 +1028,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, |
@@ -2032,4 +2034,31 @@ void RenderViewHostImpl::ClearPowerSaveBlockers() { |
STLDeleteValues(&power_save_blockers_); |
} |
+void RenderViewHostImpl::OnGetWindowSnapshot(const int id) { |
Ken Russell (switch to Gerrit)
2012/11/30 22:32:54
id -> 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 |
Ken Russell (switch to Gerrit)
2012/11/30 22:32:54
Please add period at end of comment.
|
+ 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( |
+ 0, 0, view_bounds.width(), view_bounds.height()); |
+ |
+ snapshot_size.SetSize(snapshot_bounds.width(), |
+ snapshot_bounds.height()); |
+ |
+ if (ui::GrabViewSnapshot(GetView()->GetNativeView(), |
+ &png, snapshot_bounds)) { |
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), id, snapshot_size, png)); |
+ return; |
+ } |
+ } |
+ |
+ Send(new ViewMsg_WindowSnapshotCompleted( |
+ GetRoutingID(), id, gfx::Size(), png)); |
+} |
+ |
} // namespace content |