summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorMichael Bruning <michael.bruning@theqtcompany.com>2016-02-25 13:40:01 +0100
committerMichael BrĂ¼ning <michael.bruning@theqtcompany.com>2016-03-16 21:21:41 +0000
commitdf222f8ccb2151e519b92d3d2046ee74f221902e (patch)
treede0e9af4a11878399698e383f0162feee48d0aa6 /src/core/web_contents_adapter.cpp
parentec9a8753a7b17bbbf886c155ed884c581c547913 (diff)
Add callback to printing API
Also corrects and updates the printToPDF docs to reflect recent changes. Change-Id: Iffe276a1046d6d55923939f9d72b97cd533017ff Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index cfd970a20..71d2172fe 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -180,6 +180,13 @@ static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint6
adapterClient->didRunJavaScript(requestId, fromJSValue(result));
}
+static void callbackOnPrintingFinished(WebContentsAdapterClient *adapterClient, int requestId, const std::vector<char>& result)
+{
+ if (requestId) {
+ adapterClient->didPrintPage(requestId, QByteArray(result.data(), result.size()));
+ }
+}
+
static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
{
content::WebContents::CreateParams create_params(browserContext, NULL);
@@ -912,6 +919,18 @@ void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString
#endif // if defined(ENABLE_BASIC_PRINTING)
}
+quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayout)
+{
+#if defined(ENABLE_BASIC_PRINTING)
+ Q_D(WebContentsAdapter);
+ PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished, d->adapterClient, d->nextRequestId);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout, callback);
+ return d->nextRequestId++;
+#else
+ return 0;
+#endif // if defined(ENABLE_BASIC_PRINTING)
+}
+
QPointF WebContentsAdapter::lastScrollOffset() const
{
Q_D(const WebContentsAdapter);