Commit a46cb343 authored by thestig@chromium.org's avatar thestig@chromium.org

Split printing utility IPC messages into its own file.

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278042 0039d316-1c4b-4281-b951-d872f2087c98
parent cac3776e
...@@ -117,7 +117,7 @@ base::LazyInstance<chrome::ChromeContentBrowserClient> ...@@ -117,7 +117,7 @@ base::LazyInstance<chrome::ChromeContentBrowserClient>
#if !defined(CHROME_MULTIPLE_DLL_BROWSER) #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
base::LazyInstance<ChromeContentRendererClient> base::LazyInstance<ChromeContentRendererClient>
g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER; g_chrome_content_renderer_client = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<chrome::ChromeContentUtilityClient> base::LazyInstance<ChromeContentUtilityClient>
g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER; g_chrome_content_utility_client = LAZY_INSTANCE_INITIALIZER;
base::LazyInstance<chrome::ChromeContentPluginClient> base::LazyInstance<chrome::ChromeContentPluginClient>
g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER; g_chrome_content_plugin_client = LAZY_INSTANCE_INITIALIZER;
...@@ -761,7 +761,7 @@ void ChromeMainDelegate::PreSandboxStartup() { ...@@ -761,7 +761,7 @@ void ChromeMainDelegate::PreSandboxStartup() {
#if !defined(CHROME_MULTIPLE_DLL_BROWSER) #if !defined(CHROME_MULTIPLE_DLL_BROWSER)
if (process_type == switches::kUtilityProcess || if (process_type == switches::kUtilityProcess ||
process_type == switches::kZygoteProcess) { process_type == switches::kZygoteProcess) {
chrome::ChromeContentUtilityClient::PreSandboxStartup(); ChromeContentUtilityClient::PreSandboxStartup();
} }
#endif #endif
} }
......
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/chrome_utility_printing_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h" #include "content/public/browser/child_process_data.h"
#include "content/public/browser/utility_process_host.h" #include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h" #include "content/public/browser/utility_process_host_client.h"
#include "printing/pdf_render_settings.h"
#include "printing/pwg_raster_settings.h"
namespace local_discovery { namespace local_discovery {
......
...@@ -11,10 +11,13 @@ ...@@ -11,10 +11,13 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/chrome_utility_printing_messages.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h" #include "content/public/browser/child_process_data.h"
#include "content/public/browser/utility_process_host.h" #include "content/public/browser/utility_process_host.h"
#include "content/public/browser/utility_process_host_client.h" #include "content/public/browser/utility_process_host_client.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
namespace printing { namespace printing {
......
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
'../crypto/crypto.gyp:crypto', '../crypto/crypto.gyp:crypto',
'../google_apis/google_apis.gyp:google_apis', '../google_apis/google_apis.gyp:google_apis',
'../jingle/jingle.gyp:notifier', '../jingle/jingle.gyp:notifier',
'../printing/printing.gyp:printing',
'../skia/skia.gyp:skia', '../skia/skia.gyp:skia',
'../sql/sql.gyp:sql', '../sql/sql.gyp:sql',
'../sync/sync.gyp:sync', '../sync/sync.gyp:sync',
...@@ -2687,11 +2688,6 @@ ...@@ -2687,11 +2688,6 @@
'xcode_settings': {'OTHER_LDFLAGS': ['-weak_framework CoreImage']}, 'xcode_settings': {'OTHER_LDFLAGS': ['-weak_framework CoreImage']},
}, },
}], }],
['enable_printing!=0', {
'dependencies': [
'../printing/printing.gyp:printing',
],
}],
['OS=="win" or OS=="mac"', { ['OS=="win" or OS=="mac"', {
'sources': [ 'sources': [
'browser/media_galleries/fileapi/iapps_data_provider.cc', 'browser/media_galleries/fileapi/iapps_data_provider.cc',
...@@ -3135,28 +3131,51 @@ ...@@ -3135,28 +3131,51 @@
], ],
}], }],
['enable_printing==0', { ['enable_printing==0', {
'dependencies!': [
'../printing/printing.gyp:printing',
],
'sources/': [ 'sources/': [
['exclude', '^browser/printing/'], ['exclude', '^browser/printing/'],
['exclude', '^browser/task_manager/printing_information.cc'], ['exclude', '^browser/task_manager/printing_information.cc'],
], ],
}], }],
['enable_printing==1', { ['enable_printing==1', {
'sources/': [ 'sources!': [
['exclude', '^browser/printing/print_view_manager_basic.*'], 'browser/printing/print_view_manager_basic.cc',
'browser/printing/print_view_manager_basic.h',
],
}, {
'sources!': [
'browser/local_discovery/privet_http_impl.cc',
'browser/local_discovery/privet_http_impl.h',
'browser/local_discovery/pwg_raster_converter.cc',
'browser/local_discovery/pwg_raster_converter.h',
], ],
}], }],
['enable_printing==2', { ['enable_printing==2', {
'sources/': [ 'sources/': [
['exclude', '^browser/printing/background_printing_manager.*'],
['exclude', '^browser/printing/cloud_print/'], ['exclude', '^browser/printing/cloud_print/'],
['exclude', '^browser/printing/print_view_manager.cc'],
['exclude', '^browser/printing/print_error_dialog.*'],
['exclude', '^browser/printing/print_preview.*'],
['exclude', '^browser/printing/print_view_manager.cc'],
['exclude', '^browser/printing/print_view_manager.h'],
['exclude', '^browser/printing/printer_manager_dialog.*'],
['exclude', '^browser/service_process/'], ['exclude', '^browser/service_process/'],
['exclude', '^browser/task_manager/printing_information.cc'], ],
'sources!': [
'browser/printing/background_printing_manager.cc',
'browser/printing/background_printing_manager.h',
'browser/printing/print_view_manager.cc',
'browser/printing/print_error_dialog.cc',
'browser/printing/print_error_dialog.h',
'browser/printing/print_preview.cc',
'browser/printing/print_preview.h',
'browser/printing/print_view_manager.cc',
'browser/printing/print_view_manager.h',
'browser/printing/printer_manager_dialog.cc',
'browser/printing/printer_manager_dialog.h',
'browser/task_manager/printing_information.cc',
],
}],
['OS!="win" or win_pdf_metafile_for_printing!=1', {
'sources!': [
'browser/printing/pdf_to_emf_converter.cc',
'browser/printing/pdf_to_emf_converter.h',
], ],
}], }],
['enable_captive_portal_detection!=1', { ['enable_captive_portal_detection!=1', {
......
...@@ -349,7 +349,7 @@ ...@@ -349,7 +349,7 @@
['exclude', '^renderer/printing/'] ['exclude', '^renderer/printing/']
] ]
}], }],
['win_pdf_metafile_for_printing', { ['win_pdf_metafile_for_printing==1', {
'sources': [ 'sources': [
'renderer/printing/print_web_view_helper_pdf_win.cc', 'renderer/printing/print_web_view_helper_pdf_win.cc',
], ],
......
...@@ -2286,6 +2286,9 @@ ...@@ -2286,6 +2286,9 @@
['exclude', '^browser/ui/webui/print_preview/'], ['exclude', '^browser/ui/webui/print_preview/'],
['exclude', '^service/'], ['exclude', '^service/'],
], ],
'sources!': [
'browser/local_discovery/privet_http_unittest.cc',
],
}], }],
['enable_captive_portal_detection!=1', { ['enable_captive_portal_detection!=1', {
'sources/': [ 'sources/': [
......
...@@ -72,6 +72,8 @@ ...@@ -72,6 +72,8 @@
'utility/importer/nss_decryptor_win.h', 'utility/importer/nss_decryptor_win.h',
'utility/importer/safari_importer.h', 'utility/importer/safari_importer.h',
'utility/importer/safari_importer.mm', 'utility/importer/safari_importer.mm',
'utility/local_discovery/service_discovery_message_handler.cc',
'utility/local_discovery/service_discovery_message_handler.h',
'utility/media_galleries/image_metadata_extractor.cc', 'utility/media_galleries/image_metadata_extractor.cc',
'utility/media_galleries/image_metadata_extractor.h', 'utility/media_galleries/image_metadata_extractor.h',
'utility/media_galleries/ipc_data_source.cc', 'utility/media_galleries/ipc_data_source.cc',
...@@ -80,6 +82,8 @@ ...@@ -80,6 +82,8 @@
'utility/media_galleries/itunes_pref_parser_win.h', 'utility/media_galleries/itunes_pref_parser_win.h',
'utility/media_galleries/media_metadata_parser.cc', 'utility/media_galleries/media_metadata_parser.cc',
'utility/media_galleries/media_metadata_parser.h', 'utility/media_galleries/media_metadata_parser.h',
'utility/printing_handler.cc',
'utility/printing_handler.h',
'utility/profile_import_handler.cc', 'utility/profile_import_handler.cc',
'utility/profile_import_handler.h', 'utility/profile_import_handler.h',
'utility/utility_message_handler.h', 'utility/utility_message_handler.h',
...@@ -134,17 +138,23 @@ ...@@ -134,17 +138,23 @@
['exclude', '^utility/profile_import_handler\.cc'], ['exclude', '^utility/profile_import_handler\.cc'],
], ],
}], }],
['enable_mdns == 1', {
'sources': [
'utility/local_discovery/service_discovery_message_handler.cc',
'utility/local_discovery/service_discovery_message_handler.h',
]
}],
['OS!="win"', { ['OS!="win"', {
'sources': [ 'sources': [
'utility/image_writer/image_writer_stub.cc', 'utility/image_writer/image_writer_stub.cc',
] ]
}], }],
['enable_printing!=1', {
'sources!': [
'utility/printing_handler.cc',
'utility/printing_handler.h',
]
}],
['enable_mdns==0', {
'sources!': [
'utility/local_discovery/service_discovery_message_handler.cc',
'utility/local_discovery/service_discovery_message_handler.h',
]
}],
], ],
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations. # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
'msvs_disabled_warnings': [ 4267, ], 'msvs_disabled_warnings': [ 4267, ],
......
...@@ -21,10 +21,6 @@ ...@@ -21,10 +21,6 @@
#include "chrome/common/safe_browsing/zip_analyzer.h" #include "chrome/common/safe_browsing/zip_analyzer.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h" #include "ipc/ipc_platform_file.h"
#include "printing/backend/print_backend.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
#include "printing/pwg_raster_settings.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#define IPC_MESSAGE_START ChromeUtilityMsgStart #define IPC_MESSAGE_START ChromeUtilityMsgStart
...@@ -36,53 +32,6 @@ typedef std::vector<Tuple2<SkBitmap, base::FilePath> > DecodedImages; ...@@ -36,53 +32,6 @@ typedef std::vector<Tuple2<SkBitmap, base::FilePath> > DecodedImages;
#endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_ #endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
IPC_STRUCT_TRAITS_MEMBER(from)
IPC_STRUCT_TRAITS_MEMBER(to)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
IPC_STRUCT_TRAITS_MEMBER(printer_defaults)
IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(printing::DuplexMode,
printing::UNKNOWN_DUPLEX_MODE,
printing::SHORT_EDGE)
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
IPC_STRUCT_TRAITS_MEMBER(display_name)
IPC_STRUCT_TRAITS_MEMBER(vendor_id)
IPC_STRUCT_TRAITS_MEMBER(size_um)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(collate_capable)
IPC_STRUCT_TRAITS_MEMBER(collate_default)
IPC_STRUCT_TRAITS_MEMBER(copies_capable)
IPC_STRUCT_TRAITS_MEMBER(duplex_capable)
IPC_STRUCT_TRAITS_MEMBER(duplex_default)
IPC_STRUCT_TRAITS_MEMBER(color_changeable)
IPC_STRUCT_TRAITS_MEMBER(color_default)
IPC_STRUCT_TRAITS_MEMBER(color_model)
IPC_STRUCT_TRAITS_MEMBER(bw_model)
IPC_STRUCT_TRAITS_MEMBER(papers)
IPC_STRUCT_TRAITS_MEMBER(default_paper)
IPC_STRUCT_TRAITS_MEMBER(dpis)
IPC_STRUCT_TRAITS_MEMBER(default_dpi)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS(printing::PwgRasterTransformType);
IPC_STRUCT_TRAITS_BEGIN(printing::PwgRasterSettings)
IPC_STRUCT_TRAITS_MEMBER(odd_page_transform)
IPC_STRUCT_TRAITS_MEMBER(rotate_all_pages)
IPC_STRUCT_TRAITS_MEMBER(reverse_page_order)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result) IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result)
IPC_STRUCT_TRAITS_MEMBER(extension_id) IPC_STRUCT_TRAITS_MEMBER(extension_id)
IPC_STRUCT_TRAITS_MEMBER(version) IPC_STRUCT_TRAITS_MEMBER(version)
...@@ -183,23 +132,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImage, ...@@ -183,23 +132,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImage,
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64, IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64,
std::string) // base64 encoded image contents std::string) // base64 encoded image contents
// 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.
IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
IPC::PlatformFileForTransit, // PDF file
base::FilePath, // Base location for output metafile
printing::PdfRenderSettings, // PDF render settings
std::vector<printing::PageRange>)
// Tell the utility process to render the given PDF into a PWGRaster.
IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
IPC::PlatformFileForTransit, /* Input PDF file */
printing::PdfRenderSettings, /* PDF render settings */
// PWG transform settings.
printing::PwgRasterSettings,
IPC::PlatformFileForTransit /* Output PWG file */)
// Tell the utility process to decode the given JPEG image data with a robust // Tell the utility process to decode the given JPEG image data with a robust
// libjpeg codec. // libjpeg codec.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage, IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage,
...@@ -209,20 +141,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage, ...@@ -209,20 +141,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage,
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON, IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON,
std::string /* JSON to parse */) std::string /* JSON to parse */)
// Tells the utility process to get capabilities and defaults for the specified
// printer. Used on Windows to isolate the service process from printer driver
// crashes by executing this in a separate process. This does not run in a
// sandbox.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
std::string /* printer name */)
// Tells the utility process to get capabilities and defaults for the specified
// printer. Used on Windows to isolate the service process from printer driver
// crashes by executing this in a separate process. This does not run in a
// sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
std::string /* printer name */)
// Tell the utility process to patch the given |input_file| using |patch_file| // Tell the utility process to patch the given |input_file| using |patch_file|
// and place the output in |output_file|. The patch should use the bsdiff // and place the output in |output_file|. The patch should use the bsdiff
// algorithm (Courgette's version). // algorithm (Courgette's version).
...@@ -372,20 +290,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded, ...@@ -372,20 +290,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded,
// Reply when an error occurred decoding the image. // Reply when an error occurred decoding the image.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed) IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed)
// 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)
// Reply when the utility process has succeeded in rendering the PDF to PWG.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded)
// Reply when an error occurred rendering the PDF to PWG.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed)
// Reply when the utility process successfully parsed a JSON string. // Reply when the utility process successfully parsed a JSON string.
// //
// WARNING: The result can be of any Value subclass type, but we can't easily // WARNING: The result can be of any Value subclass type, but we can't easily
...@@ -399,21 +303,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded, ...@@ -399,21 +303,6 @@ IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded,
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed, IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed,
std::string /* error message, if any*/) std::string /* error message, if any*/)
#if defined(ENABLE_FULL_PRINTING)
// Reply when the utility process has succeeded in obtaining the printer
// capabilities and defaults.
IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
std::string /* printer name */,
printing::PrinterCapsAndDefaults)
// Reply when the utility process has succeeded in obtaining the printer
// semantic capabilities and defaults.
IPC_MESSAGE_CONTROL2(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded,
std::string /* printer name */,
printing::PrinterSemanticCapsAndDefaults)
#endif
// Reply when a file has been patched successfully. // Reply when a file has been patched successfully.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_PatchFile_Succeeded) IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_PatchFile_Succeeded)
...@@ -421,17 +310,6 @@ IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_PatchFile_Succeeded) ...@@ -421,17 +310,6 @@ IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_PatchFile_Succeeded)
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_PatchFile_Failed, IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_PatchFile_Failed,
int /* error code */) int /* error code */)
// Reply when the utility process has failed to obtain the printer
// capabilities and defaults.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
std::string /* printer name */)
// Reply when the utility process has failed to obtain the printer
// semantic capabilities and defaults.
IPC_MESSAGE_CONTROL1(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
std::string /* printer name */)
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Reply when the utility process has succeeded in creating the zip file. // Reply when the utility process has succeeded in creating the zip file.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Succeeded) IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Succeeded)
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Multiply-included message file, so no include guard.
#include <string>
#include <vector>
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_platform_file.h"
#include "printing/backend/print_backend.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
#include "printing/pwg_raster_settings.h"
#if !defined(ENABLE_FULL_PRINTING)
#error "Full printing must be enabled"
#endif
#define IPC_MESSAGE_START UtilityPrintingMsgStart
IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
IPC_STRUCT_TRAITS_MEMBER(from)
IPC_STRUCT_TRAITS_MEMBER(to)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
IPC_STRUCT_TRAITS_MEMBER(printer_defaults)
IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(printing::DuplexMode,
printing::UNKNOWN_DUPLEX_MODE,
printing::SHORT_EDGE)
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
IPC_STRUCT_TRAITS_MEMBER(display_name)
IPC_STRUCT_TRAITS_MEMBER(vendor_id)
IPC_STRUCT_TRAITS_MEMBER(size_um)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
IPC_STRUCT_TRAITS_MEMBER(collate_capable)
IPC_STRUCT_TRAITS_MEMBER(collate_default)
IPC_STRUCT_TRAITS_MEMBER(copies_capable)
IPC_STRUCT_TRAITS_MEMBER(duplex_capable)
IPC_STRUCT_TRAITS_MEMBER(duplex_default)
IPC_STRUCT_TRAITS_MEMBER(color_changeable)
IPC_STRUCT_TRAITS_MEMBER(color_default)
IPC_STRUCT_TRAITS_MEMBER(color_model)
IPC_STRUCT_TRAITS_MEMBER(bw_model)
IPC_STRUCT_TRAITS_MEMBER(papers)
IPC_STRUCT_TRAITS_MEMBER(default_paper)
IPC_STRUCT_TRAITS_MEMBER(dpis)
IPC_STRUCT_TRAITS_MEMBER(default_dpi)
IPC_STRUCT_TRAITS_END()
IPC_ENUM_TRAITS(printing::PwgRasterTransformType);
IPC_STRUCT_TRAITS_BEGIN(printing::PwgRasterSettings)
IPC_STRUCT_TRAITS_MEMBER(odd_page_transform)
IPC_STRUCT_TRAITS_MEMBER(rotate_all_pages)
IPC_STRUCT_TRAITS_MEMBER(reverse_page_order)
IPC_STRUCT_TRAITS_END()
//------------------------------------------------------------------------------
// Utility process messages:
// These are messages from the browser to the utility process.
// Tell the utility process to render the given PDF into a PWGRaster.
IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
IPC::PlatformFileForTransit, /* Input PDF file */
printing::PdfRenderSettings, /* PDF render settings */
// PWG transform settings.
printing::PwgRasterSettings,
IPC::PlatformFileForTransit /* Output PWG file */)
// Tells the utility process to get capabilities and defaults for the specified
// printer. Used on Windows to isolate the service process from printer driver
// crashes by executing this in a separate process. This does not run in a
// sandbox.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
std::string /* printer name */)
// Tells the utility process to get capabilities and defaults for the specified
// printer. Used on Windows to isolate the service process from printer driver
// crashes by executing this in a separate process. This does not run in a
// sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults.
IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
std::string /* printer name */)
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
// 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.
IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
IPC::PlatformFileForTransit, // PDF file
base::FilePath, // Base location for output metafile
printing::PdfRenderSettings, // PDF render settings
std::vector<printing::PageRange>)
#endif
//------------------------------------------------------------------------------
// Utility process host messages:
// These are messages from the utility process to the browser.
// Reply when the utility process has succeeded in rendering the PDF to PWG.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded)
// Reply when an error occurred rendering the PDF to PWG.
IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed)
// Reply when the utility process has succeeded in obtaining the printer
// capabilities and defaults.
IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
std::string /* printer name */,
printing::PrinterCapsAndDefaults)
// Reply when the utility process has succeeded in obtaining the printer
// semantic capabilities and defaults.
IPC_MESSAGE_CONTROL2(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded,
std::string /* printer name */,
printing::PrinterSemanticCapsAndDefaults)
// Reply when the utility process has failed to obtain the printer
// capabilities and defaults.
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
std::string /* printer name */)
// Reply when the utility process has failed to obtain the printer
// semantic capabilities and defaults.
IPC_MESSAGE_CONTROL1(
ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
std::string /* printer name */)
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
// 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
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "chrome/common/local_discovery/local_discovery_messages.h" #include "chrome/common/local_discovery/local_discovery_messages.h"
#endif #endif
#if defined(ENABLE_FULL_PRINTING)
#include "chrome/common/chrome_utility_printing_messages.h"
#endif
#if defined(ENABLE_PRINTING) #if defined(ENABLE_PRINTING)
#include "chrome/common/print_messages.h" #include "chrome/common/print_messages.h"
#endif #endif
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include "base/process/kill.h" #include "base/process/kill.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_printing_messages.h"
#include "content/public/common/child_process_host.h" #include "content/public/common/child_process_host.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "content/public/common/sandbox_init.h" #include "content/public/common/sandbox_init.h"
...@@ -230,11 +230,13 @@ void ServiceUtilityProcessHost::OnChildDisconnected() { ...@@ -230,11 +230,13 @@ void ServiceUtilityProcessHost::OnChildDisconnected() {
bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) { bool ServiceUtilityProcessHost::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message) IPC_BEGIN_MESSAGE_MAP(ServiceUtilityProcessHost, message)
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
IPC_MESSAGE_HANDLER( IPC_MESSAGE_HANDLER(
ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded, ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded,
OnRenderPDFPagesToMetafilesSucceeded) OnRenderPDFPagesToMetafilesSucceeded)
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed, IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed,
OnRenderPDFPagesToMetafileFailed) OnRenderPDFPagesToMetafileFailed)
#endif
IPC_MESSAGE_HANDLER( IPC_MESSAGE_HANDLER(
ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
OnGetPrinterCapsAndDefaultsSucceeded) OnGetPrinterCapsAndDefaultsSucceeded)
...@@ -255,6 +257,7 @@ base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const { ...@@ -255,6 +257,7 @@ base::ProcessHandle ServiceUtilityProcessHost::GetHandle() const {
return handle_; return handle_;
} }
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded( void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafilesSucceeded(
const std::vector<printing::PageRange>& page_ranges, const std::vector<printing::PageRange>& page_ranges,
double scale_factor) { double scale_factor) {
...@@ -298,6 +301,7 @@ void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileFailed() { ...@@ -298,6 +301,7 @@ void ServiceUtilityProcessHost::OnRenderPDFPagesToMetafileFailed() {
FROM_HERE, FROM_HERE,
base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get())); base::Bind(&Client::OnRenderPDFPagesToMetafileFailed, client_.get()));
} }
#endif // defined(WIN_PDF_METAFILE_FOR_PRINTING)
void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded( void ServiceUtilityProcessHost::OnGetPrinterCapsAndDefaultsSucceeded(
const std::string& printer_name, const std::string& printer_name,
......
...@@ -49,7 +49,7 @@ class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { ...@@ -49,7 +49,7 @@ class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener {
#if !defined(OS_IOS) #if !defined(OS_IOS)
browser_content_client_.reset(new chrome::ChromeContentBrowserClient()); browser_content_client_.reset(new chrome::ChromeContentBrowserClient());
content::SetBrowserClientForTesting(browser_content_client_.get()); content::SetBrowserClientForTesting(browser_content_client_.get());
utility_content_client_.reset(new chrome::ChromeContentUtilityClient()); utility_content_client_.reset(new ChromeContentUtilityClient());
content::SetUtilityClientForTesting(utility_content_client_.get()); content::SetUtilityClientForTesting(utility_content_client_.get());
#endif #endif
...@@ -74,7 +74,7 @@ class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener { ...@@ -74,7 +74,7 @@ class ChromeUnitTestSuiteInitializer : public testing::EmptyTestEventListener {
// TODO(ios): Bring this back once ChromeContentBrowserClient is building. // TODO(ios): Bring this back once ChromeContentBrowserClient is building.
#if !defined(OS_IOS) #if !defined(OS_IOS)
scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_; scoped_ptr<chrome::ChromeContentBrowserClient> browser_content_client_;
scoped_ptr<chrome::ChromeContentUtilityClient> utility_content_client_; scoped_ptr<ChromeContentUtilityClient> utility_content_client_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(ChromeUnitTestSuiteInitializer); DISALLOW_COPY_AND_ASSIGN(ChromeUnitTestSuiteInitializer);
......
...@@ -7,21 +7,16 @@ ...@@ -7,21 +7,16 @@
#include "base/base64.h" #include "base/base64.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/file_util.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/scoped_native_library.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_messages.h"
#include "chrome/common/extensions/chrome_extensions_client.h" #include "chrome/common/extensions/chrome_extensions_client.h"
#include "chrome/common/extensions/update_manifest.h" #include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/safe_browsing/zip_analyzer.h" #include "chrome/common/safe_browsing/zip_analyzer.h"
#include "chrome/utility/chrome_content_utility_ipc_whitelist.h" #include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
#include "chrome/utility/cloud_print/bitmap_image.h"
#include "chrome/utility/cloud_print/pwg_encoder.h"
#include "chrome/utility/extensions/unpacker.h" #include "chrome/utility/extensions/unpacker.h"
#include "chrome/utility/image_writer/image_writer_handler.h" #include "chrome/utility/image_writer/image_writer_handler.h"
#include "chrome/utility/profile_import_handler.h" #include "chrome/utility/profile_import_handler.h"
...@@ -37,8 +32,6 @@ ...@@ -37,8 +32,6 @@
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "media/base/media.h" #include "media/base/media.h"
#include "media/base/media_file_checker.h" #include "media/base/media_file_checker.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/zlib/google/zip.h" #include "third_party/zlib/google/zip.h"
#include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches.h"
...@@ -47,13 +40,9 @@ ...@@ -47,13 +40,9 @@
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "base/win/iat_patch_function.h"
#include "base/win/scoped_handle.h"
#include "chrome/common/extensions/api/networking_private/networking_private_crypto.h" #include "chrome/common/extensions/api/networking_private/networking_private_crypto.h"
#include "chrome/utility/media_galleries/itunes_pref_parser_win.h" #include "chrome/utility/media_galleries/itunes_pref_parser_win.h"
#include "components/wifi/wifi_service.h" #include "components/wifi/wifi_service.h"
#include "printing/emf_win.h"
#include "ui/gfx/gdi_util.h"
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -75,15 +64,12 @@ ...@@ -75,15 +64,12 @@
#endif // !defined(OS_ANDROID) && !defined(OS_IOS) #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
#if defined(ENABLE_FULL_PRINTING) #if defined(ENABLE_FULL_PRINTING)
#include "chrome/common/crash_keys.h" #include "chrome/utility/printing_handler.h"
#include "printing/backend/print_backend.h"
#endif #endif
#if defined(ENABLE_MDNS) #if defined(ENABLE_MDNS)
#include "chrome/utility/local_discovery/service_discovery_message_handler.h" #include "chrome/utility/local_discovery/service_discovery_message_handler.h"
#endif // ENABLE_MDNS #endif
namespace chrome {
namespace { namespace {
...@@ -95,212 +81,6 @@ void ReleaseProcessIfNeeded() { ...@@ -95,212 +81,6 @@ void ReleaseProcessIfNeeded() {
content::UtilityThread::Get()->ReleaseProcessIfNeeded(); content::UtilityThread::Get()->ReleaseProcessIfNeeded();
} }
class PdfFunctionsBase {
public:
PdfFunctionsBase() : render_pdf_to_bitmap_func_(NULL),
get_pdf_doc_info_func_(NULL) {}
bool Init() {
base::FilePath pdf_module_path;
if (!PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_module_path) ||
!base::PathExists(pdf_module_path)) {
return false;
}
pdf_lib_.Reset(base::LoadNativeLibrary(pdf_module_path, NULL));
if (!pdf_lib_.is_valid()) {
LOG(WARNING) << "Couldn't load PDF plugin";
return false;
}
render_pdf_to_bitmap_func_ =
reinterpret_cast<RenderPDFPageToBitmapProc>(
pdf_lib_.GetFunctionPointer("RenderPDFPageToBitmap"));
LOG_IF(WARNING, !render_pdf_to_bitmap_func_) <<
"Missing RenderPDFPageToBitmap";
get_pdf_doc_info_func_ =
reinterpret_cast<GetPDFDocInfoProc>(
pdf_lib_.GetFunctionPointer("GetPDFDocInfo"));
LOG_IF(WARNING, !get_pdf_doc_info_func_) << "Missing GetPDFDocInfo";
if (!render_pdf_to_bitmap_func_ || !get_pdf_doc_info_func_ ||
!PlatformInit(pdf_module_path, pdf_lib_)) {
Reset();
}
return IsValid();
}
bool IsValid() const {
return pdf_lib_.is_valid();
}
void Reset() {
pdf_lib_.Reset(NULL);
}
bool RenderPDFPageToBitmap(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi_x,
int dpi_y,
bool autorotate) {
if (!render_pdf_to_bitmap_func_)
return false;
return render_pdf_to_bitmap_func_(pdf_buffer, pdf_buffer_size, page_number,
bitmap_buffer, bitmap_width,
bitmap_height, dpi_x, dpi_y, autorotate);
}
bool GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width) {
if (!get_pdf_doc_info_func_)
return false;
return get_pdf_doc_info_func_(pdf_buffer, buffer_size, page_count,
max_page_width);
}
protected:
virtual bool PlatformInit(
const base::FilePath& pdf_module_path,
const base::ScopedNativeLibrary& pdf_lib) {
return true;
}
private:
// Exported by PDF plugin.
typedef bool (*RenderPDFPageToBitmapProc)(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi_x,
int dpi_y,
bool autorotate);
typedef bool (*GetPDFDocInfoProc)(const void* pdf_buffer,
int buffer_size, int* page_count,
double* max_page_width);
RenderPDFPageToBitmapProc render_pdf_to_bitmap_func_;
GetPDFDocInfoProc get_pdf_doc_info_func_;
base::ScopedNativeLibrary pdf_lib_;
DISALLOW_COPY_AND_ASSIGN(PdfFunctionsBase);
};
#if defined(OS_WIN)
// The 2 below IAT patch functions are almost identical to the code in
// render_process_impl.cc. This is needed to work around specific Windows APIs
// used by the Chrome PDF plugin that will fail in the sandbox.
static base::win::IATPatchFunction g_iat_patch_createdca;
HDC WINAPI UtilityProcess_CreateDCAPatch(LPCSTR driver_name,
LPCSTR device_name,
LPCSTR output,
const DEVMODEA* init_data) {
if (driver_name && (std::string("DISPLAY") == driver_name)) {
// CreateDC fails behind the sandbox, but not CreateCompatibleDC.
return CreateCompatibleDC(NULL);
}
NOTREACHED();
return CreateDCA(driver_name, device_name, output, init_data);
}
static base::win::IATPatchFunction g_iat_patch_get_font_data;
DWORD WINAPI UtilityProcess_GetFontDataPatch(
HDC hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD length) {
int rv = GetFontData(hdc, table, offset, buffer, length);
if (rv == GDI_ERROR && hdc) {
HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT));
LOGFONT logfont;
if (GetObject(font, sizeof(LOGFONT), &logfont)) {
content::UtilityThread::Get()->PreCacheFont(logfont);
rv = GetFontData(hdc, table, offset, buffer, length);
content::UtilityThread::Get()->ReleaseCachedFonts();
}
}
return rv;
}
class PdfFunctionsWin : public PdfFunctionsBase {
public:
PdfFunctionsWin() : render_pdf_to_dc_func_(NULL) {
}
bool PlatformInit(
const base::FilePath& pdf_module_path,
const base::ScopedNativeLibrary& pdf_lib) OVERRIDE {
// Patch the IAT for handling specific APIs known to fail in the sandbox.
if (!g_iat_patch_createdca.is_patched()) {
g_iat_patch_createdca.Patch(pdf_module_path.value().c_str(),
"gdi32.dll", "CreateDCA",
UtilityProcess_CreateDCAPatch);
}
if (!g_iat_patch_get_font_data.is_patched()) {
g_iat_patch_get_font_data.Patch(pdf_module_path.value().c_str(),
"gdi32.dll", "GetFontData",
UtilityProcess_GetFontDataPatch);
}
render_pdf_to_dc_func_ =
reinterpret_cast<RenderPDFPageToDCProc>(
pdf_lib.GetFunctionPointer("RenderPDFPageToDC"));
LOG_IF(WARNING, !render_pdf_to_dc_func_) << "Missing RenderPDFPageToDC";
return render_pdf_to_dc_func_ != NULL;
}
bool RenderPDFPageToDC(const void* pdf_buffer,
int buffer_size,
int page_number,
HDC dc,
int dpi_x,
int dpi_y,
int bounds_origin_x,
int bounds_origin_y,
int bounds_width,
int bounds_height,
bool fit_to_bounds,
bool stretch_to_bounds,
bool keep_aspect_ratio,
bool center_in_bounds,
bool autorotate) {
if (!render_pdf_to_dc_func_)
return false;
return render_pdf_to_dc_func_(pdf_buffer, buffer_size, page_number,
dc, dpi_x, dpi_y, bounds_origin_x,
bounds_origin_y, bounds_width, bounds_height,
fit_to_bounds, stretch_to_bounds,
keep_aspect_ratio, center_in_bounds,
autorotate);
}
private:
// Exported by PDF plugin.
typedef bool (*RenderPDFPageToDCProc)(
const void* pdf_buffer, int buffer_size, int page_number, HDC dc,
int dpi_x, int dpi_y, int bounds_origin_x, int bounds_origin_y,
int bounds_width, int bounds_height, bool fit_to_bounds,
bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds,
bool autorotate);
RenderPDFPageToDCProc render_pdf_to_dc_func_;
DISALLOW_COPY_AND_ASSIGN(PdfFunctionsWin);
};
typedef PdfFunctionsWin PdfFunctions;
#else // OS_WIN
typedef PdfFunctionsBase PdfFunctions;
#endif // OS_WIN
#if !defined(OS_ANDROID) && !defined(OS_IOS) #if !defined(OS_ANDROID) && !defined(OS_IOS)
void FinishParseMediaMetadata( void FinishParseMediaMetadata(
metadata::MediaMetadataParser* parser, metadata::MediaMetadataParser* parser,
...@@ -312,22 +92,24 @@ void FinishParseMediaMetadata( ...@@ -312,22 +92,24 @@ void FinishParseMediaMetadata(
} }
#endif // !defined(OS_ANDROID) && !defined(OS_IOS) #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
static base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER;
} // namespace } // namespace
ChromeContentUtilityClient::ChromeContentUtilityClient() ChromeContentUtilityClient::ChromeContentUtilityClient()
: filter_messages_(false) { : filter_messages_(false) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
handlers_.push_back(new ProfileImportHandler()); handlers_.push_back(new ProfileImportHandler());
#endif // OS_ANDROID #endif
#if defined(ENABLE_FULL_PRINTING)
handlers_.push_back(new PrintingHandler());
#endif
#if defined(ENABLE_MDNS) #if defined(ENABLE_MDNS)
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUtilityProcessEnableMDns)) { switches::kUtilityProcessEnableMDns)) {
handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler()); handlers_.push_back(new local_discovery::ServiceDiscoveryMessageHandler());
} }
#endif // ENABLE_MDNS #endif
handlers_.push_back(new image_writer::ImageWriterHandler()); handlers_.push_back(new image_writer::ImageWriterHandler());
} }
...@@ -350,11 +132,8 @@ void ChromeContentUtilityClient::UtilityThreadStarted() { ...@@ -350,11 +132,8 @@ void ChromeContentUtilityClient::UtilityThreadStarted() {
bool ChromeContentUtilityClient::OnMessageReceived( bool ChromeContentUtilityClient::OnMessageReceived(
const IPC::Message& message) { const IPC::Message& message) {
if (filter_messages_ && if (filter_messages_ && !ContainsKey(message_id_whitelist_, message.type()))
(message_id_whitelist_.find(message.type()) ==
message_id_whitelist_.end())) {
return false; return false;
}
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message) IPC_BEGIN_MESSAGE_MAP(ChromeContentUtilityClient, message)
...@@ -365,17 +144,9 @@ bool ChromeContentUtilityClient::OnMessageReceived( ...@@ -365,17 +144,9 @@ bool ChromeContentUtilityClient::OnMessageReceived(
OnParseUpdateManifest) OnParseUpdateManifest)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
OnRenderPDFPagesToMetafile)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
OnRenderPDFPagesToPWGRaster)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage,
OnRobustJPEGDecodeImage) OnRobustJPEGDecodeImage)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
OnGetPrinterCapsAndDefaults)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
OnGetPrinterSemanticCapsAndDefaults)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff, IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff,
OnPatchFileBsdiff) OnPatchFileBsdiff)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette, IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette,
...@@ -431,6 +202,10 @@ bool ChromeContentUtilityClient::OnMessageReceived( ...@@ -431,6 +202,10 @@ bool ChromeContentUtilityClient::OnMessageReceived(
// static // static
void ChromeContentUtilityClient::PreSandboxStartup() { void ChromeContentUtilityClient::PreSandboxStartup() {
#if defined(ENABLE_FULL_PRINTING)
PrintingHandler::PreSandboxStartup();
#endif
#if defined(ENABLE_MDNS) #if defined(ENABLE_MDNS)
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kUtilityProcessEnableMDns)) { switches::kUtilityProcessEnableMDns)) {
...@@ -438,8 +213,6 @@ void ChromeContentUtilityClient::PreSandboxStartup() { ...@@ -438,8 +213,6 @@ void ChromeContentUtilityClient::PreSandboxStartup() {
} }
#endif // ENABLE_MDNS #endif // ENABLE_MDNS
g_pdf_lib.Get().Init();
#if !defined(OS_ANDROID) && !defined(OS_IOS) #if !defined(OS_ANDROID) && !defined(OS_IOS)
// Initialize libexif for image metadata parsing. // Initialize libexif for image metadata parsing.
metadata::ImageMetadataExtractor::InitializeLibrary(); metadata::ImageMetadataExtractor::InitializeLibrary();
...@@ -566,229 +339,6 @@ void ChromeContentUtilityClient::OnCreateZipFile( ...@@ -566,229 +339,6 @@ void ChromeContentUtilityClient::OnCreateZipFile(
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile(
IPC::PlatformFileForTransit pdf_transit,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
const std::vector<printing::PageRange>& page_ranges_const) {
bool succeeded = false;
#if defined(OS_WIN)
base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit);
int highest_rendered_page_number = 0;
double scale_factor = 1.0;
std::vector<printing::PageRange> page_ranges = page_ranges_const;
succeeded = RenderPDFToWinMetafile(pdf_file.Pass(),
metafile_path,
settings,
&page_ranges,
&highest_rendered_page_number,
&scale_factor);
if (succeeded) {
// TODO(vitalybuka|scottmg): http://crbug.com/170859. These could
// potentially be sent as each page is converted so that the spool could
// start sooner.
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded(
page_ranges, scale_factor));
}
#endif // defined(OS_WIN)
if (!succeeded) {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed());
}
ReleaseProcessIfNeeded();
}
void ChromeContentUtilityClient::OnRenderPDFPagesToPWGRaster(
IPC::PlatformFileForTransit pdf_transit,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
IPC::PlatformFileForTransit bitmap_transit) {
base::File pdf = IPC::PlatformFileForTransitToFile(pdf_transit);
base::File bitmap = IPC::PlatformFileForTransitToFile(bitmap_transit);
if (RenderPDFPagesToPWGRaster(pdf.Pass(), settings, bitmap_settings,
bitmap.Pass())) {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded());
} else {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed());
}
ReleaseProcessIfNeeded();
}
#if defined(OS_WIN)
bool ChromeContentUtilityClient::RenderPDFToWinMetafile(
base::File pdf_file,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
std::vector<printing::PageRange>* page_ranges,
int* highest_rendered_page_number,
double* scale_factor) {
DCHECK(page_ranges);
*highest_rendered_page_number = -1;
*scale_factor = 1.0;
if (!g_pdf_lib.Get().IsValid())
return false;
// TODO(sanjeevr): Add a method to the PDF DLL that takes in a file handle
// and a page range array. That way we don't need to read the entire PDF into
// memory.
int64 length = pdf_file.GetLength();
if (length < 0)
return false;
std::vector<char> buffer;
buffer.resize(length);
if (length != pdf_file.Read(0, &buffer.front(), length))
return false;
int total_page_count = 0;
if (!g_pdf_lib.Get().GetPDFDocInfo(&buffer.front(), buffer.size(),
&total_page_count, NULL)) {
return false;
}
// If no range supplied, do all pages.
if (page_ranges->empty()) {
printing::PageRange page_range_all;
page_range_all.from = 0;
page_range_all.to = total_page_count - 1;
page_ranges->push_back(page_range_all);
}
bool ret = false;
std::vector<printing::PageRange>::const_iterator iter;
for (iter = page_ranges->begin(); iter != page_ranges->end(); ++iter) {
for (int page_number = iter->from; page_number <= iter->to; ++page_number) {
if (page_number >= total_page_count)
break;
printing::Emf metafile;
metafile.InitToFile(metafile_path.InsertBeforeExtensionASCII(
base::StringPrintf(".%d", page_number)));
// We need to scale down DC to fit an entire page into DC available area.
// Current metafile is based on screen DC and have current screen size.
// Writing outside of those boundaries will result in the cut-off output.
// On metafiles (this is the case here), scaling down will still record
// original coordinates and we'll be able to print in full resolution.
// Before playback we'll need to counter the scaling up that will happen
// in the service (print_system_win.cc).
*scale_factor = gfx::CalculatePageScale(metafile.context(),
settings.area().right(),
settings.area().bottom());
gfx::ScaleDC(metafile.context(), *scale_factor);
// The underlying metafile is of type Emf and ignores the arguments passed
// to StartPage.
metafile.StartPage(gfx::Size(), gfx::Rect(), 1);
if (g_pdf_lib.Get().RenderPDFPageToDC(
&buffer.front(), buffer.size(), page_number, metafile.context(),
settings.dpi(), settings.dpi(), settings.area().x(),
settings.area().y(), settings.area().width(),
settings.area().height(), true, false, true, true,
settings.autorotate())) {
if (*highest_rendered_page_number < page_number)
*highest_rendered_page_number = page_number;
ret = true;
}
metafile.FinishPage();
metafile.FinishDocument();
}
}
return ret;
}
#endif // defined(OS_WIN)
bool ChromeContentUtilityClient::RenderPDFPagesToPWGRaster(
base::File pdf_file,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
base::File bitmap_file) {
bool autoupdate = true;
if (!g_pdf_lib.Get().IsValid())
return false;
base::File::Info info;
if (!pdf_file.GetInfo(&info) || info.size <= 0)
return false;
std::string data(info.size, 0);
int data_size = pdf_file.Read(0, &data[0], data.size());
if (data_size != static_cast<int>(data.size()))
return false;
int total_page_count = 0;
if (!g_pdf_lib.Get().GetPDFDocInfo(data.data(), data.size(),
&total_page_count, NULL)) {
return false;
}
cloud_print::PwgEncoder encoder;
std::string pwg_header;
encoder.EncodeDocumentHeader(&pwg_header);
int bytes_written = bitmap_file.WriteAtCurrentPos(pwg_header.data(),
pwg_header.size());
if (bytes_written != static_cast<int>(pwg_header.size()))
return false;
cloud_print::BitmapImage image(settings.area().size(),
cloud_print::BitmapImage::BGRA);
for (int i = 0; i < total_page_count; ++i) {
int page_number = i;
if (bitmap_settings.reverse_page_order) {
page_number = total_page_count - 1 - page_number;
}
if (!g_pdf_lib.Get().RenderPDFPageToBitmap(data.data(),
data.size(),
page_number,
image.pixel_data(),
image.size().width(),
image.size().height(),
settings.dpi(),
settings.dpi(),
autoupdate)) {
return false;
}
cloud_print::PwgHeaderInfo header_info;
header_info.dpi = settings.dpi();
header_info.total_pages = total_page_count;
// Transform odd pages.
if (page_number % 2) {
switch (bitmap_settings.odd_page_transform) {
case printing::TRANSFORM_NORMAL:
break;
case printing::TRANSFORM_ROTATE_180:
header_info.flipx = true;
header_info.flipy = true;
break;
case printing::TRANSFORM_FLIP_HORIZONTAL:
header_info.flipx = true;
break;
case printing::TRANSFORM_FLIP_VERTICAL:
header_info.flipy = true;
break;
}
}
if (bitmap_settings.rotate_all_pages) {
header_info.flipx = !header_info.flipx;
header_info.flipy = !header_info.flipy;
}
std::string pwg_page;
if (!encoder.EncodePage(image, header_info, &pwg_page))
return false;
bytes_written = bitmap_file.WriteAtCurrentPos(pwg_page.data(),
pwg_page.size());
if (bytes_written != static_cast<int>(pwg_page.size()))
return false;
}
return true;
}
void ChromeContentUtilityClient::OnRobustJPEGDecodeImage( void ChromeContentUtilityClient::OnRobustJPEGDecodeImage(
const std::vector<unsigned char>& encoded_data) { const std::vector<unsigned char>& encoded_data) {
// Our robust jpeg decoding is using IJG libjpeg. // Our robust jpeg decoding is using IJG libjpeg.
...@@ -821,51 +371,6 @@ void ChromeContentUtilityClient::OnParseJSON(const std::string& json) { ...@@ -821,51 +371,6 @@ void ChromeContentUtilityClient::OnParseJSON(const std::string& json) {
ReleaseProcessIfNeeded(); ReleaseProcessIfNeeded();
} }
void ChromeContentUtilityClient::OnGetPrinterCapsAndDefaults(
const std::string& printer_name) {
#if defined(ENABLE_FULL_PRINTING)
scoped_refptr<printing::PrintBackend> print_backend =
printing::PrintBackend::CreateInstance(NULL);
printing::PrinterCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key(
print_backend->GetPrinterDriverInfo(printer_name));
if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) {
Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(
printer_name, printer_info));
} else // NOLINT
#endif
{
Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed(
printer_name));
}
ReleaseProcessIfNeeded();
}
void ChromeContentUtilityClient::OnGetPrinterSemanticCapsAndDefaults(
const std::string& printer_name) {
#if defined(ENABLE_FULL_PRINTING)
scoped_refptr<printing::PrintBackend> print_backend =
printing::PrintBackend::CreateInstance(NULL);
printing::PrinterSemanticCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key(
print_backend->GetPrinterDriverInfo(printer_name));
if (print_backend->GetPrinterSemanticCapsAndDefaults(printer_name,
&printer_info)) {
Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded(
printer_name, printer_info));
} else // NOLINT
#endif
{
Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed(
printer_name));
}
ReleaseProcessIfNeeded();
}
void ChromeContentUtilityClient::OnPatchFileBsdiff( void ChromeContentUtilityClient::OnPatchFileBsdiff(
const base::FilePath& input_file, const base::FilePath& input_file,
const base::FilePath& patch_file, const base::FilePath& patch_file,
...@@ -1034,5 +539,3 @@ void ChromeContentUtilityClient::OnGetAndEncryptWiFiCredentials( ...@@ -1034,5 +539,3 @@ void ChromeContentUtilityClient::OnGetAndEncryptWiFiCredentials(
success)); success));
} }
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
} // namespace chrome
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
#define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_ #define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "base/files/file.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_vector.h" #include "base/memory/scoped_vector.h"
#include "chrome/common/media_galleries/picasa_types.h" #include "chrome/common/media_galleries/picasa_types.h"
#include "content/public/utility/content_utility_client.h" #include "content/public/utility/content_utility_client.h"
...@@ -18,22 +16,10 @@ class FilePath; ...@@ -18,22 +16,10 @@ class FilePath;
struct FileDescriptor; struct FileDescriptor;
} }
namespace gfx {
class Rect;
}
namespace metadata { namespace metadata {
class MediaMetadataParser; class MediaMetadataParser;
} }
namespace printing {
class PdfRenderSettings;
struct PwgRasterSettings;
struct PageRange;
}
namespace chrome {
class UtilityMessageHandler; class UtilityMessageHandler;
class ChromeContentUtilityClient : public content::ContentUtilityClient { class ChromeContentUtilityClient : public content::ContentUtilityClient {
...@@ -55,16 +41,6 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { ...@@ -55,16 +41,6 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {
void OnParseUpdateManifest(const std::string& xml); void OnParseUpdateManifest(const std::string& xml);
void OnDecodeImage(const std::vector<unsigned char>& encoded_data); void OnDecodeImage(const std::vector<unsigned char>& encoded_data);
void OnDecodeImageBase64(const std::string& encoded_data); void OnDecodeImageBase64(const std::string& encoded_data);
void OnRenderPDFPagesToMetafile(
IPC::PlatformFileForTransit pdf_transit,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
const std::vector<printing::PageRange>& page_ranges);
void OnRenderPDFPagesToPWGRaster(
IPC::PlatformFileForTransit pdf_transit,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
IPC::PlatformFileForTransit bitmap_transit);
void OnRobustJPEGDecodeImage( void OnRobustJPEGDecodeImage(
const std::vector<unsigned char>& encoded_data); const std::vector<unsigned char>& encoded_data);
void OnParseJSON(const std::string& json); void OnParseJSON(const std::string& json);
...@@ -75,29 +51,6 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { ...@@ -75,29 +51,6 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {
const base::FileDescriptor& dest_fd); const base::FileDescriptor& dest_fd);
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
#if defined(OS_WIN)
// Helper method for Windows.
// |highest_rendered_page_number| is set to -1 on failure to render any page.
// |page_ranges| is both input and output. If supplied as input, only the
// specified pages will be rendered. If an empty vector is supplied it will
// be filled with a range of all pages that were rendered.
bool RenderPDFToWinMetafile(
base::File pdf_file,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
std::vector<printing::PageRange>* page_ranges,
int* highest_rendered_page_number,
double* scale_factor);
#endif // defined(OS_WIN)
bool RenderPDFPagesToPWGRaster(
base::File pdf_file,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
base::File bitmap_file);
void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name);
void OnPatchFileBsdiff(const base::FilePath& input_file, void OnPatchFileBsdiff(const base::FilePath& input_file,
const base::FilePath& patch_file, const base::FilePath& patch_file,
const base::FilePath& output_file); const base::FilePath& output_file);
...@@ -151,6 +104,4 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { ...@@ -151,6 +104,4 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient {
DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient); DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient);
}; };
} // namespace chrome
#endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_ #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
#include "chrome/utility/chrome_content_utility_ipc_whitelist.h" #include "chrome/utility/chrome_content_utility_ipc_whitelist.h"
#include "chrome/common/chrome_utility_messages.h" #include "chrome/common/chrome_utility_messages.h"
namespace chrome {
const uint32 kMessageWhitelist[] = { const uint32 kMessageWhitelist[] = {
#ifdef OS_WIN #ifdef OS_WIN
ChromeUtilityHostMsg_GetAndEncryptWiFiCredentials::ID, ChromeUtilityHostMsg_GetAndEncryptWiFiCredentials::ID,
...@@ -16,5 +14,3 @@ const uint32 kMessageWhitelist[] = { ...@@ -16,5 +14,3 @@ const uint32 kMessageWhitelist[] = {
ChromeUtilityMsg_ImageWriter_Verify::ID}; ChromeUtilityMsg_ImageWriter_Verify::ID};
const size_t kMessageWhitelistSize = arraysize(kMessageWhitelist); const size_t kMessageWhitelistSize = arraysize(kMessageWhitelist);
} // namespace chrome
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "base/basictypes.h" #include "base/basictypes.h"
namespace chrome {
// This array contains the list of IPC messages that the utility process will // This array contains the list of IPC messages that the utility process will
// accept when running with elevated privileges. When new messages need to run // accept when running with elevated privileges. When new messages need to run
// with elevated privileges, add them here and be sure to add a security // with elevated privileges, add them here and be sure to add a security
...@@ -16,6 +14,4 @@ namespace chrome { ...@@ -16,6 +14,4 @@ namespace chrome {
extern const uint32 kMessageWhitelist[]; extern const uint32 kMessageWhitelist[];
extern const size_t kMessageWhitelistSize; extern const size_t kMessageWhitelistSize;
} // namespace chrome
#endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_IPC_WHITELIST_H_ #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_IPC_WHITELIST_H_
...@@ -18,8 +18,8 @@ class FilePath; ...@@ -18,8 +18,8 @@ class FilePath;
namespace image_writer { namespace image_writer {
// A handler for messages related to writing images. This class is added as a // A handler for messages related to writing images. This class is added as a
// handler in chrome::ChromeContentUtilityClient. // handler in ChromeContentUtilityClient.
class ImageWriterHandler : public chrome::UtilityMessageHandler { class ImageWriterHandler : public UtilityMessageHandler {
public: public:
ImageWriterHandler(); ImageWriterHandler();
virtual ~ImageWriterHandler(); virtual ~ImageWriterHandler();
......
...@@ -33,7 +33,7 @@ namespace local_discovery { ...@@ -33,7 +33,7 @@ namespace local_discovery {
class ServiceDiscoveryClient; class ServiceDiscoveryClient;
// Handles messages related to local discovery inside utility process. // Handles messages related to local discovery inside utility process.
class ServiceDiscoveryMessageHandler : public chrome::UtilityMessageHandler { class ServiceDiscoveryMessageHandler : public UtilityMessageHandler {
public: public:
ServiceDiscoveryMessageHandler(); ServiceDiscoveryMessageHandler();
virtual ~ServiceDiscoveryMessageHandler(); virtual ~ServiceDiscoveryMessageHandler();
......
...@@ -24,7 +24,7 @@ namespace metadata { ...@@ -24,7 +24,7 @@ namespace metadata {
// as a DataSource on a different thread. The utility thread must not be blocked // as a DataSource on a different thread. The utility thread must not be blocked
// for read operations to succeed. // for read operations to succeed.
class IPCDataSource: public media::DataSource, class IPCDataSource: public media::DataSource,
public chrome::UtilityMessageHandler { public UtilityMessageHandler {
public: public:
// May only be called on the utility thread. // May only be called on the utility thread.
explicit IPCDataSource(int64 total_size); explicit IPCDataSource(int64 total_size);
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/utility/printing_handler.h"
#include "base/file_util.h"
#include "base/lazy_instance.h"
#include "base/path_service.h"
#include "base/scoped_native_library.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_utility_printing_messages.h"
#include "chrome/utility/cloud_print/bitmap_image.h"
#include "chrome/utility/cloud_print/pwg_encoder.h"
#include "content/public/utility/utility_thread.h"
#include "printing/page_range.h"
#include "printing/pdf_render_settings.h"
#if defined(OS_WIN)
#include "base/win/iat_patch_function.h"
#include "printing/emf_win.h"
#include "ui/gfx/gdi_util.h"
#endif
#if defined(ENABLE_FULL_PRINTING)
#include "chrome/common/crash_keys.h"
#include "printing/backend/print_backend.h"
#endif
namespace {
bool Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
void ReleaseProcessIfNeeded() {
content::UtilityThread::Get()->ReleaseProcessIfNeeded();
}
class PdfFunctionsBase {
public:
PdfFunctionsBase() : render_pdf_to_bitmap_func_(NULL),
get_pdf_doc_info_func_(NULL) {}
bool Init() {
base::FilePath pdf_module_path;
if (!PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_module_path) ||
!base::PathExists(pdf_module_path)) {
return false;
}
pdf_lib_.Reset(base::LoadNativeLibrary(pdf_module_path, NULL));
if (!pdf_lib_.is_valid()) {
LOG(WARNING) << "Couldn't load PDF plugin";
return false;
}
render_pdf_to_bitmap_func_ =
reinterpret_cast<RenderPDFPageToBitmapProc>(
pdf_lib_.GetFunctionPointer("RenderPDFPageToBitmap"));
LOG_IF(WARNING, !render_pdf_to_bitmap_func_) <<
"Missing RenderPDFPageToBitmap";
get_pdf_doc_info_func_ =
reinterpret_cast<GetPDFDocInfoProc>(
pdf_lib_.GetFunctionPointer("GetPDFDocInfo"));
LOG_IF(WARNING, !get_pdf_doc_info_func_) << "Missing GetPDFDocInfo";
if (!render_pdf_to_bitmap_func_ || !get_pdf_doc_info_func_ ||
!PlatformInit(pdf_module_path, pdf_lib_)) {
Reset();
}
return IsValid();
}
bool IsValid() const {
return pdf_lib_.is_valid();
}
void Reset() {
pdf_lib_.Reset(NULL);
}
bool RenderPDFPageToBitmap(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi_x,
int dpi_y,
bool autorotate) {
if (!render_pdf_to_bitmap_func_)
return false;
return render_pdf_to_bitmap_func_(pdf_buffer, pdf_buffer_size, page_number,
bitmap_buffer, bitmap_width,
bitmap_height, dpi_x, dpi_y, autorotate);
}
bool GetPDFDocInfo(const void* pdf_buffer,
int buffer_size,
int* page_count,
double* max_page_width) {
if (!get_pdf_doc_info_func_)
return false;
return get_pdf_doc_info_func_(pdf_buffer, buffer_size, page_count,
max_page_width);
}
protected:
virtual bool PlatformInit(
const base::FilePath& pdf_module_path,
const base::ScopedNativeLibrary& pdf_lib) {
return true;
}
private:
// Exported by PDF plugin.
typedef bool (*RenderPDFPageToBitmapProc)(const void* pdf_buffer,
int pdf_buffer_size,
int page_number,
void* bitmap_buffer,
int bitmap_width,
int bitmap_height,
int dpi_x,
int dpi_y,
bool autorotate);
typedef bool (*GetPDFDocInfoProc)(const void* pdf_buffer,
int buffer_size, int* page_count,
double* max_page_width);
RenderPDFPageToBitmapProc render_pdf_to_bitmap_func_;
GetPDFDocInfoProc get_pdf_doc_info_func_;
base::ScopedNativeLibrary pdf_lib_;
DISALLOW_COPY_AND_ASSIGN(PdfFunctionsBase);
};
#if defined(OS_WIN)
// The 2 below IAT patch functions are almost identical to the code in
// render_process_impl.cc. This is needed to work around specific Windows APIs
// used by the Chrome PDF plugin that will fail in the sandbox.
static base::win::IATPatchFunction g_iat_patch_createdca;
HDC WINAPI UtilityProcess_CreateDCAPatch(LPCSTR driver_name,
LPCSTR device_name,
LPCSTR output,
const DEVMODEA* init_data) {
if (driver_name && (std::string("DISPLAY") == driver_name)) {
// CreateDC fails behind the sandbox, but not CreateCompatibleDC.
return CreateCompatibleDC(NULL);
}
NOTREACHED();
return CreateDCA(driver_name, device_name, output, init_data);
}
static base::win::IATPatchFunction g_iat_patch_get_font_data;
DWORD WINAPI UtilityProcess_GetFontDataPatch(
HDC hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD length) {
int rv = GetFontData(hdc, table, offset, buffer, length);
if (rv == GDI_ERROR && hdc) {
HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT));
LOGFONT logfont;
if (GetObject(font, sizeof(LOGFONT), &logfont)) {
content::UtilityThread::Get()->PreCacheFont(logfont);
rv = GetFontData(hdc, table, offset, buffer, length);
content::UtilityThread::Get()->ReleaseCachedFonts();
}
}
return rv;
}
class PdfFunctionsWin : public PdfFunctionsBase {
public:
PdfFunctionsWin() : render_pdf_to_dc_func_(NULL) {
}
bool PlatformInit(
const base::FilePath& pdf_module_path,
const base::ScopedNativeLibrary& pdf_lib) OVERRIDE {
// Patch the IAT for handling specific APIs known to fail in the sandbox.
if (!g_iat_patch_createdca.is_patched()) {
g_iat_patch_createdca.Patch(pdf_module_path.value().c_str(),
"gdi32.dll", "CreateDCA",
UtilityProcess_CreateDCAPatch);
}
if (!g_iat_patch_get_font_data.is_patched()) {
g_iat_patch_get_font_data.Patch(pdf_module_path.value().c_str(),
"gdi32.dll", "GetFontData",
UtilityProcess_GetFontDataPatch);
}
render_pdf_to_dc_func_ =
reinterpret_cast<RenderPDFPageToDCProc>(
pdf_lib.GetFunctionPointer("RenderPDFPageToDC"));
LOG_IF(WARNING, !render_pdf_to_dc_func_) << "Missing RenderPDFPageToDC";
return render_pdf_to_dc_func_ != NULL;
}
bool RenderPDFPageToDC(const void* pdf_buffer,
int buffer_size,
int page_number,
HDC dc,
int dpi_x,
int dpi_y,
int bounds_origin_x,
int bounds_origin_y,
int bounds_width,
int bounds_height,
bool fit_to_bounds,
bool stretch_to_bounds,
bool keep_aspect_ratio,
bool center_in_bounds,
bool autorotate) {
if (!render_pdf_to_dc_func_)
return false;
return render_pdf_to_dc_func_(pdf_buffer, buffer_size, page_number,
dc, dpi_x, dpi_y, bounds_origin_x,
bounds_origin_y, bounds_width, bounds_height,
fit_to_bounds, stretch_to_bounds,
keep_aspect_ratio, center_in_bounds,
autorotate);
}
private:
// Exported by PDF plugin.
typedef bool (*RenderPDFPageToDCProc)(
const void* pdf_buffer, int buffer_size, int page_number, HDC dc,
int dpi_x, int dpi_y, int bounds_origin_x, int bounds_origin_y,
int bounds_width, int bounds_height, bool fit_to_bounds,
bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds,
bool autorotate);
RenderPDFPageToDCProc render_pdf_to_dc_func_;
DISALLOW_COPY_AND_ASSIGN(PdfFunctionsWin);
};
typedef PdfFunctionsWin PdfFunctions;
#else // OS_WIN
typedef PdfFunctionsBase PdfFunctions;
#endif // OS_WIN
base::LazyInstance<PdfFunctions> g_pdf_lib = LAZY_INSTANCE_INITIALIZER;
} // namespace
PrintingHandler::PrintingHandler() {}
PrintingHandler::~PrintingHandler() {}
// static
void PrintingHandler::PreSandboxStartup() {
g_pdf_lib.Get().Init();
}
bool PrintingHandler::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintingHandler, message)
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
OnRenderPDFPagesToMetafile)
#endif
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
OnRenderPDFPagesToPWGRaster)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
OnGetPrinterCapsAndDefaults)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
OnGetPrinterSemanticCapsAndDefaults)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
void PrintingHandler::OnRenderPDFPagesToMetafile(
IPC::PlatformFileForTransit pdf_transit,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
const std::vector<printing::PageRange>& page_ranges_const) {
bool succeeded = false;
base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit);
int highest_rendered_page_number = 0;
double scale_factor = 1.0;
std::vector<printing::PageRange> page_ranges = page_ranges_const;
succeeded = RenderPDFToWinMetafile(pdf_file.Pass(),
metafile_path,
settings,
&page_ranges,
&highest_rendered_page_number,
&scale_factor);
if (succeeded) {
// TODO(vitalybuka|scottmg): http://crbug.com/170859. These could
// potentially be sent as each page is converted so that the spool could
// start sooner.
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded(
page_ranges, scale_factor));
} else {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed());
}
ReleaseProcessIfNeeded();
}
#endif
void PrintingHandler::OnRenderPDFPagesToPWGRaster(
IPC::PlatformFileForTransit pdf_transit,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
IPC::PlatformFileForTransit bitmap_transit) {
base::File pdf = IPC::PlatformFileForTransitToFile(pdf_transit);
base::File bitmap = IPC::PlatformFileForTransitToFile(bitmap_transit);
if (RenderPDFPagesToPWGRaster(pdf.Pass(), settings, bitmap_settings,
bitmap.Pass())) {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded());
} else {
Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed());
}
ReleaseProcessIfNeeded();
}
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
bool PrintingHandler::RenderPDFToWinMetafile(
base::File pdf_file,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
std::vector<printing::PageRange>* page_ranges,
int* highest_rendered_page_number,
double* scale_factor) {
DCHECK(page_ranges);
*highest_rendered_page_number = -1;
*scale_factor = 1.0;
if (!g_pdf_lib.Get().IsValid())
return false;
// TODO(sanjeevr): Add a method to the PDF DLL that takes in a file handle
// and a page range array. That way we don't need to read the entire PDF into
// memory.
int64 length = pdf_file.GetLength();
if (length < 0)
return false;
std::vector<char> buffer;
buffer.resize(length);
if (length != pdf_file.Read(0, &buffer.front(), length))
return false;
int total_page_count = 0;
if (!g_pdf_lib.Get().GetPDFDocInfo(&buffer.front(), buffer.size(),
&total_page_count, NULL)) {
return false;
}
// If no range supplied, do all pages.
if (page_ranges->empty()) {
printing::PageRange page_range_all;
page_range_all.from = 0;
page_range_all.to = total_page_count - 1;
page_ranges->push_back(page_range_all);
}
bool ret = false;
std::vector<printing::PageRange>::const_iterator iter;
for (iter = page_ranges->begin(); iter != page_ranges->end(); ++iter) {
for (int page_number = iter->from; page_number <= iter->to; ++page_number) {
if (page_number >= total_page_count)
break;
printing::Emf metafile;
metafile.InitToFile(metafile_path.InsertBeforeExtensionASCII(
base::StringPrintf(".%d", page_number)));
// We need to scale down DC to fit an entire page into DC available area.
// Current metafile is based on screen DC and have current screen size.
// Writing outside of those boundaries will result in the cut-off output.
// On metafiles (this is the case here), scaling down will still record
// original coordinates and we'll be able to print in full resolution.
// Before playback we'll need to counter the scaling up that will happen
// in the service (print_system_win.cc).
*scale_factor = gfx::CalculatePageScale(metafile.context(),
settings.area().right(),
settings.area().bottom());
gfx::ScaleDC(metafile.context(), *scale_factor);
// The underlying metafile is of type Emf and ignores the arguments passed
// to StartPage.
metafile.StartPage(gfx::Size(), gfx::Rect(), 1);
if (g_pdf_lib.Get().RenderPDFPageToDC(
&buffer.front(), buffer.size(), page_number, metafile.context(),
settings.dpi(), settings.dpi(), settings.area().x(),
settings.area().y(), settings.area().width(),
settings.area().height(), true, false, true, true,
settings.autorotate())) {
if (*highest_rendered_page_number < page_number)
*highest_rendered_page_number = page_number;
ret = true;
}
metafile.FinishPage();
metafile.FinishDocument();
}
}
return ret;
}
#endif // defined(WIN_PDF_METAFILE_FOR_PRINTING)
bool PrintingHandler::RenderPDFPagesToPWGRaster(
base::File pdf_file,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
base::File bitmap_file) {
bool autoupdate = true;
if (!g_pdf_lib.Get().IsValid())
return false;
base::File::Info info;
if (!pdf_file.GetInfo(&info) || info.size <= 0)
return false;
std::string data(info.size, 0);
int data_size = pdf_file.Read(0, &data[0], data.size());
if (data_size != static_cast<int>(data.size()))
return false;
int total_page_count = 0;
if (!g_pdf_lib.Get().GetPDFDocInfo(data.data(), data.size(),
&total_page_count, NULL)) {
return false;
}
cloud_print::PwgEncoder encoder;
std::string pwg_header;
encoder.EncodeDocumentHeader(&pwg_header);
int bytes_written = bitmap_file.WriteAtCurrentPos(pwg_header.data(),
pwg_header.size());
if (bytes_written != static_cast<int>(pwg_header.size()))
return false;
cloud_print::BitmapImage image(settings.area().size(),
cloud_print::BitmapImage::BGRA);
for (int i = 0; i < total_page_count; ++i) {
int page_number = i;
if (bitmap_settings.reverse_page_order) {
page_number = total_page_count - 1 - page_number;
}
if (!g_pdf_lib.Get().RenderPDFPageToBitmap(data.data(),
data.size(),
page_number,
image.pixel_data(),
image.size().width(),
image.size().height(),
settings.dpi(),
settings.dpi(),
autoupdate)) {
return false;
}
cloud_print::PwgHeaderInfo header_info;
header_info.dpi = settings.dpi();
header_info.total_pages = total_page_count;
// Transform odd pages.
if (page_number % 2) {
switch (bitmap_settings.odd_page_transform) {
case printing::TRANSFORM_NORMAL:
break;
case printing::TRANSFORM_ROTATE_180:
header_info.flipx = true;
header_info.flipy = true;
break;
case printing::TRANSFORM_FLIP_HORIZONTAL:
header_info.flipx = true;
break;
case printing::TRANSFORM_FLIP_VERTICAL:
header_info.flipy = true;
break;
}
}
if (bitmap_settings.rotate_all_pages) {
header_info.flipx = !header_info.flipx;
header_info.flipy = !header_info.flipy;
}
std::string pwg_page;
if (!encoder.EncodePage(image, header_info, &pwg_page))
return false;
bytes_written = bitmap_file.WriteAtCurrentPos(pwg_page.data(),
pwg_page.size());
if (bytes_written != static_cast<int>(pwg_page.size()))
return false;
}
return true;
}
void PrintingHandler::OnGetPrinterCapsAndDefaults(
const std::string& printer_name) {
scoped_refptr<printing::PrintBackend> print_backend =
printing::PrintBackend::CreateInstance(NULL);
printing::PrinterCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key(
print_backend->GetPrinterDriverInfo(printer_name));
if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) {
Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(
printer_name, printer_info));
} else {
Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed(
printer_name));
}
ReleaseProcessIfNeeded();
}
void PrintingHandler::OnGetPrinterSemanticCapsAndDefaults(
const std::string& printer_name) {
scoped_refptr<printing::PrintBackend> print_backend =
printing::PrintBackend::CreateInstance(NULL);
printing::PrinterSemanticCapsAndDefaults printer_info;
crash_keys::ScopedPrinterInfo crash_key(
print_backend->GetPrinterDriverInfo(printer_name));
if (print_backend->GetPrinterSemanticCapsAndDefaults(printer_name,
&printer_info)) {
Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded(
printer_name, printer_info));
} else {
Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed(
printer_name));
}
ReleaseProcessIfNeeded();
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_UTILITY_PRINTING_HANDLER_H_
#define CHROME_UTILITY_PRINTING_HANDLER_H_
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/utility/utility_message_handler.h"
#include "ipc/ipc_platform_file.h"
#if !defined(ENABLE_FULL_PRINTING)
#error "Full printing must be enabled"
#endif
namespace printing {
class PdfRenderSettings;
struct PwgRasterSettings;
struct PageRange;
}
// Dispatches IPCs for printing.
class PrintingHandler : public UtilityMessageHandler {
public:
PrintingHandler();
virtual ~PrintingHandler();
static void PreSandboxStartup();
// IPC::Listener:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
private:
// IPC message handlers.
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
void OnRenderPDFPagesToMetafile(
IPC::PlatformFileForTransit pdf_transit,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
const std::vector<printing::PageRange>& page_ranges);
#endif
void OnRenderPDFPagesToPWGRaster(
IPC::PlatformFileForTransit pdf_transit,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
IPC::PlatformFileForTransit bitmap_transit);
#if defined(WIN_PDF_METAFILE_FOR_PRINTING)
// Helper method for Windows.
// |highest_rendered_page_number| is set to -1 on failure to render any page.
// |page_ranges| is both input and output. If supplied as input, only the
// specified pages will be rendered. If an empty vector is supplied it will
// be filled with a range of all pages that were rendered.
bool RenderPDFToWinMetafile(
base::File pdf_file,
const base::FilePath& metafile_path,
const printing::PdfRenderSettings& settings,
std::vector<printing::PageRange>* page_ranges,
int* highest_rendered_page_number,
double* scale_factor);
#endif
bool RenderPDFPagesToPWGRaster(
base::File pdf_file,
const printing::PdfRenderSettings& settings,
const printing::PwgRasterSettings& bitmap_settings,
base::File bitmap_file);
void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name);
DISALLOW_COPY_AND_ASSIGN(PrintingHandler);
};
#endif // CHROME_UTILITY_PRINTING_HANDLER_H_
...@@ -14,7 +14,13 @@ ...@@ -14,7 +14,13 @@
#include "chrome/utility/importer/importer_creator.h" #include "chrome/utility/importer/importer_creator.h"
#include "content/public/utility/utility_thread.h" #include "content/public/utility/utility_thread.h"
namespace chrome { namespace {
bool Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
} // namespace
ProfileImportHandler::ProfileImportHandler() : items_to_import_(0) {} ProfileImportHandler::ProfileImportHandler() : items_to_import_(0) {}
...@@ -83,10 +89,3 @@ void ProfileImportHandler::ImporterCleanup() { ...@@ -83,10 +89,3 @@ void ProfileImportHandler::ImporterCleanup() {
import_thread_.reset(); import_thread_.reset();
content::UtilityThread::Get()->ReleaseProcessIfNeeded(); content::UtilityThread::Get()->ReleaseProcessIfNeeded();
} }
// static
bool ProfileImportHandler::Send(IPC::Message* message) {
return content::UtilityThread::Get()->Send(message);
}
} // namespace chrome
...@@ -23,8 +23,6 @@ namespace importer { ...@@ -23,8 +23,6 @@ namespace importer {
struct SourceProfile; struct SourceProfile;
} }
namespace chrome {
// Dispatches IPCs for out of process profile import. // Dispatches IPCs for out of process profile import.
class ProfileImportHandler : public UtilityMessageHandler { class ProfileImportHandler : public UtilityMessageHandler {
public: public:
...@@ -45,8 +43,6 @@ class ProfileImportHandler : public UtilityMessageHandler { ...@@ -45,8 +43,6 @@ class ProfileImportHandler : public UtilityMessageHandler {
// The following are used with out of process profile import: // The following are used with out of process profile import:
void ImporterCleanup(); void ImporterCleanup();
static bool Send(IPC::Message* message);
// Thread that importer runs on, while ProfileImportThread handles messages // Thread that importer runs on, while ProfileImportThread handles messages
// from the browser process. // from the browser process.
scoped_ptr<base::Thread> import_thread_; scoped_ptr<base::Thread> import_thread_;
...@@ -62,6 +58,4 @@ class ProfileImportHandler : public UtilityMessageHandler { ...@@ -62,6 +58,4 @@ class ProfileImportHandler : public UtilityMessageHandler {
scoped_refptr<Importer> importer_; scoped_refptr<Importer> importer_;
}; };
} // namespace chrome
#endif // CHROME_UTILITY_PROFILE_IMPORT_HANDLER_H_ #endif // CHROME_UTILITY_PROFILE_IMPORT_HANDLER_H_
...@@ -9,8 +9,6 @@ namespace IPC { ...@@ -9,8 +9,6 @@ namespace IPC {
class Message; class Message;
} }
namespace chrome {
class UtilityMessageHandler { class UtilityMessageHandler {
public: public:
virtual ~UtilityMessageHandler() {} virtual ~UtilityMessageHandler() {}
...@@ -20,7 +18,5 @@ class UtilityMessageHandler { ...@@ -20,7 +18,5 @@ class UtilityMessageHandler {
virtual bool OnMessageReceived(const IPC::Message& message) = 0; virtual bool OnMessageReceived(const IPC::Message& message) = 0;
}; };
} // namespace chrome
#endif // CHROME_UTILITY_UTILITY_MESSAGE_HANDLER_H_ #endif // CHROME_UTILITY_UTILITY_MESSAGE_HANDLER_H_
...@@ -105,6 +105,7 @@ enum IPCMessageStart { ...@@ -105,6 +105,7 @@ enum IPCMessageStart {
PushMessagingMsgStart, PushMessagingMsgStart,
GinJavaBridgeMsgStart, GinJavaBridgeMsgStart,
BatteryStatusMsgStart, BatteryStatusMsgStart,
UtilityPrintingMsgStart,
LastIPCMsgStart // Must come last. LastIPCMsgStart // Must come last.
}; };
......
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