Skip to content

Commit

Permalink
Removed print_web_view_helper_win.cc
Browse files Browse the repository at this point in the history
Removed win_pdf_metafile_for_printing gyp option.
Removed WIN_PDF_METAFILE_FOR_PRINTING define.

BUG=170859
TBR=yzshen

Review URL: https://codereview.chromium.org/516823002

Cr-Commit-Position: refs/heads/master@{#292501}
  • Loading branch information
vitalybuka authored and Commit bot committed Aug 28, 2014
1 parent 60a5bf4 commit 36259ca
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 383 deletions.
7 changes: 0 additions & 7 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,6 @@
# print, UI, etc.
'enable_printing%': 1,

# Windows prints using a PDF as the metafile from the renderer.
'win_pdf_metafile_for_printing%': 1,

# Set the version of CLD.
# 0: Don't specify the version. This option is for the Finch testing.
# 1: Use only CLD1.
Expand Down Expand Up @@ -1155,7 +1152,6 @@
'test_isolation_outdir%': '<(test_isolation_outdir)',
'test_isolation_fail_on_missing': '<(test_isolation_fail_on_missing)',
'enable_printing%': '<(enable_printing)',
'win_pdf_metafile_for_printing%': '<(win_pdf_metafile_for_printing)',
'enable_spellcheck%': '<(enable_spellcheck)',
'enable_google_now%': '<(enable_google_now)',
'cld_version%': '<(cld_version)',
Expand Down Expand Up @@ -2862,9 +2858,6 @@
['enable_printing==2', {
'defines': ['ENABLE_PRINTING=1'],
}],
['OS=="win" and win_pdf_metafile_for_printing==1', {
'defines': ['WIN_PDF_METAFILE_FOR_PRINTING=1'],
}],
['enable_spellcheck==1', {
'defines': ['ENABLE_SPELLCHECK=1'],
}],
Expand Down
3 changes: 0 additions & 3 deletions build/config/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ config("feature_flags") {
if (enable_themes) {
defines += [ "ENABLE_THEMES=1" ]
}
if (is_win && win_pdf_metafile_for_printing) {
defines += [ "WIN_PDF_METAFILE_FOR_PRINTING=1" ]
}
if (enable_captive_portal_detection) {
defines += [ "ENABLE_CAPTIVE_PORTAL_DETECTION=1" ]
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ static_library("browser") {
deps += [
"//printing",
]
if (is_win && win_pdf_metafile_for_printing) {
if (is_win) {
sources += rebase_path(gypi_values.chrome_browser_printing_emf_sources,
".", "//chrome")
}
Expand Down
55 changes: 13 additions & 42 deletions chrome/browser/printing/print_view_manager_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
#include "chrome/browser/printing/print_error_dialog.h"
#endif

#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "chrome/browser/printing/pdf_to_emf_converter.h"
#include "printing/emf_win.h"
#include "printing/pdf_render_settings.h"
#endif

Expand All @@ -47,11 +48,6 @@ namespace printing {

namespace {

#if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
// Limits memory usage by raster to 64 MiB.
const int kMaxRasterSizeInPixels = 16*1024*1024;
#endif

} // namespace

PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
Expand All @@ -62,10 +58,9 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
cookie_(0),
queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_.get());
#if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if !defined(OS_MACOSX)
expecting_first_page_ = true;
#endif
#endif // OS_MACOSX
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
printing_enabled_.Init(
Expand Down Expand Up @@ -129,7 +124,7 @@ void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) {
cookie_ = cookie;
}

#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
void PrintViewManagerBase::OnPdfToEmfConverted(
const PrintHostMsg_DidPrintPage_Params& params,
double scale_factor,
Expand Down Expand Up @@ -158,7 +153,7 @@ void PrintViewManagerBase::OnPdfToEmfConverted(

ShouldQuitFromInnerMessageLoop();
}
#endif // WIN_PDF_METAFILE_FOR_PRINTING
#endif // OS_WIN

void PrintViewManagerBase::OnDidPrintPage(
const PrintHostMsg_DidPrintPage_Params& params) {
Expand All @@ -172,13 +167,12 @@ void PrintViewManagerBase::OnDidPrintPage(
return;
}

#if (defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)) || \
defined(OS_MACOSX)
#if defined(OS_MACOSX)
const bool metafile_must_be_valid = true;
#elif defined(OS_POSIX) || defined(WIN_PDF_METAFILE_FOR_PRINTING)
#else
const bool metafile_must_be_valid = expecting_first_page_;
expecting_first_page_ = false;
#endif
#endif // OS_MACOSX

base::SharedMemory shared_buf(params.metafile_data_handle, true);
if (metafile_must_be_valid) {
Expand All @@ -198,32 +192,10 @@ void PrintViewManagerBase::OnDidPrintPage(
}
}

#if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
bool big_emf = (params.data_size && params.data_size >= kMetafileMaxSize);
int raster_size =
std::min(params.page_size.GetArea(), kMaxRasterSizeInPixels);
if (big_emf) {
scoped_ptr<NativeMetafile> raster_metafile(
metafile->RasterizeMetafile(raster_size));
if (raster_metafile.get()) {
metafile.swap(raster_metafile);
} else if (big_emf) {
// Don't fall back to emf here.
NOTREACHED() << "size:" << params.data_size;
TerminatePrintJob(true);
web_contents()->Stop();
return;
}
}
#endif // OS_WIN && !WIN_PDF_METAFILE_FOR_PRINTING

#if !defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if !defined(OS_WIN)
// Update the rendered document. It will send notifications to the listener.
document->SetPage(params.page_number,
metafile.release(),
#if defined(OS_WIN)
params.actual_shrink,
#endif // OS_WIN
params.page_size,
params.content_area);

Expand All @@ -247,7 +219,7 @@ void PrintViewManagerBase::OnDidPrintPage(
base::Unretained(this),
params));
}
#endif // !WIN_PDF_METAFILE_FOR_PRINTING
#endif // !OS_WIN
}

void PrintViewManagerBase::OnPrintingFailed(int cookie) {
Expand Down Expand Up @@ -454,10 +426,9 @@ void PrintViewManagerBase::DisconnectFromCurrentPrintJob() {
// DO NOT wait for the job to finish.
ReleasePrintJob();
}
#if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if !defined(OS_MACOSX)
expecting_first_page_ = true;
#endif
#endif // OS_MACOSX
}

void PrintViewManagerBase::PrintingDone(bool success) {
Expand Down
13 changes: 6 additions & 7 deletions chrome/browser/printing/print_view_manager_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ class PrintViewManagerBase : public content::NotificationObserver,
// Release the PrinterQuery associated with our |cookie_|.
void ReleasePrinterQuery();

#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
// Called on completion of converting the pdf to emf.
void OnPdfToEmfConverted(const PrintHostMsg_DidPrintPage_Params& params,
double scale_factor,
const std::vector<base::FilePath>& emf_file);
#endif
#endif // OS_WIN

content::NotificationRegistrar registrar_;

Expand All @@ -154,15 +154,14 @@ class PrintViewManagerBase : public content::NotificationObserver,
// print settings are being loaded.
bool inside_inner_message_loop_;

#if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \
defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if !defined(OS_MACOSX)
// Set to true when OnDidPrintPage() should be expecting the first page.
bool expecting_first_page_;
#endif
#endif // OS_MACOSX

#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
scoped_ptr<PdfToEmfConverter> pdf_to_emf_converter_;
#endif
#endif // OS_WIN

// The document cookie of the current PrinterQuery.
int cookie_;
Expand Down
2 changes: 1 addition & 1 deletion chrome/chrome_browser.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -3213,7 +3213,7 @@
],
'sources': [ '<@(chrome_browser_basic_printing_sources)' ],
'conditions': [
['OS=="win" and win_pdf_metafile_for_printing==1', {
['OS=="win"', {
'sources': [ '<@(chrome_browser_printing_emf_sources)' ],
}],
# Full printing on top of the above.
Expand Down
10 changes: 1 addition & 9 deletions chrome/chrome_renderer.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@
'renderer/printing/print_web_view_helper_android.cc',
'renderer/printing/print_web_view_helper_linux.cc',
'renderer/printing/print_web_view_helper_mac.mm',
'renderer/printing/print_web_view_helper_pdf_win.cc',
],
'chrome_renderer_full_printing_sources': [
'renderer/pepper/chrome_pdf_print_client.cc',
Expand Down Expand Up @@ -390,15 +391,6 @@
'<@(chrome_renderer_full_printing_sources)',
],
}],
['win_pdf_metafile_for_printing==1', {
'sources': [
'renderer/printing/print_web_view_helper_pdf_win.cc',
],
}, {
'sources': [
'renderer/printing/print_web_view_helper_win.cc',
],
}],
['OS!="android"', {
'sources': [
'<@(chrome_renderer_non_android_sources)',
Expand Down
9 changes: 4 additions & 5 deletions chrome/common/chrome_utility_printing_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
std::string /* printer name */)


#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
// Tell the utility process to render the given PDF into a metafile.
// The metafile path will have ".%d" inserted where the %d is the page number.
// If no page range is specified, all pages will be converted.
Expand All @@ -95,7 +94,7 @@ IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
base::FilePath, // Base location for output metafile
printing::PdfRenderSettings, // PDF render settings
std::vector<printing::PageRange>)
#endif
#endif // OS_WIN

//------------------------------------------------------------------------------
// Utility process host messages:
Expand Down Expand Up @@ -131,12 +130,12 @@ IPC_MESSAGE_CONTROL1(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
std::string /* printer name */)

#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
#if defined(OS_WIN)
// Reply when the utility process has succeeded in rendering the PDF.
IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded,
std::vector<printing::PageRange>, // Pages rendered
double) // Scale factor

// Reply when an error occurred rendering the PDF.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed)
#endif
#endif // OS_WIN
5 changes: 0 additions & 5 deletions chrome/common/print_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,6 @@ IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
// Page number.
IPC_STRUCT_MEMBER(int, page_number)

#if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
// Shrink factor used to render this page.
IPC_STRUCT_MEMBER(double, actual_shrink)
#endif // OS_WIN && !WIN_PDF_METAFILE_FOR_PRINTING

// The size of the page the page author specified.
IPC_STRUCT_MEMBER(gfx::Size, page_size)

Expand Down
6 changes: 0 additions & 6 deletions chrome/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ static_library("renderer") {
}

# TODO(GYP)
# ['win_pdf_metafile_for_printing==1', {
# 'sources': [
# 'renderer/printing/print_web_view_helper_pdf_win.cc',
# ],
# }, {
# 'sources': [
# 'renderer/printing/print_web_view_helper_win.cc',
# ],
# }],
}
5 changes: 2 additions & 3 deletions chrome/renderer/printing/print_web_view_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,7 @@ void PrintWebViewHelper::FinishFramePrinting() {
prep_frame_view_.reset();
}

#if defined(OS_MACOSX) || \
(defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING))
#if defined(OS_MACOSX)
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
int page_count,
const gfx::Size& canvas_size) {
Expand All @@ -1366,7 +1365,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
return true;
}

#endif // OS_MACOSX || !WIN_PDF_METAFILE_FOR_PRINTING
#endif // OS_MACOSX

// static - Not anonymous so that platform implementations can use it.
void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
Expand Down
15 changes: 3 additions & 12 deletions chrome/renderer/printing/print_web_view_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class PrintWebViewHelper
const gfx::Size& canvas_size,
blink::WebFrame* frame,
Metafile* metafile);
#elif defined(WIN_PDF_METAFILE_FOR_PRINTING)
#elif defined(OS_WIN)
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
const gfx::Size& canvas_size,
blink::WebFrame* frame,
Expand All @@ -227,24 +227,15 @@ class PrintWebViewHelper
const blink::WebNode& node);

