OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ |
6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/prefs/pref_member.h" | 9 #include "base/prefs/pref_member.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
15 #include "printing/printed_pages_source.h" | 15 #include "printing/printed_pages_source.h" |
16 | 16 |
17 struct PrintHostMsg_DidPrintPage_Params; | 17 struct PrintHostMsg_DidPrintPage_Params; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 class RenderViewHost; | 20 class RenderViewHost; |
21 } | 21 } |
22 | 22 |
23 namespace printing { | 23 namespace printing { |
24 | 24 |
25 class JobEventDetails; | 25 class JobEventDetails; |
26 class MetafilePlayer; | 26 class MetafilePlayer; |
27 class PdfToEmfConverter; | |
28 class PrintJob; | 27 class PrintJob; |
29 class PrintJobWorkerOwner; | 28 class PrintJobWorkerOwner; |
30 class PrintQueriesQueue; | 29 class PrintQueriesQueue; |
31 | 30 |
32 // Base class for managing the print commands for a WebContents. | 31 // Base class for managing the print commands for a WebContents. |
33 class PrintViewManagerBase : public content::NotificationObserver, | 32 class PrintViewManagerBase : public content::NotificationObserver, |
34 public PrintedPagesSource, | 33 public PrintedPagesSource, |
35 public content::WebContentsObserver { | 34 public content::WebContentsObserver { |
36 public: | 35 public: |
37 virtual ~PrintViewManagerBase(); | 36 virtual ~PrintViewManagerBase(); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 bool RunInnerMessageLoop(); | 126 bool RunInnerMessageLoop(); |
128 | 127 |
129 // In the case of Scripted Printing, where the renderer is controlling the | 128 // In the case of Scripted Printing, where the renderer is controlling the |
130 // control flow, print_job_ is initialized whenever possible. No-op is | 129 // control flow, print_job_ is initialized whenever possible. No-op is |
131 // print_job_ is initialized. | 130 // print_job_ is initialized. |
132 bool OpportunisticallyCreatePrintJob(int cookie); | 131 bool OpportunisticallyCreatePrintJob(int cookie); |
133 | 132 |
134 // Release the PrinterQuery associated with our |cookie_|. | 133 // Release the PrinterQuery associated with our |cookie_|. |
135 void ReleasePrinterQuery(); | 134 void ReleasePrinterQuery(); |
136 | 135 |
137 #if defined(OS_WIN) | |
138 // Called on completion of converting the pdf to emf. | |
139 void OnPdfToEmfConverted(const PrintHostMsg_DidPrintPage_Params& params, | |
140 double scale_factor, | |
141 ScopedVector<MetafilePlayer>* emf_files); | |
142 #endif // OS_WIN | |
143 | |
144 content::NotificationRegistrar registrar_; | 136 content::NotificationRegistrar registrar_; |
145 | 137 |
146 // Manages the low-level talk to the printer. | 138 // Manages the low-level talk to the printer. |
147 scoped_refptr<PrintJob> print_job_; | 139 scoped_refptr<PrintJob> print_job_; |
148 | 140 |
149 // Number of pages to print in the print job. | 141 // Number of pages to print in the print job. |
150 int number_pages_; | 142 int number_pages_; |
151 | 143 |
152 // Indication of success of the print job. | 144 // Indication of success of the print job. |
153 bool printing_succeeded_; | 145 bool printing_succeeded_; |
154 | 146 |
155 // Running an inner message loop inside RenderAllMissingPagesNow(). This means | 147 // Running an inner message loop inside RenderAllMissingPagesNow(). This means |
156 // we are _blocking_ until all the necessary pages have been rendered or the | 148 // we are _blocking_ until all the necessary pages have been rendered or the |
157 // print settings are being loaded. | 149 // print settings are being loaded. |
158 bool inside_inner_message_loop_; | 150 bool inside_inner_message_loop_; |
159 | 151 |
160 #if !defined(OS_MACOSX) | 152 #if !defined(OS_MACOSX) |
161 // Set to true when OnDidPrintPage() should be expecting the first page. | 153 // Set to true when OnDidPrintPage() should be expecting the first page. |
162 bool expecting_first_page_; | 154 bool expecting_first_page_; |
163 #endif // OS_MACOSX | 155 #endif // OS_MACOSX |
164 | 156 |
165 #if defined(OS_WIN) | |
166 scoped_ptr<PdfToEmfConverter> pdf_to_emf_converter_; | |
167 #endif // OS_WIN | |
168 | |
169 // The document cookie of the current PrinterQuery. | 157 // The document cookie of the current PrinterQuery. |
170 int cookie_; | 158 int cookie_; |
171 | 159 |
172 // Whether printing is enabled. | 160 // Whether printing is enabled. |
173 BooleanPrefMember printing_enabled_; | 161 BooleanPrefMember printing_enabled_; |
174 | 162 |
175 scoped_refptr<printing::PrintQueriesQueue> queue_; | 163 scoped_refptr<printing::PrintQueriesQueue> queue_; |
176 | 164 |
177 DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBase); | 165 DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBase); |
178 }; | 166 }; |
179 | 167 |
180 } // namespace printing | 168 } // namespace printing |
181 | 169 |
182 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ | 170 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ |
OLD | NEW |