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

Side by Side Diff: chrome/browser/printing/print_preview_pdf_generated_browsertest.cc

Issue 2633573002: Add Postscript Printing (Closed)
Patch Set: Merge Created 3 years, 10 months 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <fstream> 8 #include <fstream>
9 #include <iostream> 9 #include <iostream>
10 #include <iterator> 10 #include <iterator>
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "components/printing/common/print_messages.h" 43 #include "components/printing/common/print_messages.h"
44 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
45 #include "content/public/browser/web_ui_message_handler.h" 45 #include "content/public/browser/web_ui_message_handler.h"
46 #include "content/public/test/browser_test_utils.h" 46 #include "content/public/test/browser_test_utils.h"
47 #include "ipc/ipc_message_macros.h" 47 #include "ipc/ipc_message_macros.h"
48 #include "net/base/filename_util.h" 48 #include "net/base/filename_util.h"
49 #include "pdf/pdf.h" 49 #include "pdf/pdf.h"
50 #include "printing/pdf_render_settings.h" 50 #include "printing/pdf_render_settings.h"
51 #include "printing/units.h" 51 #include "printing/units.h"
52 #include "ui/gfx/codec/png_codec.h" 52 #include "ui/gfx/codec/png_codec.h"
53 #include "ui/gfx/geometry/point.h"
53 #include "ui/gfx/geometry/rect.h" 54 #include "ui/gfx/geometry/rect.h"
54 #include "url/gurl.h" 55 #include "url/gurl.h"
55 56
56 #if defined(OS_WIN) 57 #if defined(OS_WIN)
57 #include <fcntl.h> 58 #include <fcntl.h>
58 #include <io.h> 59 #include <io.h>
59 #endif 60 #endif
60 61
61 using content::WebContents; 62 using content::WebContents;
62 using content::WebContentsObserver; 63 using content::WebContentsObserver;
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // The image will be rotated if |width_in_pixels| is greater than 364 // The image will be rotated if |width_in_pixels| is greater than
364 // |height_in_pixels|. This is because the page will be rotated to fit 365 // |height_in_pixels|. This is because the page will be rotated to fit
365 // within a piece of paper. Therefore, |width_in_pixels| and 366 // within a piece of paper. Therefore, |width_in_pixels| and
366 // |height_in_pixels| have to be swapped or else they won't reflect the 367 // |height_in_pixels| have to be swapped or else they won't reflect the
367 // dimensions of the rotated page. 368 // dimensions of the rotated page.
368 if (width_in_pixels > height_in_pixels) 369 if (width_in_pixels > height_in_pixels)
369 std::swap(width_in_pixels, height_in_pixels); 370 std::swap(width_in_pixels, height_in_pixels);
370 371
371 total_height_in_pixels += height_in_pixels; 372 total_height_in_pixels += height_in_pixels;
372 gfx::Rect rect(width_in_pixels, height_in_pixels); 373 gfx::Rect rect(width_in_pixels, height_in_pixels);
373 PdfRenderSettings settings(rect, kDpi, true, 374 PdfRenderSettings settings(rect, gfx::Point(0, 0), kDpi, true,
374 PdfRenderSettings::Mode::NORMAL); 375 PdfRenderSettings::Mode::NORMAL);
375 376
376 int int_max = std::numeric_limits<int>::max(); 377 int int_max = std::numeric_limits<int>::max();
377 if (settings.area.width() > int_max / kColorChannels || 378 if (settings.area.width() > int_max / kColorChannels ||
378 settings.area.height() > 379 settings.area.height() >
379 int_max / (kColorChannels * settings.area.width())) { 380 int_max / (kColorChannels * settings.area.width())) {
380 FAIL() << "The dimensions of the image are too large." 381 FAIL() << "The dimensions of the image are too large."
381 << "Decrease the DPI or the dimensions of the image."; 382 << "Decrease the DPI or the dimensions of the image.";
382 } 383 }
383 384
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 // waiting for this message and start waiting for the image data. 632 // waiting for this message and start waiting for the image data.
632 std::cout << "#EOF\n"; 633 std::cout << "#EOF\n";
633 std::cout.flush(); 634 std::cout.flush();
634 635
635 SendPng(); 636 SendPng();
636 Reset(); 637 Reset();
637 } 638 }
638 } 639 }
639 640
640 } // namespace printing 641 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_job.cc ('k') | chrome/browser/printing/print_view_manager_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698