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

Unified Diff: chrome/renderer/render_view.cc

Issue 6142013: Allow printing/saving a plugin through right click menu, even if it's in a fr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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
« no previous file with comments | « chrome/renderer/render_view.h ('k') | ui/base/models/menu_model.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 71495)
+++ chrome/renderer/render_view.cc (working copy)
@@ -981,6 +981,9 @@
IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot)
IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone)
+ IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview)
+ IPC_MESSAGE_HANDLER(ViewMsg_PrintNodeUnderContextMenu,
+ OnPrintNodeUnderContextMenu)
IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame)
@@ -1109,9 +1112,9 @@
#if defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem)
#endif
- IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview)
IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl,
OnJavaScriptStressTestControl)
+ IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed)
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
@@ -1193,6 +1196,18 @@
}
}
+void RenderView::OnPrintNodeUnderContextMenu() {
+ if (context_menu_node_.isNull()) {
+ NOTREACHED();
+ return;
+ }
+
+ // Make a copy of the node, since we will do a sync call to the browser and
+ // during that time OnContextMenuClosed might reset context_menu_node_.
+ WebNode context_menu_node(context_menu_node_);
+ GetPrintWebViewHelper()->PrintNode(&context_menu_node, false, false);
+}
+
void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) {
if (load_id != page_id_)
return; // this capture call is no longer relevant due to navigation
@@ -2513,6 +2528,7 @@
// data encoded images. We should have a way to save them.
if (params.src_url.spec().size() > chrome::kMaxURLChars)
params.src_url = GURL();
+ context_menu_node_ = data.node;
Send(new ViewHostMsg_ContextMenu(routing_id_, params));
}
@@ -5410,10 +5426,13 @@
bool script_initiated,
bool is_preview) {
DCHECK(frame);
- if (print_helper_.get() == NULL) {
+ GetPrintWebViewHelper()->PrintFrame(frame, script_initiated, is_preview);
+}
+
+PrintWebViewHelper* RenderView::GetPrintWebViewHelper() {
+ if (print_helper_.get() == NULL)
print_helper_.reset(new PrintWebViewHelper(this));
- }
- print_helper_->Print(frame, script_initiated, is_preview);
+ return print_helper_.get();
}
void RenderView::OnSetEditCommandsForNextKeyEvent(
@@ -5803,3 +5822,7 @@
v8::Testing::PrepareStressRun(param);
}
}
+
+void RenderView::OnContextMenuClosed() {
+ context_menu_node_.reset();
+}
« no previous file with comments | « chrome/renderer/render_view.h ('k') | ui/base/models/menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698