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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 2527913002: Fix one more RenderFrame/RenderView ID mixup in printing code. (Closed)
Patch Set: put back PrintingMessageFilter::OnUpdatePrintSettings code Created 4 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
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/print_preview/print_preview_handler.cc
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index 77af2c319ef74b84ccfb2a5ad9962968fff29f58..de2fc1255d17e2a97ba53f2257c88a3671bd04f6 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -912,23 +912,28 @@ void PrintPreviewHandler::HandlePrint(const base::ListValue* args) {
// association with the initiator yet.
print_preview_ui()->OnHidePreviewDialog();
- // Do this so the initiator can open a new print preview dialog, while the
- // current print preview dialog is still handling its print job.
+ // Grab the current initiator before calling ClearInitiatorDetails() below.
+ // Otherwise calling GetInitiator() later will return the wrong WebContents.
+ // https://crbug.com/407080
WebContents* initiator = GetInitiator();
if (initiator) {
- // Save initiator IDs. |PrintingMessageFilter::OnUpdatePrintSettings|
- // would be called when initiator info is cleared.
+ // Save initiator IDs. PrintMsg_PrintForPrintPreview below should cause
+ // the renderer to send PrintHostMsg_UpdatePrintSettings and trigger
+ // PrintingMessageFilter::OnUpdatePrintSettings(), which needs this info.
+ auto* main_render_frame = initiator->GetMainFrame();
settings->SetInteger(printing::kPreviewInitiatorHostId,
- initiator->GetRenderProcessHost()->GetID());
+ main_render_frame->GetProcess()->GetID());
settings->SetInteger(printing::kPreviewInitiatorRoutingId,
- initiator->GetRoutingID());
+ main_render_frame->GetRoutingID());
}
+ // Do this so the initiator can open a new print preview dialog, while the
+ // current print preview dialog is still handling its print job.
ClearInitiatorDetails();
// The PDF being printed contains only the pages that the user selected,
// so ignore the page range and print all pages.
- settings->Remove(printing::kSettingPageRange, NULL);
+ settings->Remove(printing::kSettingPageRange, nullptr);
// Reset selection only flag for the same reason.
settings->SetBoolean(printing::kSettingShouldPrintSelectionOnly, false);
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698