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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Manages the print commands in relation to a TabContents. TabContents | 27 // Manages the print commands in relation to a TabContents. TabContents |
28 // delegates a few printing related commands to this instance. | 28 // delegates a few printing related commands to this instance. |
29 class PrintViewManager : public NotificationObserver, | 29 class PrintViewManager : public NotificationObserver, |
30 public PrintedPagesSource, | 30 public PrintedPagesSource, |
31 public TabContentsObserver { | 31 public TabContentsObserver { |
32 public: | 32 public: |
33 explicit PrintViewManager(TabContentsWrapper* tab); | 33 explicit PrintViewManager(TabContentsWrapper* tab); |
34 virtual ~PrintViewManager(); | 34 virtual ~PrintViewManager(); |
35 | 35 |
36 // Override the title for this PrintViewManager's PrintJobs using the title | |
37 // in |tab_contents|. | |
38 void OverrideTitle(TabContents* tab_contents); | |
39 | |
40 // Prints the current document immediately. Since the rendering is | 36 // Prints the current document immediately. Since the rendering is |
41 // asynchronous, the actual printing will not be completed on the return of | 37 // asynchronous, the actual printing will not be completed on the return of |
42 // this function. Returns false if printing is impossible at the moment. | 38 // this function. Returns false if printing is impossible at the moment. |
43 bool PrintNow(); | 39 bool PrintNow(); |
44 | 40 |
45 // Same as PrintNow(), but for the case where a user prints with the system | 41 // Same as PrintNow(), but for the case where a user prints with the system |
46 // dialog from print preview. | 42 // dialog from print preview. |
47 bool PrintForSystemDialogNow(); | 43 bool PrintForSystemDialogNow(); |
48 | 44 |
49 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to | 45 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to |
50 // show the native system dialog. This can happen from both initiator tab and | 46 // show the native system dialog. This can happen from both initiator tab and |
51 // preview tab. | 47 // preview tab. |
52 bool AdvancedPrintNow(); | 48 bool AdvancedPrintNow(); |
53 | 49 |
54 // Initiate print preview of the current document by first notifying the | 50 // Initiate print preview of the current document by first notifying the |
55 // renderer. Since this happens asynchronous, the print preview tab creation | 51 // renderer. Since this happens asynchronous, the print preview tab creation |
56 // will not be completed on the return of this function. Returns false if | 52 // will not be completed on the return of this function. Returns false if |
57 // print preview is impossible at the moment. | 53 // print preview is impossible at the moment. |
58 bool PrintPreviewNow(); | 54 bool PrintPreviewNow(); |
59 | 55 |
60 // Handles cancelled preview printing request. | 56 // Handles cancelled preview printing request. |
61 void PreviewPrintingRequestCancelled(); | 57 void PreviewPrintingRequestCancelled(); |
62 | 58 |
| 59 // Let the renderer know print preview has finished. |
| 60 void PrintPreviewDone(); |
| 61 |
63 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to | 62 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to |
64 // remove the current observer. |observer| may always be NULL, but |observer_| | 63 // remove the current observer. |observer| may always be NULL, but |observer_| |
65 // must be NULL if |observer| is non-NULL. | 64 // must be NULL if |observer| is non-NULL. |
66 void set_observer(PrintViewManagerObserver* observer); | 65 void set_observer(PrintViewManagerObserver* observer); |
67 | 66 |
68 // Reset |is_title_overridden_| to false. | |
69 void ResetTitleOverride(); | |
70 | |
71 // PrintedPagesSource implementation. | 67 // PrintedPagesSource implementation. |
72 virtual string16 RenderSourceName() OVERRIDE; | 68 virtual string16 RenderSourceName() OVERRIDE; |
73 | 69 |
74 // NotificationObserver implementation. | 70 // NotificationObserver implementation. |
75 virtual void Observe(int type, | 71 virtual void Observe(int type, |
76 const NotificationSource& source, | 72 const NotificationSource& source, |
77 const NotificationDetails& details) OVERRIDE; | 73 const NotificationDetails& details) OVERRIDE; |
78 | 74 |
79 // TabContentsObserver implementation. | 75 // TabContentsObserver implementation. |
80 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 76 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // Running an inner message loop inside RenderAllMissingPagesNow(). This means | 157 // Running an inner message loop inside RenderAllMissingPagesNow(). This means |
162 // we are _blocking_ until all the necessary pages have been rendered or the | 158 // we are _blocking_ until all the necessary pages have been rendered or the |
163 // print settings are being loaded. | 159 // print settings are being loaded. |
164 bool inside_inner_message_loop_; | 160 bool inside_inner_message_loop_; |
165 | 161 |
166 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 162 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
167 // Set to true when OnDidPrintPage() should be expecting the first page. | 163 // Set to true when OnDidPrintPage() should be expecting the first page. |
168 bool expecting_first_page_; | 164 bool expecting_first_page_; |
169 #endif | 165 #endif |
170 | 166 |
171 // Title override. | |
172 bool is_title_overridden_; | |
173 string16 overridden_title_; | |
174 | |
175 // Weak pointer to an observer that is notified when the print dialog is | 167 // Weak pointer to an observer that is notified when the print dialog is |
176 // shown. | 168 // shown. |
177 PrintViewManagerObserver* observer_; | 169 PrintViewManagerObserver* observer_; |
178 | 170 |
179 // The document cookie of the current PrinterQuery. | 171 // The document cookie of the current PrinterQuery. |
180 int cookie_; | 172 int cookie_; |
181 | 173 |
182 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); | 174 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); |
183 }; | 175 }; |
184 | 176 |
185 } // namespace printing | 177 } // namespace printing |
186 | 178 |
187 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 179 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
OLD | NEW |