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

Unified Diff: content/renderer/render_view_impl.cc

Issue 11399002: Implemented GetWindowSnapshot on RenderViewImpl (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressing nits 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/renderer/render_view_impl.cc
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 1f4f09a375ac137b870fe2f71e76ea5e84dbcdff..24249205f84395796f8fc9e6c0570dcdf01a78d8 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -598,6 +598,7 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params)
#endif
session_storage_namespace_id_(params->session_storage_namespace_id),
handling_select_range_(false),
+ next_snapshot_id_(0),
#if defined(OS_WIN)
focused_plugin_id_(-1),
#endif
@@ -1018,6 +1019,8 @@ bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
#endif
IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB,
OnReleaseDisambiguationPopupDIB)
+ IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
+ OnWindowSnapshotCompleted)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
@@ -1732,6 +1735,20 @@ bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) {
return Send(message);
}
+void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) {
+ int id = next_snapshot_id_++;
+ pending_snapshots_.insert(std::make_pair(id, callback));
+ Send(new ViewHostMsg_GetWindowSnapshot(routing_id_, id));
+}
+
+void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id,
+ const gfx::Size& size, const std::vector<unsigned char>& png) {
+ PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id);
+ DCHECK(it != pending_snapshots_.end());
+ it->second.Run(size, png);
+ pending_snapshots_.erase(it);
+}
+
// WebKit::WebViewClient ------------------------------------------------------
WebView* RenderViewImpl::createView(

Powered by Google App Engine
This is Rietveld 408576698