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

Unified Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 12177009: Printing selection from context menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
Index: chrome/renderer/printing/print_web_view_helper.cc
diff --git a/chrome/renderer/printing/print_web_view_helper.cc b/chrome/renderer/printing/print_web_view_helper.cc
index d9a5cd79ef509c466e68112439e74d7e1de0588e..c41839bbd6e47d46b0ac5e5e81c760f25c496aa0 100644
--- a/chrome/renderer/printing/print_web_view_helper.cc
+++ b/chrome/renderer/printing/print_web_view_helper.cc
@@ -1106,12 +1106,14 @@ void PrintWebViewHelper::OnPrintNodeUnderContextMenu() {
PrintNode(render_view()->GetContextMenuNode());
}
-void PrintWebViewHelper::OnInitiatePrintPreview() {
+void PrintWebViewHelper::OnInitiatePrintPreview(bool selection_only) {
DCHECK(is_preview_enabled_);
WebKit::WebFrame* frame;
if (GetPrintFrame(&frame)) {
print_preview_context_.InitWithFrame(frame);
- RequestPrintPreview(PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME);
+ RequestPrintPreview(selection_only ?
+ PRINT_PREVIEW_USER_INITIATED_SELECTION :
+ PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME);
} else {
// This should not happen. Let's add a CHECK here to see how often this
// gets hit.
@@ -1577,22 +1579,27 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) {
const bool is_modifiable = print_preview_context_.IsModifiable();
const bool has_selection = print_preview_context_.HasSelection();
old_print_pages_params_.reset();
+ PrintHostMsg_RequestPrintPreview_Params params;
+ params.is_modifiable = is_modifiable;
+ params.has_selection = has_selection;
switch (type) {
- case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: {
- Send(new PrintHostMsg_RequestPrintPreview(routing_id(), is_modifiable,
- false, has_selection));
- break;
- }
- case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: {
- Send(new PrintHostMsg_RequestPrintPreview(routing_id(), is_modifiable,
- true, has_selection));
- break;
- }
case PRINT_PREVIEW_SCRIPTED: {
IPC::SyncMessage* msg =
new PrintHostMsg_ScriptedPrintPreview(routing_id(), is_modifiable);
msg->EnableMessagePumping();
Send(msg);
+ return;
+ }
+ case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: {
+ break;
+ }
+ case PRINT_PREVIEW_USER_INITIATED_SELECTION: {
+ DCHECK(has_selection);
+ params.selection_only = has_selection;
+ break;
+ }
+ case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: {
+ params.webnode_only = true;
break;
}
default: {
@@ -1600,6 +1607,7 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) {
return;
}
}
+ Send(new PrintHostMsg_RequestPrintPreview(routing_id(), params));
}
bool PrintWebViewHelper::CheckForCancel() {
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | chrome/renderer/printing/print_web_view_helper_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698