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_
|
|
|
|
|
|
|
|
#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"
|
|
|
|
|
2015-03-24 16:40:08 +01:00
|
|
|
struct PrintHostMsg_DidPreviewDocument_Params;
|
|
|
|
struct PrintHostMsg_RequestPrintPreview_Params;
|
|
|
|
|
2013-10-23 21:30:47 +02:00
|
|
|
namespace content {
|
|
|
|
class RenderProcessHost;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace printing {
|
|
|
|
|
|
|
|
// Manages the print commands for a WebContents.
|
|
|
|
class PrintViewManager : public PrintViewManagerBase,
|
|
|
|
public content::WebContentsUserData<PrintViewManager> {
|
|
|
|
public:
|
2014-11-12 20:25:15 +01:00
|
|
|
~PrintViewManager() override;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
#if defined(ENABLE_BASIC_PRINTING)
|
2013-10-23 21:30:47 +02:00
|
|
|
// Same as PrintNow(), but for the case where a user prints with the system
|
|
|
|
// dialog from print preview.
|
|
|
|
bool PrintForSystemDialogNow();
|
2014-11-12 20:25:15 +01:00
|
|
|
#endif // ENABLE_BASIC_PRINTING
|
2013-10-23 21:30:47 +02:00
|
|
|
|
|
|
|
// content::WebContentsObserver implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
|
|
|
// content::WebContentsObserver implementation.
|
2015-03-24 16:40:08 +01:00
|
|
|
// Cancels the print job.
|
|
|
|
void NavigationStopped() override;
|
2013-10-23 21:30:47 +02:00
|
|
|
// Terminates or cancels the print job if one was pending.
|
2014-11-12 20:25:15 +01:00
|
|
|
void RenderProcessGone(base::TerminationStatus status) 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.
|
|
|
|
void PrintToPDF(const base::FilePath& path,
|
|
|
|
const CefPdfPrintSettings& settings,
|
|
|
|
const PdfPrintCallback& callback);
|
|
|
|
|
2013-10-23 21:30:47 +02:00
|
|
|
private:
|
|
|
|
explicit PrintViewManager(content::WebContents* web_contents);
|
|
|
|
friend class content::WebContentsUserData<PrintViewManager>;
|
|
|
|
|
|
|
|
// IPC Message handlers.
|
|
|
|
void OnDidShowPrintDialog();
|
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;
|
|
|
|
base::FilePath pdf_output_path_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<base::DictionaryValue> pdf_print_settings_;
|
2015-03-24 16:40:08 +01:00
|
|
|
PdfPrintCallback pdf_print_callback_;
|
2013-10-23 21:30:47 +02:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace printing
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
|