Chromium Code Reviews| 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_document.h" | |
| 14 #include "printing/printed_pages_source.h" | 15 #include "printing/printed_pages_source.h" |
| 15 | 16 |
| 16 class TabContents; | 17 class TabContents; |
| 17 struct PrintHostMsg_DidPrintPage_Params; | 18 struct PrintHostMsg_DidPrintPage_Params; |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class RenderProcessHost; | 21 class RenderProcessHost; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace printing { | 24 namespace printing { |
| 24 | 25 |
| 25 class JobEventDetails; | 26 class JobEventDetails; |
| 26 class PrintJob; | 27 class PrintJob; |
| 27 class PrintJobWorkerOwner; | 28 class PrintJobWorkerOwner; |
| 28 class PrintViewManagerObserver; | 29 class PrintViewManagerObserver; |
| 29 | 30 |
| 30 // Manages the print commands in relation to a TabContents. | 31 // Manages the print commands in relation to a TabContents. |
| 31 // TabContents delegates a few printing related commands to this | 32 // TabContents delegates a few printing related commands to this |
| 32 // instance. | 33 // instance. |
| 33 class PrintViewManager : public content::NotificationObserver, | 34 class PrintViewManager : public content::NotificationObserver, |
| 34 public PrintedPagesSource, | 35 public PrintedPagesSource, |
| 35 public content::WebContentsObserver { | 36 public content::WebContentsObserver { |
| 36 public: | 37 public: |
| 38 class Delegate : public base::RefCountedThreadSafe<PrintJobWorkerOwner> { | |
|
MAD
2012/06/15 02:54:29
Oopss... I'll need to remove this...
MAD
2012/06/28 15:48:14
Done.
| |
| 39 | |
| 40 }; | |
| 37 explicit PrintViewManager(TabContents* tab); | 41 explicit PrintViewManager(TabContents* tab); |
| 38 virtual ~PrintViewManager(); | 42 virtual ~PrintViewManager(); |
| 39 | 43 |
| 40 // Prints the current document immediately. Since the rendering is | 44 // Prints the current document immediately. Since the rendering is |
| 41 // asynchronous, the actual printing will not be completed on the return of | 45 // asynchronous, the actual printing will not be completed on the return of |
| 42 // this function. Returns false if printing is impossible at the moment. | 46 // this function. Returns false if printing is impossible at the moment. |
| 43 bool PrintNow(); | 47 bool PrintNow(); |
| 44 | 48 |
| 45 // Same as PrintNow(), but for the case where a user prints with the system | 49 // Same as PrintNow(), but for the case where a user prints with the system |
| 46 // dialog from print preview. | 50 // dialog from print preview. |
| 47 bool PrintForSystemDialogNow(); | 51 bool PrintForSystemDialogNow(); |
| 48 | 52 |
| 49 // Same as PrintNow(), but for the case where a user press "ctrl+shift+p" to | 53 // 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 | 54 // show the native system dialog. This can happen from both initiator tab and |
| 51 // preview tab. | 55 // preview tab. |
| 52 bool AdvancedPrintNow(); | 56 bool AdvancedPrintNow(); |
| 53 | 57 |
| 58 // Same as PrintNow(), but for the case where we want to send the result to | |
| 59 // a Delegate. | |
| 60 bool PrintToDelegate(PrintedDocument::Delegate* printed_document_delegate); | |
| 61 | |
| 54 // Initiate print preview of the current document by first notifying the | 62 // Initiate print preview of the current document by first notifying the |
| 55 // renderer. Since this happens asynchronous, the print preview tab creation | 63 // renderer. Since this happens asynchronous, the print preview tab creation |
| 56 // will not be completed on the return of this function. Returns false if | 64 // will not be completed on the return of this function. Returns false if |
| 57 // print preview is impossible at the moment. | 65 // print preview is impossible at the moment. |
| 58 bool PrintPreviewNow(); | 66 bool PrintPreviewNow(); |
| 59 | 67 |
| 60 // Notify PrintViewManager that print preview is starting in the renderer for | 68 // Notify PrintViewManager that print preview is starting in the renderer for |
| 61 // a particular WebNode. | 69 // a particular WebNode. |
| 62 void PrintPreviewForWebNode(); | 70 void PrintPreviewForWebNode(); |
| 63 | 71 |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 | 191 |
| 184 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 192 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 185 // Set to true when OnDidPrintPage() should be expecting the first page. | 193 // Set to true when OnDidPrintPage() should be expecting the first page. |
| 186 bool expecting_first_page_; | 194 bool expecting_first_page_; |
| 187 #endif | 195 #endif |
| 188 | 196 |
| 189 // Weak pointer to an observer that is notified when the print dialog is | 197 // Weak pointer to an observer that is notified when the print dialog is |
| 190 // shown. | 198 // shown. |
| 191 PrintViewManagerObserver* observer_; | 199 PrintViewManagerObserver* observer_; |
| 192 | 200 |
| 201 // A potential delegate to be set on the printed document. | |
| 202 scoped_refptr<PrintedDocument::Delegate> printed_document_delegate_; | |
| 203 | |
| 193 // The document cookie of the current PrinterQuery. | 204 // The document cookie of the current PrinterQuery. |
| 194 int cookie_; | 205 int cookie_; |
| 195 | 206 |
| 196 // Current state of print preview for this view. | 207 // Current state of print preview for this view. |
| 197 PrintPreviewState print_preview_state_; | 208 PrintPreviewState print_preview_state_; |
| 198 | 209 |
| 199 // Keeps track of the pending callback during scripted print preview. | 210 // Keeps track of the pending callback during scripted print preview. |
| 200 content::RenderProcessHost* scripted_print_preview_rph_; | 211 content::RenderProcessHost* scripted_print_preview_rph_; |
| 201 | 212 |
| 202 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); | 213 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); |
| 203 }; | 214 }; |
| 204 | 215 |
| 205 } // namespace printing | 216 } // namespace printing |
| 206 | 217 |
| 207 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ | 218 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ |
| OLD | NEW |