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

Side by Side 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: Fixed aura snapshot circular dependency Created 8 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 body_background_color_(SK_ColorWHITE), 591 body_background_color_(SK_ColorWHITE),
592 update_frame_info_scheduled_(false), 592 update_frame_info_scheduled_(false),
593 expected_content_intent_id_(0), 593 expected_content_intent_id_(0),
594 media_player_proxy_(NULL), 594 media_player_proxy_(NULL),
595 synchronous_find_active_match_ordinal_(-1), 595 synchronous_find_active_match_ordinal_(-1),
596 ALLOW_THIS_IN_INITIALIZER_LIST( 596 ALLOW_THIS_IN_INITIALIZER_LIST(
597 load_progress_tracker_(new LoadProgressTracker(this))), 597 load_progress_tracker_(new LoadProgressTracker(this))),
598 #endif 598 #endif
599 session_storage_namespace_id_(params->session_storage_namespace_id), 599 session_storage_namespace_id_(params->session_storage_namespace_id),
600 handling_select_range_(false), 600 handling_select_range_(false),
601 next_snapshot_id_(0),
601 #if defined(OS_WIN) 602 #if defined(OS_WIN)
602 focused_plugin_id_(-1), 603 focused_plugin_id_(-1),
603 #endif 604 #endif
604 updating_frame_tree_(false), 605 updating_frame_tree_(false),
605 pending_frame_tree_update_(false), 606 pending_frame_tree_update_(false),
606 target_process_id_(0), 607 target_process_id_(0),
607 target_routing_id_(0), 608 target_routing_id_(0),
608 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { 609 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) {
609 set_throttle_input_events(params->renderer_prefs.throttle_input_events); 610 set_throttle_input_events(params->renderer_prefs.throttle_input_events);
610 routing_id_ = params->routing_id; 611 routing_id_ = params->routing_id;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) 1012 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard)
1012 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, 1013 IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted,
1013 OnPluginImeCompositionCompleted) 1014 OnPluginImeCompositionCompleted)
1014 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) 1015 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
1015 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) 1016 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize)
1016 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) 1017 IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility)
1017 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) 1018 IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged)
1018 #endif 1019 #endif
1019 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB, 1020 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB,
1020 OnReleaseDisambiguationPopupDIB) 1021 OnReleaseDisambiguationPopupDIB)
1022 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted,
1023 OnWindowSnapshotCompleted)
1021 1024
1022 // Have the super handle all other messages. 1025 // Have the super handle all other messages.
1023 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) 1026 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
1024 IPC_END_MESSAGE_MAP() 1027 IPC_END_MESSAGE_MAP()
1025 1028
1026 if (!msg_is_ok) { 1029 if (!msg_is_ok) {
1027 // The message had a handler, but its deserialization failed. 1030 // The message had a handler, but its deserialization failed.
1028 // Kill the renderer to avoid potential spoofing attacks. 1031 // Kill the renderer to avoid potential spoofing attacks.
1029 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; 1032 CHECK(false) << "Unable to deserialize message in RenderViewImpl.";
1030 } 1033 }
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog 1728 // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog
1726 // it is particularly important that we do not call willEnterModalLoop as 1729 // it is particularly important that we do not call willEnterModalLoop as
1727 // that would defer resource loads for the dialog itself. 1730 // that would defer resource loads for the dialog itself.
1728 if (RenderThreadImpl::current()) // Will be NULL during unit tests. 1731 if (RenderThreadImpl::current()) // Will be NULL during unit tests.
1729 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); 1732 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop();
1730 1733
1731 message->EnableMessagePumping(); // Runs a nested message loop. 1734 message->EnableMessagePumping(); // Runs a nested message loop.
1732 return Send(message); 1735 return Send(message);
1733 } 1736 }
1734 1737
1738 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) {
1739 int id = next_snapshot_id_++;
1740 pending_snapshots_.insert(std::make_pair(id, callback));
1741 Send(new ViewHostMsg_GetWindowSnapshot(routing_id_, id));
1742 }
1743
1744 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id,
1745 const gfx::Size& size, const std::vector<unsigned char>& png) {
1746 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id);
1747 DCHECK(it != pending_snapshots_.end());
1748 it->second.Run(size, png);
1749 pending_snapshots_.erase(it);
1750 }
1751
1735 // WebKit::WebViewClient ------------------------------------------------------ 1752 // WebKit::WebViewClient ------------------------------------------------------
1736 1753
1737 WebView* RenderViewImpl::createView( 1754 WebView* RenderViewImpl::createView(
1738 WebFrame* creator, 1755 WebFrame* creator,
1739 const WebURLRequest& request, 1756 const WebURLRequest& request,
1740 const WebWindowFeatures& features, 1757 const WebWindowFeatures& features,
1741 const WebString& frame_name, 1758 const WebString& frame_name,
1742 WebNavigationPolicy policy) { 1759 WebNavigationPolicy policy) {
1743 // Check to make sure we aren't overloading on popups. 1760 // Check to make sure we aren't overloading on popups.
1744 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) 1761 if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups)
(...skipping 4682 matching lines...) Expand 10 before | Expand all | Expand 10 after
6427 } 6444 }
6428 #endif 6445 #endif
6429 6446
6430 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( 6447 void RenderViewImpl::OnReleaseDisambiguationPopupDIB(
6431 TransportDIB::Handle dib_handle) { 6448 TransportDIB::Handle dib_handle) {
6432 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); 6449 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle);
6433 RenderProcess::current()->ReleaseTransportDIB(dib); 6450 RenderProcess::current()->ReleaseTransportDIB(dib);
6434 } 6451 }
6435 6452
6436 } // namespace content 6453 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698