[go: nahoru, domu]

blob: 78aa762309cb1e62622eb6383d2e7bd67770dd71 [file] [log] [blame]
avayvod@chromium.orgb25f0032013-08-19 22:26:251// Copyright 2013 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
5#ifndef PRINTING_PRINTING_CONTEXT_ANDROID_H_
6#define PRINTING_PRINTING_CONTEXT_ANDROID_H_
7
avayvod@chromium.orgb25f0032013-08-19 22:26:258#include <string>
9
10#include "base/android/scoped_java_ref.h"
avi126e93c2015-12-21 21:48:1611#include "base/macros.h"
avayvod@chromium.orgb25f0032013-08-19 22:26:2512#include "printing/printing_context.h"
13
14namespace printing {
15
dgn4c172eea2014-12-15 21:11:2316// Android subclass of PrintingContext. This class communicates with the
avayvod@chromium.orgb25f0032013-08-19 22:26:2517// Java side through JNI.
18class PRINTING_EXPORT PrintingContextAndroid : public PrintingContext {
19 public:
Vitaly Bukabd7c9812014-08-26 08:57:5420 explicit PrintingContextAndroid(Delegate* delegate);
dchengff7922e2015-02-06 03:37:1321 ~PrintingContextAndroid() override;
avayvod@chromium.orgb25f0032013-08-19 22:26:2522
23 // Called when the page is successfully written to a PDF using the file
Shimi Zhangb4149562017-06-30 02:41:2324 // descriptor specified, or when the printing operation failed. On success,
25 // the PDF written to |fd| has |page_count| pages. Non-positive |page_count|
26 // indicates failure.
27 static void PdfWritingDone(int fd, int page_count);
avayvod@chromium.orgb25f0032013-08-19 22:26:2528
29 // Called from Java, when printing settings from the user are ready or the
30 // printing operation is canceled.
torne6f3f0972015-11-25 18:04:3031 void AskUserForSettingsReply(JNIEnv* env,
32 const base::android::JavaParamRef<jobject>& obj,
33 jboolean success);
avayvod@chromium.orgb25f0032013-08-19 22:26:2534
dgn4c172eea2014-12-15 21:11:2335 // Called from Java, when a printing process initiated by a script finishes.
torne6f3f0972015-11-25 18:04:3036 void ShowSystemDialogDone(JNIEnv* env,
37 const base::android::JavaParamRef<jobject>& obj);
dgn4c172eea2014-12-15 21:11:2338
avayvod@chromium.orgb25f0032013-08-19 22:26:2539 // PrintingContext implementation.
dchengff7922e2015-02-06 03:37:1340 void AskUserForSettings(int max_pages,
41 bool has_selection,
42 bool is_scripted,
43 const PrintSettingsCallback& callback) override;
44 Result UseDefaultSettings() override;
45 gfx::Size GetPdfPaperSizeDeviceUnits() override;
46 Result UpdatePrinterSettings(bool external_preview,
vitalybuka95fa3c92015-05-05 03:03:3247 bool show_system_dialog,
48 int page_count) override;
dchengff7922e2015-02-06 03:37:1349 Result NewDocument(const base::string16& document_name) override;
50 Result NewPage() override;
51 Result PageDone() override;
52 Result DocumentDone() override;
53 void Cancel() override;
54 void ReleaseContext() override;
Nico Weber8e559562017-10-03 01:25:2655 printing::NativeDrawingContext context() const override;
avayvod@chromium.orgb25f0032013-08-19 22:26:2556
avayvod@chromium.orgb25f0032013-08-19 22:26:2557 private:
58 base::android::ScopedJavaGlobalRef<jobject> j_printing_context_;
59
60 // The callback from AskUserForSettings to be called when the settings are
61 // ready on the Java side
62 PrintSettingsCallback callback_;
63
64 DISALLOW_COPY_AND_ASSIGN(PrintingContextAndroid);
65};
66
67} // namespace printing
68
69#endif // PRINTING_PRINTING_CONTEXT_ANDROID_H_