// Platform specific helper function for rendering page(s) to |metafile|.
#if defined(OS_WIN) && !defined(WIN_PDF_METAFILE_FOR_PRINTING)
void RenderPage(const PrintMsg_Print_Params& params,
int page_number,
blink::WebFrame* frame,
bool is_preview,
Metafile* metafile,
double* scale_factor,
gfx::Size* page_size_in_dpi,
gfx::Rect* content_area_in_dpi);
#elif defined(OS_MACOSX)
#if defined(OS_MACOSX)
void RenderPage(const PrintMsg_Print_Params& params,
int page_number,
blink::WebFrame* frame,
bool is_preview,
Metafile* metafile,
gfx::Size* page_size,
gfx::Rect* content_rect);
#endif // defined(OS_WIN)
#endif // defined(OS_MACOSX)

// Renders page contents from |frame| to |content_area| of |canvas|.
// |page_number| is zero-based.
Expand Down
8 changes: 4 additions & 4 deletions chrome/renderer/printing/print_web_view_helper_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ TEST_F(PrintWebViewHelperTest, OnPrintPages) {
VerifyPagesPrinted(true);
}

#if (defined(OS_WIN) && !WIN_PDF_METAFILE_FOR_PRINTING) || defined(OS_MACOSX)
#if defined(OS_MACOSX)
// TODO(estade): I don't think this test is worth porting to Linux. We will have
// to rip out and replace most of the IPC code if we ever plan to improve
// printing, and the comment below by sverrir suggests that it doesn't do much
Expand Down Expand Up @@ -284,7 +284,7 @@ TEST_F(PrintWebViewHelperTest, PrintWithIframe) {
EXPECT_NE(0, image1.size().width());
EXPECT_NE(0, image1.size().height());
}
#endif
#endif // OS_MACOSX

// Tests if we can print a page and verify its results.
// This test prints HTML pages into a pseudo printer and check their outputs,
Expand Down Expand Up @@ -330,7 +330,7 @@ const TestPageData kTestPages[] = {
// hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
// metafile directly.
// Same for printing via PDF on Windows.
#if (defined(OS_WIN) && !WIN_PDF_METAFILE_FOR_PRINTING) || defined(OS_MACOSX)
#if defined(OS_MACOSX)
TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
bool baseline = false;

Expand Down Expand Up @@ -383,7 +383,7 @@ TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
}
}
}
#endif
#endif // OS_MACOSX

// These print preview tests do not work on Chrome OS yet.
#if !defined(OS_CHROMEOS)
Expand Down
Loading

0 comments on commit 36259ca

Please sign in to comment.