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