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

Side by Side 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 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
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG); 905 ReportUserActionHistogram(FALLBACK_TO_ADVANCED_SETTINGS_DIALOG);
906 } else { 906 } else {
907 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count); 907 UMA_HISTOGRAM_COUNTS("PrintPreview.PageCount.PrintToPrinter", page_count);
908 ReportUserActionHistogram(PRINT_TO_PRINTER); 908 ReportUserActionHistogram(PRINT_TO_PRINTER);
909 } 909 }
910 910
911 // This tries to activate the initiator as well, so do not clear the 911 // This tries to activate the initiator as well, so do not clear the
912 // association with the initiator yet. 912 // association with the initiator yet.
913 print_preview_ui()->OnHidePreviewDialog(); 913 print_preview_ui()->OnHidePreviewDialog();
914 914
915 // Grab the current initiator before calling ClearInitiatorDetails() below.
916 // Otherwise calling GetInitiator() later will return the wrong WebContents.
917 // https://crbug.com/407080
918 WebContents* initiator = GetInitiator();
919 if (initiator) {
920 // Save initiator IDs. PrintMsg_PrintForPrintPreview below should cause
921 // the renderer to send PrintHostMsg_UpdatePrintSettings and trigger
922 // PrintingMessageFilter::OnUpdatePrintSettings(), which needs this info.
923 auto* main_render_frame = initiator->GetMainFrame();
924 settings->SetInteger(printing::kPreviewInitiatorHostId,
925 main_render_frame->GetProcess()->GetID());
926 settings->SetInteger(printing::kPreviewInitiatorRoutingId,
927 main_render_frame->GetRoutingID());
928 }
929
915 // Do this so the initiator can open a new print preview dialog, while the 930 // Do this so the initiator can open a new print preview dialog, while the
916 // current print preview dialog is still handling its print job. 931 // current print preview dialog is still handling its print job.
917 WebContents* initiator = GetInitiator();
918 if (initiator) {
919 // Save initiator IDs. |PrintingMessageFilter::OnUpdatePrintSettings|
920 // would be called when initiator info is cleared.
921 settings->SetInteger(printing::kPreviewInitiatorHostId,
922 initiator->GetRenderProcessHost()->GetID());
923 settings->SetInteger(printing::kPreviewInitiatorRoutingId,
924 initiator->GetRoutingID());
925 }
926
927 ClearInitiatorDetails(); 932 ClearInitiatorDetails();
928 933
929 // The PDF being printed contains only the pages that the user selected, 934 // The PDF being printed contains only the pages that the user selected,
930 // so ignore the page range and print all pages. 935 // so ignore the page range and print all pages.
931 settings->Remove(printing::kSettingPageRange, NULL); 936 settings->Remove(printing::kSettingPageRange, nullptr);
932 // Reset selection only flag for the same reason. 937 // Reset selection only flag for the same reason.
933 settings->SetBoolean(printing::kSettingShouldPrintSelectionOnly, false); 938 settings->SetBoolean(printing::kSettingShouldPrintSelectionOnly, false);
934 939
935 // Set ID to know whether printing is for preview. 940 // Set ID to know whether printing is for preview.
936 settings->SetInteger(printing::kPreviewUIID, 941 settings->SetInteger(printing::kPreviewUIID,
937 print_preview_ui()->GetIDForPrintPreviewUI()); 942 print_preview_ui()->GetIDForPrintPreviewUI());
938 RenderFrameHost* rfh = preview_web_contents()->GetMainFrame(); 943 RenderFrameHost* rfh = preview_web_contents()->GetMainFrame();
939 rfh->Send( 944 rfh->Send(
940 new PrintMsg_PrintForPrintPreview(rfh->GetRoutingID(), *settings)); 945 new PrintMsg_PrintForPrintPreview(rfh->GetRoutingID(), *settings));
941 946
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 1702
1698 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { 1703 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() {
1699 if (gaia_cookie_manager_service_) 1704 if (gaia_cookie_manager_service_)
1700 gaia_cookie_manager_service_->RemoveObserver(this); 1705 gaia_cookie_manager_service_->RemoveObserver(this);
1701 } 1706 }
1702 1707
1703 void PrintPreviewHandler::SetPdfSavedClosureForTesting( 1708 void PrintPreviewHandler::SetPdfSavedClosureForTesting(
1704 const base::Closure& closure) { 1709 const base::Closure& closure) {
1705 pdf_file_saved_closure_ = closure; 1710 pdf_file_saved_closure_ = closure;
1706 } 1711 }
OLDNEW
« 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