Chromium Code Reviews| 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 30748c09d3bf48d958bc2a95a5d2970686fa748c..f96809afcb4390ce9b7add4d3b7adbf9b9730efb 100644 |
| --- a/content/browser/renderer_host/render_view_host_impl.cc |
| +++ b/content/browser/renderer_host/render_view_host_impl.cc |
| @@ -52,6 +52,7 @@ |
| #include "content/public/browser/notification_types.h" |
| #include "content/public/browser/render_view_host_observer.h" |
| #include "content/public/browser/user_metrics.h" |
| +#include "content/public/browser/window_util.h" |
| #include "content/public/common/bindings_policy.h" |
| #include "content/public/common/content_constants.h" |
| #include "content/public/common/content_switches.h" |
| @@ -1029,6 +1030,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, OnMsgGetWindowSnapshot) |
| #if defined(OS_ANDROID) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_StartContentIntent, OnStartContentIntent) |
| IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeBodyBackgroundColor, |
| @@ -2035,4 +2037,29 @@ void RenderViewHostImpl::ClearPowerSaveBlockers() { |
| STLDeleteValues(&power_save_blockers_); |
| } |
| +void RenderViewHostImpl::OnMsgGetWindowSnapshot(const int id) { |
| + std::vector<unsigned char> png; |
|
jam
2012/11/09 02:21:29
nit: 2 space tabbing per style guide
|
| + |
| + 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 (content::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 |