Commit 3764d52b authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Remove printing::PrintingPdfContent().

PrintingPdfContent() uses URLs to figure out if the content to be
printed is PDF or not. This does not work when printing Flash content.
Go back to checking PrintSettings::is_modifiable(), which already works
correctly on Mac. On Windows and Linux, the "is modifiable" setting
needs to be preserved when getting settings from the user in the native
print dialog.

BUG=859481

Change-Id: I674cf3c0f38b87c17fb6d2ca30ebae842c260d8c
Reviewed-on: https://chromium-review.googlesource.com/1146024Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577712}
parent 7e956395
...@@ -316,7 +316,7 @@ void PrintViewManagerBase::OnDidPrintDocument( ...@@ -316,7 +316,7 @@ void PrintViewManagerBase::OnDidPrintDocument(
} }
auto* client = PrintCompositeClient::FromWebContents(web_contents()); auto* client = PrintCompositeClient::FromWebContents(web_contents());
if (IsOopifEnabled() && !PrintingPdfContent(render_frame_host)) { if (IsOopifEnabled() && print_job_->document()->settings().is_modifiable()) {
client->DoCompositeDocumentToPdf( client->DoCompositeDocumentToPdf(
params.document_cookie, render_frame_host, content.metafile_data_handle, params.document_cookie, render_frame_host, content.metafile_data_handle,
content.data_size, content.subframe_content_info, content.data_size, content.subframe_content_info,
......
...@@ -4,12 +4,9 @@ ...@@ -4,12 +4,9 @@
#include "chrome/browser/printing/print_view_manager_common.h" #include "chrome/browser/printing/print_view_manager_common.h"
#include "chrome/common/webui_url_constants.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "extensions/buildflags/buildflags.h" #include "extensions/buildflags/buildflags.h"
#include "extensions/common/constants.h"
#include "printing/buildflags/buildflags.h" #include "printing/buildflags/buildflags.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_EXTENSIONS) #if BUILDFLAG(ENABLE_EXTENSIONS)
#include "components/guest_view/browser/guest_view_manager.h" #include "components/guest_view/browser/guest_view_manager.h"
...@@ -120,12 +117,4 @@ content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents) { ...@@ -120,12 +117,4 @@ content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents) {
: contents->GetMainFrame(); : contents->GetMainFrame();
} }
bool PrintingPdfContent(content::RenderFrameHost* rfh) {
GURL url = rfh->GetLastCommittedURL();
// Whether it is inside print preview or pdf plugin extension.
return url.GetOrigin() == chrome::kChromeUIPrintURL ||
(url.SchemeIs(extensions::kExtensionScheme) &&
url.host_piece() == extension_misc::kPdfExtensionId);
}
} // namespace printing } // namespace printing
...@@ -26,13 +26,6 @@ void StartBasicPrint(content::WebContents* contents); ...@@ -26,13 +26,6 @@ void StartBasicPrint(content::WebContents* contents);
// frame (this makes print selection work for multiple frames). // frame (this makes print selection work for multiple frames).
content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents); content::RenderFrameHost* GetFrameToPrint(content::WebContents* contents);
// Whether the content sent to |rfh| is in PDF format.
// When print preview dialog is printed, the content returned is always
// in PDF format because print preview already stores the PDF file for
// the previewed web page; When a full page PDF plugin is printed, the document
// in it is in PDF format so will return in PDF also.
bool PrintingPdfContent(content::RenderFrameHost* rfh);
} // namespace printing } // namespace printing
#endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_COMMON_H_ #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_COMMON_H_
...@@ -475,6 +475,7 @@ void PrintDialogGtk2::OnResponse(GtkWidget* dialog, int response_id) { ...@@ -475,6 +475,7 @@ void PrintDialogGtk2::OnResponse(GtkWidget* dialog, int response_id) {
} }
PrintSettings settings; PrintSettings settings;
settings.set_is_modifiable(context_->settings().is_modifiable());
settings.set_ranges(ranges_vector); settings.set_ranges(ranges_vector);
settings.set_selection_only(print_selection_only); settings.set_selection_only(print_selection_only);
InitPrintSettingsGtk(gtk_settings_, page_setup_, &settings); InitPrintSettingsGtk(gtk_settings_, page_setup_, &settings);
......
...@@ -143,9 +143,11 @@ PrintingContext::Result PrintingContextSystemDialogWin::ParseDialogResultEx( ...@@ -143,9 +143,11 @@ PrintingContext::Result PrintingContextSystemDialogWin::ParseDialogResultEx(
const PRINTDLGEX& dialog_options) { const PRINTDLGEX& dialog_options) {
// If the user clicked OK or Apply then Cancel, but not only Cancel. // If the user clicked OK or Apply then Cancel, but not only Cancel.
if (dialog_options.dwResultAction != PD_RESULT_CANCEL) { if (dialog_options.dwResultAction != PD_RESULT_CANCEL) {
// Start fresh, but preserve GDI print setting. // Start fresh, but preserve is_modifiable and GDI print setting.
bool is_modifiable = settings_.is_modifiable();
bool print_text_with_gdi = settings_.print_text_with_gdi(); bool print_text_with_gdi = settings_.print_text_with_gdi();
ResetSettings(); ResetSettings();
settings_.set_is_modifiable(is_modifiable);
settings_.set_print_text_with_gdi(print_text_with_gdi); settings_.set_print_text_with_gdi(print_text_with_gdi);
DEVMODE* dev_mode = NULL; DEVMODE* dev_mode = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment