OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_RENDERER_MOCK_PRINTER_H_ | 5 #ifndef CHROME_RENDERER_MOCK_PRINTER_H_ |
6 #define CHROME_RENDERER_MOCK_PRINTER_H_ | 6 #define CHROME_RENDERER_MOCK_PRINTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/string16.h" | 15 #include "base/string16.h" |
16 #include "printing/image.h" | 16 #include "printing/image.h" |
| 17 #include "ui/gfx/rect.h" |
17 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
18 | 19 |
19 struct PrintMsg_Print_Params; | 20 struct PrintMsg_Print_Params; |
20 struct PrintMsg_PrintPages_Params; | 21 struct PrintMsg_PrintPages_Params; |
21 struct PrintHostMsg_DidPrintPage_Params; | 22 struct PrintHostMsg_DidPrintPage_Params; |
22 | 23 |
23 // A class which represents an output page used in the MockPrinter class. | 24 // A class which represents an output page used in the MockPrinter class. |
24 // The MockPrinter class stores output pages in a vector, so, this class | 25 // The MockPrinter class stores output pages in a vector, so, this class |
25 // inherits the base::RefCounted<> class so that the MockPrinter class can use | 26 // inherits the base::RefCounted<> class so that the MockPrinter class can use |
26 // a smart pointer of this object (i.e. scoped_refptr<>). | 27 // a smart pointer of this object (i.e. scoped_refptr<>). |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void SetDefaultPrintSettings(const PrintMsg_Print_Params& params); | 72 void SetDefaultPrintSettings(const PrintMsg_Print_Params& params); |
72 void UseInvalidSettings(); | 73 void UseInvalidSettings(); |
73 | 74 |
74 // Functions that handles IPC events. | 75 // Functions that handles IPC events. |
75 void GetDefaultPrintSettings(PrintMsg_Print_Params* params); | 76 void GetDefaultPrintSettings(PrintMsg_Print_Params* params); |
76 void ScriptedPrint(int cookie, | 77 void ScriptedPrint(int cookie, |
77 int expected_pages_count, | 78 int expected_pages_count, |
78 bool has_selection, | 79 bool has_selection, |
79 PrintMsg_PrintPages_Params* settings); | 80 PrintMsg_PrintPages_Params* settings); |
80 void UpdateSettings(int cookie, PrintMsg_PrintPages_Params* params, | 81 void UpdateSettings(int cookie, PrintMsg_PrintPages_Params* params, |
81 const std::vector<int>& page_range_array); | 82 const std::vector<int>& page_range_array, |
| 83 int margins_type); |
82 void SetPrintedPagesCount(int cookie, int number_pages); | 84 void SetPrintedPagesCount(int cookie, int number_pages); |
83 void PrintPage(const PrintHostMsg_DidPrintPage_Params& params); | 85 void PrintPage(const PrintHostMsg_DidPrintPage_Params& params); |
84 | 86 |
85 // Functions that retrieve the output pages. | 87 // Functions that retrieve the output pages. |
86 Status GetPrinterStatus() const { return printer_status_; } | 88 Status GetPrinterStatus() const { return printer_status_; } |
87 int GetPrintedPages() const; | 89 int GetPrintedPages() const; |
88 | 90 |
89 // Get a pointer to the printed page, returns NULL if pageno has not been | 91 // Get a pointer to the printed page, returns NULL if pageno has not been |
90 // printed. The pointer is for read only view and should not be deleted. | 92 // printed. The pointer is for read only view and should not be deleted. |
91 const MockPrinterPage* GetPrintedPage(unsigned int pageno) const; | 93 const MockPrinterPage* GetPrintedPage(unsigned int pageno) const; |
(...skipping 11 matching lines...) Expand all Loading... |
103 | 105 |
104 private: | 106 private: |
105 // Helper function to fill the fields in |params|. | 107 // Helper function to fill the fields in |params|. |
106 void SetPrintParams(PrintMsg_Print_Params* params); | 108 void SetPrintParams(PrintMsg_Print_Params* params); |
107 | 109 |
108 // In pixels according to dpi_x and dpi_y. | 110 // In pixels according to dpi_x and dpi_y. |
109 gfx::Size page_size_; | 111 gfx::Size page_size_; |
110 gfx::Size content_size_; | 112 gfx::Size content_size_; |
111 int margin_left_; | 113 int margin_left_; |
112 int margin_top_; | 114 int margin_top_; |
| 115 gfx::Rect printable_area_; |
113 | 116 |
114 // Specifies dots per inch. | 117 // Specifies dots per inch. |
115 double dpi_; | 118 double dpi_; |
116 double max_shrink_; | 119 double max_shrink_; |
117 double min_shrink_; | 120 double min_shrink_; |
118 | 121 |
119 // Desired apparent dpi on paper. | 122 // Desired apparent dpi on paper. |
120 int desired_dpi_; | 123 int desired_dpi_; |
121 | 124 |
122 // Print selection. | 125 // Print selection. |
123 bool selection_only_; | 126 bool selection_only_; |
124 | 127 |
125 // Cookie for the document to ensure correctness. | 128 // Cookie for the document to ensure correctness. |
126 int document_cookie_; | 129 int document_cookie_; |
127 int current_document_cookie_; | 130 int current_document_cookie_; |
128 | 131 |
129 // The current status of this printer. | 132 // The current status of this printer. |
130 Status printer_status_; | 133 Status printer_status_; |
131 | 134 |
132 // The output of a printing job. | 135 // The output of a printing job. |
133 int number_pages_; | 136 int number_pages_; |
134 int page_number_; | 137 int page_number_; |
135 | 138 |
136 // Used only in the preview sequence. | 139 // Used only in the preview sequence. |
137 bool is_first_request_; | 140 bool is_first_request_; |
| 141 bool print_to_pdf_; |
138 int preview_request_id_; | 142 int preview_request_id_; |
139 | 143 |
140 // Used for displaying headers and footers. | 144 // Used for displaying headers and footers. |
141 bool display_header_footer_; | 145 bool display_header_footer_; |
142 string16 date_; | 146 string16 date_; |
143 string16 title_; | 147 string16 title_; |
144 string16 url_; | 148 string16 url_; |
145 | 149 |
146 // Used for generating invalid settings. | 150 // Used for generating invalid settings. |
147 bool use_invalid_settings_; | 151 bool use_invalid_settings_; |
148 | 152 |
149 std::vector<scoped_refptr<MockPrinterPage> > pages_; | 153 std::vector<scoped_refptr<MockPrinterPage> > pages_; |
150 | 154 |
151 DISALLOW_COPY_AND_ASSIGN(MockPrinter); | 155 DISALLOW_COPY_AND_ASSIGN(MockPrinter); |
152 }; | 156 }; |
153 | 157 |
154 #endif // CHROME_RENDERER_MOCK_PRINTER_H_ | 158 #endif // CHROME_RENDERER_MOCK_PRINTER_H_ |
OLD | NEW |