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

Side by Side Diff: chrome/utility/printing_handler.cc

Issue 702603004: Renamed DISABLE_BASIC_PRINTING and ENABLE_FULL_PRINTING. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wed Nov 5 02:31:54 PST 2014 Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/utility/printing_handler.h" 5 #include "chrome/utility/printing_handler.h"
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/scoped_native_library.h" 10 #include "base/scoped_native_library.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_utility_printing_messages.h" 12 #include "chrome/common/chrome_utility_printing_messages.h"
13 #include "chrome/utility/cloud_print/bitmap_image.h" 13 #include "chrome/utility/cloud_print/bitmap_image.h"
14 #include "chrome/utility/cloud_print/pwg_encoder.h" 14 #include "chrome/utility/cloud_print/pwg_encoder.h"
15 #include "content/public/utility/utility_thread.h" 15 #include "content/public/utility/utility_thread.h"
16 #include "printing/page_range.h" 16 #include "printing/page_range.h"
17 #include "printing/pdf_render_settings.h" 17 #include "printing/pdf_render_settings.h"
18 18
19 #if defined(OS_WIN) 19 #if defined(OS_WIN)
20 #include "base/win/iat_patch_function.h" 20 #include "base/win/iat_patch_function.h"
21 #include "printing/emf_win.h" 21 #include "printing/emf_win.h"
22 #include "ui/gfx/gdi_util.h" 22 #include "ui/gfx/gdi_util.h"
23 #endif 23 #endif
24 24
25 #if defined(ENABLE_FULL_PRINTING) 25 #if defined(ENABLE_PRINT_PREVIEW)
26 #include "chrome/common/crash_keys.h" 26 #include "chrome/common/crash_keys.h"
27 #include "printing/backend/print_backend.h" 27 #include "printing/backend/print_backend.h"
28 #endif 28 #endif
29 29
30 namespace { 30 namespace {
31 31
32 bool Send(IPC::Message* message) { 32 bool Send(IPC::Message* message) {
33 return content::UtilityThread::Get()->Send(message); 33 return content::UtilityThread::Get()->Send(message);
34 } 34 }
35 35
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 bool handled = true; 260 bool handled = true;
261 IPC_BEGIN_MESSAGE_MAP(PrintingHandler, message) 261 IPC_BEGIN_MESSAGE_MAP(PrintingHandler, message)
262 #if defined(OS_WIN) 262 #if defined(OS_WIN)
263 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles, 263 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
264 OnRenderPDFPagesToMetafile) 264 OnRenderPDFPagesToMetafile)
265 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage, 265 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage,
266 OnRenderPDFPagesToMetafileGetPage) 266 OnRenderPDFPagesToMetafileGetPage)
267 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop, 267 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop,
268 OnRenderPDFPagesToMetafileStop) 268 OnRenderPDFPagesToMetafileStop)
269 #endif // OS_WIN 269 #endif // OS_WIN
270 #if defined(ENABLE_FULL_PRINTING) 270 #if defined(ENABLE_PRINT_PREVIEW)
271 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster, 271 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
272 OnRenderPDFPagesToPWGRaster) 272 OnRenderPDFPagesToPWGRaster)
273 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, 273 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
274 OnGetPrinterCapsAndDefaults) 274 OnGetPrinterCapsAndDefaults)
275 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, 275 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
276 OnGetPrinterSemanticCapsAndDefaults) 276 OnGetPrinterSemanticCapsAndDefaults)
277 #endif // ENABLE_FULL_PRINTING 277 #endif // ENABLE_PRINT_PREVIEW
278 IPC_MESSAGE_UNHANDLED(handled = false) 278 IPC_MESSAGE_UNHANDLED(handled = false)
279 IPC_END_MESSAGE_MAP() 279 IPC_END_MESSAGE_MAP()
280 return handled; 280 return handled;
281 } 281 }
282 282
283 #if defined(OS_WIN) 283 #if defined(OS_WIN)
284 void PrintingHandler::OnRenderPDFPagesToMetafile( 284 void PrintingHandler::OnRenderPDFPagesToMetafile(
285 IPC::PlatformFileForTransit pdf_transit, 285 IPC::PlatformFileForTransit pdf_transit,
286 const printing::PdfRenderSettings& settings) { 286 const printing::PdfRenderSettings& settings) {
287 pdf_rendering_settings_ = settings; 287 pdf_rendering_settings_ = settings;
(...skipping 13 matching lines...) Expand all
301 Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone( 301 Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone(
302 success, scale_factor)); 302 success, scale_factor));
303 } 303 }
304 304
305 void PrintingHandler::OnRenderPDFPagesToMetafileStop() { 305 void PrintingHandler::OnRenderPDFPagesToMetafileStop() {
306 ReleaseProcessIfNeeded(); 306 ReleaseProcessIfNeeded();
307 } 307 }
308 308
309 #endif // OS_WIN 309 #endif // OS_WIN
310 310
311 #if defined(ENABLE_FULL_PRINTING) 311 #if defined(ENABLE_PRINT_PREVIEW)
312 void PrintingHandler::OnRenderPDFPagesToPWGRaster( 312 void PrintingHandler::OnRenderPDFPagesToPWGRaster(
313 IPC::PlatformFileForTransit pdf_transit, 313 IPC::PlatformFileForTransit pdf_transit,
314 const printing::PdfRenderSettings& settings, 314 const printing::PdfRenderSettings& settings,
315 const printing::PwgRasterSettings& bitmap_settings, 315 const printing::PwgRasterSettings& bitmap_settings,
316 IPC::PlatformFileForTransit bitmap_transit) { 316 IPC::PlatformFileForTransit bitmap_transit) {
317 base::File pdf = IPC::PlatformFileForTransitToFile(pdf_transit); 317 base::File pdf = IPC::PlatformFileForTransitToFile(pdf_transit);
318 base::File bitmap = IPC::PlatformFileForTransitToFile(bitmap_transit); 318 base::File bitmap = IPC::PlatformFileForTransitToFile(bitmap_transit);
319 if (RenderPDFPagesToPWGRaster(pdf.Pass(), settings, bitmap_settings, 319 if (RenderPDFPagesToPWGRaster(pdf.Pass(), settings, bitmap_settings,
320 bitmap.Pass())) { 320 bitmap.Pass())) {
321 Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded()); 321 Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded());
322 } else { 322 } else {
323 Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed()); 323 Send(new ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed());
324 } 324 }
325 ReleaseProcessIfNeeded(); 325 ReleaseProcessIfNeeded();
326 } 326 }
327 #endif // ENABLE_FULL_PRINTING 327 #endif // ENABLE_PRINT_PREVIEW
328 328
329 #if defined(OS_WIN) 329 #if defined(OS_WIN)
330 int PrintingHandler::LoadPDF(base::File pdf_file) { 330 int PrintingHandler::LoadPDF(base::File pdf_file) {
331 if (!g_pdf_lib.Get().IsValid()) 331 if (!g_pdf_lib.Get().IsValid())
332 return 0; 332 return 0;
333 333
334 int64 length64 = pdf_file.GetLength(); 334 int64 length64 = pdf_file.GetLength();
335 if (length64 <= 0 || length64 > std::numeric_limits<int>::max()) 335 if (length64 <= 0 || length64 > std::numeric_limits<int>::max())
336 return 0; 336 return 0;
337 int length = static_cast<int>(length64); 337 int length = static_cast<int>(length64);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 pdf_rendering_settings_.autorotate())) { 388 pdf_rendering_settings_.autorotate())) {
389 return false; 389 return false;
390 } 390 }
391 metafile.FinishPage(); 391 metafile.FinishPage();
392 metafile.FinishDocument(); 392 metafile.FinishDocument();
393 return metafile.SaveTo(&output_file); 393 return metafile.SaveTo(&output_file);
394 } 394 }
395 395
396 #endif // OS_WIN 396 #endif // OS_WIN
397 397
398 #if defined(ENABLE_FULL_PRINTING) 398 #if defined(ENABLE_PRINT_PREVIEW)
399 bool PrintingHandler::RenderPDFPagesToPWGRaster( 399 bool PrintingHandler::RenderPDFPagesToPWGRaster(
400 base::File pdf_file, 400 base::File pdf_file,
401 const printing::PdfRenderSettings& settings, 401 const printing::PdfRenderSettings& settings,
402 const printing::PwgRasterSettings& bitmap_settings, 402 const printing::PwgRasterSettings& bitmap_settings,
403 base::File bitmap_file) { 403 base::File bitmap_file) {
404 bool autoupdate = true; 404 bool autoupdate = true;
405 if (!g_pdf_lib.Get().IsValid()) 405 if (!g_pdf_lib.Get().IsValid())
406 return false; 406 return false;
407 407
408 base::File::Info info; 408 base::File::Info info;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 if (print_backend->GetPrinterSemanticCapsAndDefaults(printer_name, 519 if (print_backend->GetPrinterSemanticCapsAndDefaults(printer_name,
520 &printer_info)) { 520 &printer_info)) {
521 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded( 521 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded(
522 printer_name, printer_info)); 522 printer_name, printer_info));
523 } else { 523 } else {
524 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed( 524 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed(
525 printer_name)); 525 printer_name));
526 } 526 }
527 ReleaseProcessIfNeeded(); 527 ReleaseProcessIfNeeded();
528 } 528 }
529 #endif // ENABLE_FULL_PRINTING 529 #endif // ENABLE_PRINT_PREVIEW
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698