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 "chrome/service/service_utility_process_host.h" |
11 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
13 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 16 #include "printing/metafile_impl.h" |
15 #include "printing/printed_pages_source.h" | 17 #include "printing/printed_pages_source.h" |
16 | 18 |
17 struct PrintHostMsg_DidPrintPage_Params; | 19 struct PrintHostMsg_DidPrintPage_Params; |
18 | 20 |
19 namespace content { | 21 namespace content { |
20 class RenderViewHost; | 22 class RenderViewHost; |
21 } | 23 } |
22 | 24 |
23 namespace printing { | 25 namespace printing { |
24 | 26 |
25 class JobEventDetails; | 27 class JobEventDetails; |
26 class PrintJob; | 28 class PrintJob; |
27 class PrintJobWorkerOwner; | 29 class PrintJobWorkerOwner; |
28 class PrintQueriesQueue; | 30 class PrintQueriesQueue; |
29 | 31 |
30 // Base class for managing the print commands for a WebContents. | 32 // Base class for managing the print commands for a WebContents. |
31 class PrintViewManagerBase : public content::NotificationObserver, | 33 class PrintViewManagerBase : public content::NotificationObserver, |
32 public PrintedPagesSource, | 34 public PrintedPagesSource, |
33 public content::WebContentsObserver { | 35 public content::WebContentsObserver |
| 36 #if 0 && defined(OS_WIN) && !PRINTING_USE_EMF_METAFILE |
| 37 , public ServiceUtilityProcessHost::Client |
| 38 #endif |
| 39 { |
34 public: | 40 public: |
35 virtual ~PrintViewManagerBase(); | 41 virtual ~PrintViewManagerBase(); |
36 | 42 |
37 // Prints the current document immediately. Since the rendering is | 43 // Prints the current document immediately. Since the rendering is |
38 // asynchronous, the actual printing will not be completed on the return of | 44 // asynchronous, the actual printing will not be completed on the return of |
39 // this function. Returns false if printing is impossible at the moment. | 45 // this function. Returns false if printing is impossible at the moment. |
40 virtual bool PrintNow(); | 46 virtual bool PrintNow(); |
41 | 47 |
42 // Whether to block scripted printing for our tab or not. | 48 // Whether to block scripted printing for our tab or not. |
43 void UpdateScriptedPrintingBlocked(); | 49 void UpdateScriptedPrintingBlocked(); |
44 | 50 |
45 // PrintedPagesSource implementation. | 51 // PrintedPagesSource implementation. |
46 virtual base::string16 RenderSourceName() OVERRIDE; | 52 virtual base::string16 RenderSourceName() OVERRIDE; |
47 | 53 |
| 54 #if 0 && defined(OS_WIN) && !PRINTING_USE_EMF_METAFILE |
| 55 // ServiceUtilityProcessHost::Client implementation: |
| 56 virtual void OnRenderPDFPagesToMetafileSucceeded( |
| 57 const printing::Emf& metafile, |
| 58 int highest_rendered_page_number, |
| 59 double scale_factor) OVERRIDE; |
| 60 #endif |
| 61 |
48 protected: | 62 protected: |
49 explicit PrintViewManagerBase(content::WebContents* web_contents); | 63 explicit PrintViewManagerBase(content::WebContents* web_contents); |
50 | 64 |
51 // Helper method for Print*Now(). | 65 // Helper method for Print*Now(). |
52 bool PrintNowInternal(IPC::Message* message); | 66 bool PrintNowInternal(IPC::Message* message); |
53 | 67 |
54 // Terminates or cancels the print job if one was pending. | 68 // Terminates or cancels the print job if one was pending. |
55 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; | 69 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; |
56 | 70 |
57 // content::WebContentsObserver implementation. | 71 // content::WebContentsObserver implementation. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 bool RunInnerMessageLoop(); | 137 bool RunInnerMessageLoop(); |
124 | 138 |
125 // In the case of Scripted Printing, where the renderer is controlling the | 139 // In the case of Scripted Printing, where the renderer is controlling the |
126 // control flow, print_job_ is initialized whenever possible. No-op is | 140 // control flow, print_job_ is initialized whenever possible. No-op is |
127 // print_job_ is initialized. | 141 // print_job_ is initialized. |
128 bool OpportunisticallyCreatePrintJob(int cookie); | 142 bool OpportunisticallyCreatePrintJob(int cookie); |
129 | 143 |
130 // Release the PrinterQuery associated with our |cookie_|. | 144 // Release the PrinterQuery associated with our |cookie_|. |
131 void ReleasePrinterQuery(); | 145 void ReleasePrinterQuery(); |
132 | 146 |
| 147 #if 0 && defined(OS_WIN) && !PRINTING_USE_EMF_METAFILE |
| 148 // XXX |
| 149 void ConvertPDFToEMF(scoped_ptr<NativeMetafile> metafile); |
| 150 #endif |
| 151 |
133 content::NotificationRegistrar registrar_; | 152 content::NotificationRegistrar registrar_; |
134 | 153 |
135 // Manages the low-level talk to the printer. | 154 // Manages the low-level talk to the printer. |
136 scoped_refptr<PrintJob> print_job_; | 155 scoped_refptr<PrintJob> print_job_; |
137 | 156 |
138 // Number of pages to print in the print job. | 157 // Number of pages to print in the print job. |
139 int number_pages_; | 158 int number_pages_; |
140 | 159 |
141 // Indication of success of the print job. | 160 // Indication of success of the print job. |
142 bool printing_succeeded_; | 161 bool printing_succeeded_; |
143 | 162 |
144 // Running an inner message loop inside RenderAllMissingPagesNow(). This means | 163 // Running an inner message loop inside RenderAllMissingPagesNow(). This means |
145 // we are _blocking_ until all the necessary pages have been rendered or the | 164 // we are _blocking_ until all the necessary pages have been rendered or the |
146 // print settings are being loaded. | 165 // print settings are being loaded. |
147 bool inside_inner_message_loop_; | 166 bool inside_inner_message_loop_; |
148 | 167 |
149 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 168 #if (defined(OS_POSIX) && !defined(OS_MACOSX)) || \ |
| 169 (defined(OS_WIN) && !PRINTING_USE_EMF_METAFILE) |
150 // Set to true when OnDidPrintPage() should be expecting the first page. | 170 // Set to true when OnDidPrintPage() should be expecting the first page. |
151 bool expecting_first_page_; | 171 bool expecting_first_page_; |
152 #endif | 172 #endif |
153 | 173 |
154 // The document cookie of the current PrinterQuery. | 174 // The document cookie of the current PrinterQuery. |
155 int cookie_; | 175 int cookie_; |
156 | 176 |
157 // Whether printing is enabled. | 177 // Whether printing is enabled. |
158 BooleanPrefMember printing_enabled_; | 178 BooleanPrefMember printing_enabled_; |
159 | 179 |
160 scoped_refptr<printing::PrintQueriesQueue> queue_; | 180 scoped_refptr<printing::PrintQueriesQueue> queue_; |
161 | 181 |
162 DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBase); | 182 DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBase); |
163 }; | 183 }; |
164 | 184 |
165 } // namespace printing | 185 } // namespace printing |
166 | 186 |
167 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ | 187 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASE_H_ |
OLD | NEW |