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_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/browser/tab_contents/tab_contents_observer.h" | 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
12 #include "content/common/notification_observer.h" | 12 #include "content/common/notification_observer.h" |
13 #include "content/common/notification_registrar.h" | 13 #include "content/common/notification_registrar.h" |
14 #include "printing/printed_pages_source.h" | 14 #include "printing/printed_pages_source.h" |
15 | 15 |
16 class RenderViewHost; | 16 class RenderViewHost; |
17 class TabContents; | 17 class TabContentsWrapper; |
18 struct PrintHostMsg_DidPrintPage_Params; | 18 struct PrintHostMsg_DidPrintPage_Params; |
19 | 19 |
20 namespace printing { | 20 namespace printing { |
21 | 21 |
22 class JobEventDetails; | 22 class JobEventDetails; |
23 class PrintJob; | 23 class PrintJob; |
24 class PrintJobWorkerOwner; | 24 class PrintJobWorkerOwner; |
25 | 25 |
26 // Manages the print commands in relation to a TabContents. TabContents | 26 // Manages the print commands in relation to a TabContents. TabContents |
27 // delegates a few printing related commands to this instance. | 27 // delegates a few printing related commands to this instance. |
28 class PrintViewManager : public NotificationObserver, | 28 class PrintViewManager : public NotificationObserver, |
29 public PrintedPagesSource, | 29 public PrintedPagesSource, |
30 public TabContentsObserver { | 30 public TabContentsObserver { |
31 public: | 31 public: |
32 explicit PrintViewManager(TabContents* tab_contents); | 32 explicit PrintViewManager(TabContentsWrapper* tab); |
33 virtual ~PrintViewManager(); | 33 virtual ~PrintViewManager(); |
34 | 34 |
35 // Override the title for this PrintViewManager's PrintJobs using the title | 35 // Override the title for this PrintViewManager's PrintJobs using the title |
36 // in |tab_contents|. | 36 // in |tab_contents|. |
37 void OverrideTitle(TabContents* tab_contents); | 37 void OverrideTitle(TabContents* tab_contents); |
38 | 38 |
39 // Prints the current document immediately. Since the rendering is | 39 // Prints the current document immediately. Since the rendering is |
40 // asynchronous, the actual printing will not be completed on the return of | 40 // asynchronous, the actual printing will not be completed on the return of |
41 // this function. Returns false if printing is impossible at the moment. | 41 // this function. Returns false if printing is impossible at the moment. |
42 bool PrintNow(); | 42 bool PrintNow(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 // while the blocking inner message loop is running. This is useful in cases | 112 // while the blocking inner message loop is running. This is useful in cases |
113 // where the RenderView is about to be destroyed while a printing job isn't | 113 // where the RenderView is about to be destroyed while a printing job isn't |
114 // finished. | 114 // finished. |
115 bool RunInnerMessageLoop(); | 115 bool RunInnerMessageLoop(); |
116 | 116 |
117 // In the case of Scripted Printing, where the renderer is controlling the | 117 // In the case of Scripted Printing, where the renderer is controlling the |
118 // control flow, print_job_ is initialized whenever possible. No-op is | 118 // control flow, print_job_ is initialized whenever possible. No-op is |
119 // print_job_ is initialized. | 119 // print_job_ is initialized. |
120 bool OpportunisticallyCreatePrintJob(int cookie); | 120 bool OpportunisticallyCreatePrintJob(int cookie); |
121 | 121 |
| 122 // TabContentsWrapper we're associated with. |
| 123 TabContentsWrapper* tab_; |
| 124 |
122 NotificationRegistrar registrar_; | 125 NotificationRegistrar registrar_; |
123 | 126 |
124 // Manages the low-level talk to the printer. | 127 // Manages the low-level talk to the printer. |
125 scoped_refptr<PrintJob> print_job_; | 128 scoped_refptr<PrintJob> print_job_; |
126 | 129 |
127 // Number of pages to print in the print job. | 130 // Number of pages to print in the print job. |
128 int number_pages_; | 131 int number_pages_; |
129 | 132 |
130 // Indication of success of the print job. | 133 // Indication of success of the print job. |
131 bool printing_succeeded_; | 134 bool printing_succeeded_; |
(...skipping 11 matching lines...) Expand all Loading... |
143 // Title override. | 146 // Title override. |
144 bool is_title_overridden_; | 147 bool is_title_overridden_; |
145 string16 overridden_title_; | 148 string16 overridden_title_; |
146 | 149 |
147 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); | 150 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); |
148 }; | 151 }; |
149 | 152 |
150 } // namespace printing | 153 } // namespace printing |
151 | 154 |
152 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 155 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
OLD | NEW |