blob: 12e4f19805a4c906dbe04a32b7a7789d8a7f04ae [file] [log] [blame]
timvolodine66cc354b2015-07-14 16:13:161// 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
thestig7dd61e062016-11-08 23:53:505#ifndef ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_
6#define ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_
timvolodine66cc354b2015-07-14 16:13:167
avide7d5c22015-12-20 05:48:448#include "base/macros.h"
timvolodine66cc354b2015-07-14 16:13:169#include "components/printing/browser/print_manager.h"
ctzsmd20a4bb2017-03-24 21:52:1810#include "components/printing/common/print_messages.h"
timvolodine66cc354b2015-07-14 16:13:1611#include "content/public/browser/web_contents_user_data.h"
12#include "printing/print_settings.h"
13
14namespace android_webview {
15
16class AwPrintManager : public printing::PrintManager,
17 public content::WebContentsUserData<AwPrintManager> {
18 public:
thestig7dd61e062016-11-08 23:53:5019 // Creates an AwPrintManager for the provided WebContents. If the
timvolodine66cc354b2015-07-14 16:13:1620 // 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>;
thestig7dd61e062016-11-08 23:53:5033
timvolodine66cc354b2015-07-14 16:13:1634 AwPrintManager(content::WebContents* contents,
35 const printing::PrintSettings& settings,
36 const base::FileDescriptor& file_descriptor,
37 const PdfWritingDoneCallback& callback);
38
thestigcb959ce2016-11-17 05:56:3239 // printing::PrintManager:
40 bool OnMessageReceived(const IPC::Message& message,
41 content::RenderFrameHost* render_frame_host) override;
42
43 // IPC Handlers
Lukasz Anforowiczf4357ca2017-09-07 01:43:3244 struct FrameDispatchHelper;
thestigcb959ce2016-11-17 05:56:3245 void OnGetDefaultPrintSettings(content::RenderFrameHost* render_frame_host,
46 IPC::Message* reply_msg);
ctzsmd20a4bb2017-03-24 21:52:1847 void OnScriptedPrint(content::RenderFrameHost* render_frame_host,
48 const PrintHostMsg_ScriptedPrint_Params& params,
49 IPC::Message* reply_msg);
50
timvolodine66cc354b2015-07-14 16:13:1651 printing::PrintSettings settings_;
52
53 DISALLOW_COPY_AND_ASSIGN(AwPrintManager);
54};
55
56} // namespace android_webview
57
thestig7dd61e062016-11-08 23:53:5058#endif // ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_