Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1730)

Unified Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 11399002: Implemented GetWindowSnapshot on RenderViewImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698