2013-10-23 21:30:47 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|
|
|
|
|
2017-05-19 11:06:00 +02:00
|
|
|
#include "include/internal/cef_types_wrappers.h"
|
2013-10-23 21:30:47 +02:00
|
|
|
#include "libcef/browser/printing/print_view_manager_base.h"
|
2016-01-06 20:20:54 +01:00
|
|
|
|
|
|
|
#include "base/macros.h"
|
2013-10-23 21:30:47 +02:00
|
|
|
#include "content/public/browser/web_contents_user_data.h"
|
|
|
|
|
|
|
|
namespace content {
|
2016-11-23 21:54:29 +01:00
|
|
|
class RenderFrameHost;
|
2013-10-23 21:30:47 +02:00
|
|
|
class RenderProcessHost;
|
|
|
|
}
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
struct PrintHostMsg_DidPreviewDocument_Params;
|
|
|
|
struct PrintHostMsg_RequestPrintPreview_Params;
|
|
|
|
|
2013-10-23 21:30:47 +02:00
|
|
|
namespace printing {
|
|
|
|
|
|
|
|
// Manages the print commands for a WebContents.
|
2017-05-17 11:29:28 +02:00
|
|
|
class CefPrintViewManager
|
|
|
|
: public CefPrintViewManagerBase,
|
|
|
|
public content::WebContentsUserData<CefPrintViewManager> {
|
2013-10-23 21:30:47 +02:00
|
|
|
public:
|
2016-07-14 03:35:07 +02:00
|
|
|
~CefPrintViewManager() override;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
// Callback executed on PDF printing completion.
|
|
|
|
typedef base::Callback<void(bool /*ok*/)> PdfPrintCallback;
|
|
|
|
|
|
|
|
// Print the current document to a PDF file. Execute |callback| on completion.
|
2016-11-23 21:54:29 +01:00
|
|
|
bool PrintToPDF(content::RenderFrameHost* rfh,
|
|
|
|
const base::FilePath& path,
|
2015-03-24 16:40:08 +01:00
|
|
|
const CefPdfPrintSettings& settings,
|
|
|
|
const PdfPrintCallback& callback);
|
|
|
|
|
2016-11-23 21:54:29 +01:00
|
|
|
// content::WebContentsObserver implementation.
|
|
|
|
void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override;
|
|
|
|
void NavigationStopped() override;
|
|
|
|
void RenderProcessGone(base::TerminationStatus status) override;
|
|
|
|
bool OnMessageReceived(const IPC::Message& message,
|
|
|
|
content::RenderFrameHost* render_frame_host) override;
|
|
|
|
|
2013-10-23 21:30:47 +02:00
|
|
|
private:
|
2016-07-14 03:35:07 +02:00
|
|
|
explicit CefPrintViewManager(content::WebContents* web_contents);
|
|
|
|
friend class content::WebContentsUserData<CefPrintViewManager>;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
|
|
|
// IPC Message handlers.
|
2016-11-23 21:54:29 +01:00
|
|
|
void OnDidShowPrintDialog(content::RenderFrameHost* rfh);
|
2015-03-24 16:40:08 +01:00
|
|
|
void OnRequestPrintPreview(const PrintHostMsg_RequestPrintPreview_Params&);
|
|
|
|
void OnMetafileReadyForPrinting(
|
|
|
|
const PrintHostMsg_DidPreviewDocument_Params&);
|
|
|
|
|
|
|
|
void TerminatePdfPrintJob();
|
|
|
|
|
|
|
|
// Used for printing to PDF. Only accessed on the browser process UI thread.
|
|
|
|
int next_pdf_request_id_ = -1;
|
2016-11-23 21:54:29 +01:00
|
|
|
struct PdfPrintState;
|
|
|
|
std::unique_ptr<PdfPrintState> pdf_print_state_;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
2016-07-14 03:35:07 +02:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefPrintViewManager);
|
2013-10-23 21:30:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace printing
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|