OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/string16.h" | 10 #include "base/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 "printing/printed_pages_source.h" | 14 #include "printing/printed_pages_source.h" |
15 | 15 |
16 class TabContents; | 16 class TabContents; |
17 typedef TabContents TabContentsWrapper; | |
18 struct PrintHostMsg_DidPrintPage_Params; | 17 struct PrintHostMsg_DidPrintPage_Params; |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 class RenderProcessHost; | 20 class RenderProcessHost; |
22 } | 21 } |
23 | 22 |
24 namespace printing { | 23 namespace printing { |
25 | 24 |
26 class JobEventDetails; | 25 class JobEventDetails; |
27 class PrintJob; | 26 class PrintJob; |
28 class PrintJobWorkerOwner; | 27 class PrintJobWorkerOwner; |
29 class PrintViewManagerObserver; | 28 class PrintViewManagerObserver; |
30 | 29 |
31 // Manages the print commands in relation to a TabContentsWrapper. | 30 // Manages the print commands in relation to a TabContents. |
32 // TabContentsWrapper delegates a few printing related commands to this | 31 // TabContents delegates a few printing related commands to this |
33 // instance. | 32 // instance. |
34 class PrintViewManager : public content::NotificationObserver, | 33 class PrintViewManager : public content::NotificationObserver, |
35 public PrintedPagesSource, | 34 public PrintedPagesSource, |
36 public content::WebContentsObserver { | 35 public content::WebContentsObserver { |
37 public: | 36 public: |
38 explicit PrintViewManager(TabContentsWrapper* tab); | 37 explicit PrintViewManager(TabContents* tab); |
39 virtual ~PrintViewManager(); | 38 virtual ~PrintViewManager(); |
40 | 39 |
41 // Prints the current document immediately. Since the rendering is | 40 // Prints the current document immediately. Since the rendering is |
42 // asynchronous, the actual printing will not be completed on the return of | 41 // asynchronous, the actual printing will not be completed on the return of |
43 // this function. Returns false if printing is impossible at the moment. | 42 // this function. Returns false if printing is impossible at the moment. |
44 bool PrintNow(); | 43 bool PrintNow(); |
45 | 44 |
46 // Same as PrintNow(), but for the case where a user prints with the system | 45 // Same as PrintNow(), but for the case where a user prints with the system |
47 // dialog from print preview. | 46 // dialog from print preview. |
48 bool PrintForSystemDialogNow(); | 47 bool PrintForSystemDialogNow(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // control flow, print_job_ is initialized whenever possible. No-op is | 155 // control flow, print_job_ is initialized whenever possible. No-op is |
157 // print_job_ is initialized. | 156 // print_job_ is initialized. |
158 bool OpportunisticallyCreatePrintJob(int cookie); | 157 bool OpportunisticallyCreatePrintJob(int cookie); |
159 | 158 |
160 // Helper method for Print*Now(). | 159 // Helper method for Print*Now(). |
161 bool PrintNowInternal(IPC::Message* message); | 160 bool PrintNowInternal(IPC::Message* message); |
162 | 161 |
163 // Release the PrinterQuery associated with our |cookie_|. | 162 // Release the PrinterQuery associated with our |cookie_|. |
164 void ReleasePrinterQuery(); | 163 void ReleasePrinterQuery(); |
165 | 164 |
166 // TabContentsWrapper we're associated with. | 165 // TabContents we're associated with. |
167 TabContentsWrapper* tab_; | 166 TabContents* tab_; |
168 | 167 |
169 content::NotificationRegistrar registrar_; | 168 content::NotificationRegistrar registrar_; |
170 | 169 |
171 // Manages the low-level talk to the printer. | 170 // Manages the low-level talk to the printer. |
172 scoped_refptr<PrintJob> print_job_; | 171 scoped_refptr<PrintJob> print_job_; |
173 | 172 |
174 // Number of pages to print in the print job. | 173 // Number of pages to print in the print job. |
175 int number_pages_; | 174 int number_pages_; |
176 | 175 |
177 // Indication of success of the print job. | 176 // Indication of success of the print job. |
(...skipping 21 matching lines...) Expand all Loading... |
199 | 198 |
200 // Keeps track of the pending callback during scripted print preview. | 199 // Keeps track of the pending callback during scripted print preview. |
201 content::RenderProcessHost* scripted_print_preview_rph_; | 200 content::RenderProcessHost* scripted_print_preview_rph_; |
202 | 201 |
203 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); | 202 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); |
204 }; | 203 }; |
205 | 204 |
206 } // namespace printing | 205 } // namespace printing |
207 | 206 |
208 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 207 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
OLD | NEW |