Rename PrintHandler to PrintHandlerWin since only used on Windows.
This commit is contained in:
parent
abd97a7513
commit
5ede62459c
4 changed files with 29 additions and 46 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
#include "chrome/utility/printing_handler.h"
|
#include "chrome/utility/printing_handler_win.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ int64_t AtomContentUtilityClient::max_ipc_message_size_ =
|
||||||
AtomContentUtilityClient::AtomContentUtilityClient()
|
AtomContentUtilityClient::AtomContentUtilityClient()
|
||||||
: filter_messages_(false) {
|
: filter_messages_(false) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
handlers_.push_back(new PrintingHandler());
|
handlers_.push_back(new PrintingHandlerWin());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,9 @@ void AtomContentUtilityClient::OnStartupPing() {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AtomContentUtilityClient::PreSandboxStartup() {
|
void AtomContentUtilityClient::PreSandboxStartup() {
|
||||||
PrintingHandler::PreSandboxStartup();
|
#if defined(OS_WIN)
|
||||||
|
PrintingHandlerWin::PreSandboxStartup();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "chrome/utility/printing_handler.h"
|
#include "chrome/utility/printing_handler_win.h"
|
||||||
|
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
|
@ -10,14 +10,10 @@
|
||||||
#include "base/scoped_native_library.h"
|
#include "base/scoped_native_library.h"
|
||||||
#include "chrome/common/print_messages.h"
|
#include "chrome/common/print_messages.h"
|
||||||
#include "content/public/utility/utility_thread.h"
|
#include "content/public/utility/utility_thread.h"
|
||||||
|
#include "printing/emf_win.h"
|
||||||
#include "printing/page_range.h"
|
#include "printing/page_range.h"
|
||||||
#include "printing/pdf_render_settings.h"
|
#include "printing/pdf_render_settings.h"
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
#include "printing/emf_win.h"
|
|
||||||
#include "ui/gfx/gdi_util.h"
|
#include "ui/gfx/gdi_util.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -125,33 +121,30 @@ base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PrintingHandler::PrintingHandler() {}
|
PrintingHandlerWin::PrintingHandlerWin() {}
|
||||||
|
|
||||||
PrintingHandler::~PrintingHandler() {}
|
PrintingHandlerWin::~PrintingHandlerWin() {}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void PrintingHandler::PreSandboxStartup() {
|
void PrintingHandlerWin::PreSandboxStartup() {
|
||||||
g_pdf_lib.Get().Init();
|
g_pdf_lib.Get().Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintingHandler::OnMessageReceived(const IPC::Message& message) {
|
bool PrintingHandlerWin::OnMessageReceived(const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(PrintingHandler, message)
|
IPC_BEGIN_MESSAGE_MAP(PrintingHandlerWin, message)
|
||||||
#if defined(OS_WIN)
|
|
||||||
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
|
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
|
||||||
OnRenderPDFPagesToMetafile)
|
OnRenderPDFPagesToMetafile)
|
||||||
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage,
|
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage,
|
||||||
OnRenderPDFPagesToMetafileGetPage)
|
OnRenderPDFPagesToMetafileGetPage)
|
||||||
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop,
|
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop,
|
||||||
OnRenderPDFPagesToMetafileStop)
|
OnRenderPDFPagesToMetafileStop)
|
||||||
#endif // OS_WIN
|
|
||||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||||
IPC_END_MESSAGE_MAP()
|
IPC_END_MESSAGE_MAP()
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
void PrintingHandlerWin::OnRenderPDFPagesToMetafile(
|
||||||
void PrintingHandler::OnRenderPDFPagesToMetafile(
|
|
||||||
IPC::PlatformFileForTransit pdf_transit,
|
IPC::PlatformFileForTransit pdf_transit,
|
||||||
const printing::PdfRenderSettings& settings) {
|
const printing::PdfRenderSettings& settings) {
|
||||||
pdf_rendering_settings_ = settings;
|
pdf_rendering_settings_ = settings;
|
||||||
|
@ -162,7 +155,7 @@ void PrintingHandler::OnRenderPDFPagesToMetafile(
|
||||||
new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count));
|
new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintingHandler::OnRenderPDFPagesToMetafileGetPage(
|
void PrintingHandlerWin::OnRenderPDFPagesToMetafileGetPage(
|
||||||
int page_number,
|
int page_number,
|
||||||
IPC::PlatformFileForTransit output_file) {
|
IPC::PlatformFileForTransit output_file) {
|
||||||
base::File emf_file = IPC::PlatformFileForTransitToFile(output_file);
|
base::File emf_file = IPC::PlatformFileForTransitToFile(output_file);
|
||||||
|
@ -173,11 +166,11 @@ void PrintingHandler::OnRenderPDFPagesToMetafileGetPage(
|
||||||
success, scale_factor));
|
success, scale_factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintingHandler::OnRenderPDFPagesToMetafileStop() {
|
void PrintingHandlerWin::OnRenderPDFPagesToMetafileStop() {
|
||||||
ReleaseProcessIfNeeded();
|
ReleaseProcessIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
int PrintingHandler::LoadPDF(base::File pdf_file) {
|
int PrintingHandlerWin::LoadPDF(base::File pdf_file) {
|
||||||
if (!g_pdf_lib.Get().IsValid())
|
if (!g_pdf_lib.Get().IsValid())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -198,9 +191,9 @@ int PrintingHandler::LoadPDF(base::File pdf_file) {
|
||||||
return total_page_count;
|
return total_page_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintingHandler::RenderPdfPageToMetafile(int page_number,
|
bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number,
|
||||||
base::File output_file,
|
base::File output_file,
|
||||||
float* scale_factor) {
|
float* scale_factor) {
|
||||||
printing::Emf metafile;
|
printing::Emf metafile;
|
||||||
metafile.Init();
|
metafile.Init();
|
||||||
|
|
||||||
|
@ -241,5 +234,3 @@ bool PrintingHandler::RenderPdfPageToMetafile(int page_number,
|
||||||
metafile.FinishDocument();
|
metafile.FinishDocument();
|
||||||
return metafile.SaveTo(&output_file);
|
return metafile.SaveTo(&output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OS_WIN
|
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef CHROME_UTILITY_PRINTING_HANDLER_H_
|
#ifndef CHROME_UTILITY_PRINTING_HANDLER_WIN_H_
|
||||||
#define CHROME_UTILITY_PRINTING_HANDLER_H_
|
#define CHROME_UTILITY_PRINTING_HANDLER_WIN_H_
|
||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
|
@ -11,10 +11,6 @@
|
||||||
#include "ipc/ipc_platform_file.h"
|
#include "ipc/ipc_platform_file.h"
|
||||||
#include "printing/pdf_render_settings.h"
|
#include "printing/pdf_render_settings.h"
|
||||||
|
|
||||||
#if !defined(ENABLE_PRINT_PREVIEW) && !defined(OS_WIN)
|
|
||||||
#error "Windows or full printing must be enabled"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
class PdfRenderSettings;
|
class PdfRenderSettings;
|
||||||
struct PwgRasterSettings;
|
struct PwgRasterSettings;
|
||||||
|
@ -22,40 +18,34 @@ struct PageRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatches IPCs for printing.
|
// Dispatches IPCs for printing.
|
||||||
class PrintingHandler : public UtilityMessageHandler {
|
class PrintingHandlerWin : public UtilityMessageHandler {
|
||||||
public:
|
public:
|
||||||
PrintingHandler();
|
PrintingHandlerWin();
|
||||||
~PrintingHandler() override;
|
~PrintingHandlerWin() override;
|
||||||
|
|
||||||
// IPC::Listener:
|
// IPC::Listener:
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
static void PrintingHandler::PreSandboxStartup();
|
static void PrintingHandlerWin::PreSandboxStartup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// IPC message handlers.
|
// IPC message handlers.
|
||||||
#if defined(OS_WIN)
|
|
||||||
void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit,
|
void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit,
|
||||||
const printing::PdfRenderSettings& settings);
|
const printing::PdfRenderSettings& settings);
|
||||||
void OnRenderPDFPagesToMetafileGetPage(
|
void OnRenderPDFPagesToMetafileGetPage(
|
||||||
int page_number,
|
int page_number,
|
||||||
IPC::PlatformFileForTransit output_file);
|
IPC::PlatformFileForTransit output_file);
|
||||||
void OnRenderPDFPagesToMetafileStop();
|
void OnRenderPDFPagesToMetafileStop();
|
||||||
#endif // OS_WIN
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
int LoadPDF(base::File pdf_file);
|
int LoadPDF(base::File pdf_file);
|
||||||
bool RenderPdfPageToMetafile(int page_number,
|
bool RenderPdfPageToMetafile(int page_number,
|
||||||
base::File output_file,
|
base::File output_file,
|
||||||
float* scale_factor);
|
float* scale_factor);
|
||||||
#endif // OS_WIN
|
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
std::vector<char> pdf_data_;
|
std::vector<char> pdf_data_;
|
||||||
printing::PdfRenderSettings pdf_rendering_settings_;
|
printing::PdfRenderSettings pdf_rendering_settings_;
|
||||||
#endif
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(PrintingHandler);
|
DISALLOW_COPY_AND_ASSIGN(PrintingHandlerWin);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHROME_UTILITY_PRINTING_HANDLER_H_
|
#endif // CHROME_UTILITY_PRINTING_HANDLER_WIN_H_
|
|
@ -381,8 +381,8 @@
|
||||||
'chromium_src/chrome/browser/ui/views/color_chooser_win.cc',
|
'chromium_src/chrome/browser/ui/views/color_chooser_win.cc',
|
||||||
'chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc',
|
'chromium_src/chrome/browser/printing/pdf_to_emf_converter.cc',
|
||||||
'chromium_src/chrome/browser/printing/pdf_to_emf_converter.h',
|
'chromium_src/chrome/browser/printing/pdf_to_emf_converter.h',
|
||||||
'chromium_src/chrome/utility/printing_handler.cc',
|
'chromium_src/chrome/utility/printing_handler_win.cc',
|
||||||
'chromium_src/chrome/utility/printing_handler.h',
|
'chromium_src/chrome/utility/printing_handler_win.h',
|
||||||
],
|
],
|
||||||
'framework_sources': [
|
'framework_sources': [
|
||||||
'atom/app/atom_library_main.h',
|
'atom/app/atom_library_main.h',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue