OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer/mock_printer.h" | 5 #include "chrome/renderer/mock_printer.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/shared_memory.h" | 8 #include "base/shared_memory.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/common/render_messages_params.h" | 10 #include "chrome/common/render_messages_params.h" |
11 #include "ipc/ipc_message_utils.h" | 11 #include "ipc/ipc_message_utils.h" |
12 #include "printing/units.h" | 12 #include "printing/units.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
| 15 MockPrinterPage::MockPrinterPage(const void* source_data, |
| 16 uint32 source_size, |
| 17 const printing::Image& image) |
| 18 : source_size_(source_size), |
| 19 image_(image) { |
| 20 // Create copies of the source data |
| 21 source_data_.reset(new uint8[source_size]); |
| 22 if (source_data_.get()) |
| 23 memcpy(source_data_.get(), source_data, source_size); |
| 24 } |
| 25 |
| 26 MockPrinterPage::~MockPrinterPage() {} |
| 27 |
15 MockPrinter::MockPrinter() | 28 MockPrinter::MockPrinter() |
16 : printable_width_(0), | 29 : printable_width_(0), |
17 printable_height_(0), | 30 printable_height_(0), |
18 dpi_(printing::kPointsPerInch), | 31 dpi_(printing::kPointsPerInch), |
19 max_shrink_(2.0), | 32 max_shrink_(2.0), |
20 min_shrink_(1.25), | 33 min_shrink_(1.25), |
21 desired_dpi_(72), | 34 desired_dpi_(72), |
22 selection_only_(false), | 35 selection_only_(false), |
23 document_cookie_(-1), | 36 document_cookie_(-1), |
24 current_document_cookie_(0), | 37 current_document_cookie_(0), |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 if (printer_status_ != PRINTER_READY || page >= pages_.size()) | 202 if (printer_status_ != PRINTER_READY || page >= pages_.size()) |
190 return false; | 203 return false; |
191 | 204 |
192 pages_[page]->image().SaveToPng(filepath); | 205 pages_[page]->image().SaveToPng(filepath); |
193 return true; | 206 return true; |
194 } | 207 } |
195 | 208 |
196 int MockPrinter::CreateDocumentCookie() { | 209 int MockPrinter::CreateDocumentCookie() { |
197 return ++current_document_cookie_; | 210 return ++current_document_cookie_; |
198 } | 211 } |
OLD | NEW |