OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/threading/non_thread_safe.h" | 9 #include "base/threading/non_thread_safe.h" |
10 #include "content/public/browser/web_contents_observer.h" | 10 #include "content/public/browser/web_contents_observer.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 public base::NonThreadSafe { | 40 public base::NonThreadSafe { |
41 public: | 41 public: |
42 // Creates a PrintManager for the provided webcontents. If the printmanager | 42 // Creates a PrintManager for the provided webcontents. If the printmanager |
43 // already exists, it is destroyed and a new one is created. | 43 // already exists, it is destroyed and a new one is created. |
44 static PrintManager* CreateForWebContents( | 44 static PrintManager* CreateForWebContents( |
45 content::WebContents* contents, | 45 content::WebContents* contents, |
46 printing::PrintSettings* settings, | 46 printing::PrintSettings* settings, |
47 int fd, | 47 int fd, |
48 PrintManagerDelegate* delegate); | 48 PrintManagerDelegate* delegate); |
49 | 49 |
50 virtual ~PrintManager(); | 50 ~PrintManager() override; |
51 | 51 |
52 // Prints the current document immediately. Since the rendering is | 52 // Prints the current document immediately. Since the rendering is |
53 // asynchronous, the actual printing will not be completed on the return of | 53 // asynchronous, the actual printing will not be completed on the return of |
54 // this function. Returns false if printing is impossible at the moment. | 54 // this function. Returns false if printing is impossible at the moment. |
55 // | 55 // |
56 // Note for webview: Returns false immediately if this print manager is | 56 // Note for webview: Returns false immediately if this print manager is |
57 // already busy printing. | 57 // already busy printing. |
58 bool PrintNow(); | 58 bool PrintNow(); |
59 | 59 |
60 void OnAllocateTempFileForPrinting(base::FileDescriptor* temp_file_fd, | 60 void OnAllocateTempFileForPrinting(base::FileDescriptor* temp_file_fd, |
61 int* sequence_number); | 61 int* sequence_number); |
62 void OnTempFileForPrintingWritten(int sequence_number); | 62 void OnTempFileForPrintingWritten(int sequence_number); |
63 private: | 63 private: |
64 // To send receive messages to a RenderView we take the WebContents instance, | 64 // To send receive messages to a RenderView we take the WebContents instance, |
65 // as it internally handles RenderViewHost instances changing underneath us. | 65 // as it internally handles RenderViewHost instances changing underneath us. |
66 PrintManager(content::WebContents* contents, | 66 PrintManager(content::WebContents* contents, |
67 printing::PrintSettings* settings, | 67 printing::PrintSettings* settings, |
68 int fd, | 68 int fd, |
69 PrintManagerDelegate* delegate); | 69 PrintManagerDelegate* delegate); |
70 friend class content::WebContentsUserData<PrintManager>; | 70 friend class content::WebContentsUserData<PrintManager>; |
71 | 71 |
72 virtual bool OnMessageReceived(const IPC::Message& message) override; | 72 bool OnMessageReceived(const IPC::Message& message) override; |
73 void OnDidGetPrintedPagesCount(int cookie, int number_pages); | 73 void OnDidGetPrintedPagesCount(int cookie, int number_pages); |
74 void OnDidGetDocumentCookie(int cookie); | 74 void OnDidGetDocumentCookie(int cookie); |
75 void OnPrintingFailed(int cookie); | 75 void OnPrintingFailed(int cookie); |
76 void OnGetDefaultPrintSettingsReply(IPC::Message* reply_msg); | 76 void OnGetDefaultPrintSettingsReply(IPC::Message* reply_msg); |
77 void OnGetDefaultPrintSettings(IPC::Message* reply_msg); | 77 void OnGetDefaultPrintSettings(IPC::Message* reply_msg); |
78 | 78 |
79 // Print Settings. | 79 // Print Settings. |
80 printing::PrintSettings* settings_; | 80 printing::PrintSettings* settings_; |
81 | 81 |
82 // File descriptor to export to. | 82 // File descriptor to export to. |
83 int fd_; | 83 int fd_; |
84 // Print manager delegate | 84 // Print manager delegate |
85 PrintManagerDelegate* delegate_; | 85 PrintManagerDelegate* delegate_; |
86 // Number of pages to print in the print job. | 86 // Number of pages to print in the print job. |
87 int number_pages_; | 87 int number_pages_; |
88 // The document cookie of the current PrinterQuery. | 88 // The document cookie of the current PrinterQuery. |
89 int cookie_; | 89 int cookie_; |
90 // Whether a print task is pending. | 90 // Whether a print task is pending. |
91 int printing_; | 91 int printing_; |
92 | 92 |
93 DISALLOW_COPY_AND_ASSIGN(PrintManager); | 93 DISALLOW_COPY_AND_ASSIGN(PrintManager); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace android_webview | 96 } // namespace android_webview |
97 | 97 |
98 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ | 98 #endif // ANDROID_WEBVIEW_BROWSER_RENDER_HOST_PRINT_MANAGER_H_ |
OLD | NEW |