timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 1 | // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
thestig | 7dd61e06 | 2016-11-08 23:53:50 | [diff] [blame] | 5 | #ifndef ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_ |
| 6 | #define ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_ |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 7 | |
avi | de7d5c2 | 2015-12-20 05:48:44 | [diff] [blame] | 8 | #include "base/macros.h" |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 9 | #include "components/printing/browser/print_manager.h" |
ctzsm | d20a4bb | 2017-03-24 21:52:18 | [diff] [blame] | 10 | #include "components/printing/common/print_messages.h" |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 11 | #include "content/public/browser/web_contents_user_data.h" |
| 12 | #include "printing/print_settings.h" |
| 13 | |
| 14 | namespace android_webview { |
| 15 | |
| 16 | class AwPrintManager : public printing::PrintManager, |
| 17 | public content::WebContentsUserData<AwPrintManager> { |
| 18 | public: |
thestig | 7dd61e06 | 2016-11-08 23:53:50 | [diff] [blame] | 19 | // Creates an AwPrintManager for the provided WebContents. If the |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 20 | // AwPrintManager already exists, it is destroyed and a new one is created. |
| 21 | static AwPrintManager* CreateForWebContents( |
| 22 | content::WebContents* contents, |
| 23 | const printing::PrintSettings& settings, |
| 24 | const base::FileDescriptor& file_descriptor, |
| 25 | const PdfWritingDoneCallback& callback); |
| 26 | |
| 27 | ~AwPrintManager() override; |
| 28 | |
| 29 | bool PrintNow(); |
| 30 | |
| 31 | private: |
| 32 | friend class content::WebContentsUserData<AwPrintManager>; |
thestig | 7dd61e06 | 2016-11-08 23:53:50 | [diff] [blame] | 33 | |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 34 | AwPrintManager(content::WebContents* contents, |
| 35 | const printing::PrintSettings& settings, |
| 36 | const base::FileDescriptor& file_descriptor, |
| 37 | const PdfWritingDoneCallback& callback); |
| 38 | |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 39 | // printing::PrintManager: |
| 40 | bool OnMessageReceived(const IPC::Message& message, |
| 41 | content::RenderFrameHost* render_frame_host) override; |
| 42 | |
| 43 | // IPC Handlers |
Lukasz Anforowicz | f4357ca | 2017-09-07 01:43:32 | [diff] [blame] | 44 | struct FrameDispatchHelper; |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 45 | void OnGetDefaultPrintSettings(content::RenderFrameHost* render_frame_host, |
| 46 | IPC::Message* reply_msg); |
ctzsm | d20a4bb | 2017-03-24 21:52:18 | [diff] [blame] | 47 | void OnScriptedPrint(content::RenderFrameHost* render_frame_host, |
| 48 | const PrintHostMsg_ScriptedPrint_Params& params, |
| 49 | IPC::Message* reply_msg); |
| 50 | |
timvolodine | 66cc354b | 2015-07-14 16:13:16 | [diff] [blame] | 51 | printing::PrintSettings settings_; |
| 52 | |
| 53 | DISALLOW_COPY_AND_ASSIGN(AwPrintManager); |
| 54 | }; |
| 55 | |
| 56 | } // namespace android_webview |
| 57 | |
thestig | 7dd61e06 | 2016-11-08 23:53:50 | [diff] [blame] | 58 | #endif // ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_ |