1 // 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.
5 #ifndef PRINTING_PRINTING_CONTEXT_ANDROID_H_
6 #define PRINTING_PRINTING_CONTEXT_ANDROID_H_
12 #include "base/android/scoped_java_ref.h"
13 #include "printing/printing_context.h"
17 // Android subclass of PrintingContext. This class communicates with the
18 // Java side through JNI.
19 class PRINTING_EXPORT PrintingContextAndroid
: public PrintingContext
{
21 explicit PrintingContextAndroid(Delegate
* delegate
);
22 virtual ~PrintingContextAndroid();
24 // Called when the page is successfully written to a PDF using the file
25 // descriptor specified, or when the printing operation failed.
26 static void PdfWritingDone(int fd
, bool success
);
28 // Called from Java, when printing settings from the user are ready or the
29 // printing operation is canceled.
30 void AskUserForSettingsReply(JNIEnv
* env
, jobject obj
, jboolean success
);
32 // Called from Java, when a printing process initiated by a script finishes.
33 void ShowSystemDialogDone(JNIEnv
* env
, jobject obj
);
35 // PrintingContext implementation.
36 virtual void AskUserForSettings(
40 const PrintSettingsCallback
& callback
) override
;
41 virtual Result
UseDefaultSettings() override
;
42 virtual gfx::Size
GetPdfPaperSizeDeviceUnits() override
;
43 virtual Result
UpdatePrinterSettings(bool external_preview
,
44 bool show_system_dialog
) override
;
45 virtual Result
InitWithSettings(const PrintSettings
& settings
) override
;
46 virtual Result
NewDocument(const base::string16
& document_name
) override
;
47 virtual Result
NewPage() override
;
48 virtual Result
PageDone() override
;
49 virtual Result
DocumentDone() override
;
50 virtual void Cancel() override
;
51 virtual void ReleaseContext() override
;
52 virtual gfx::NativeDrawingContext
context() const override
;
54 // Registers JNI bindings for RegisterContext.
55 static bool RegisterPrintingContext(JNIEnv
* env
);
58 base::android::ScopedJavaGlobalRef
<jobject
> j_printing_context_
;
60 // The callback from AskUserForSettings to be called when the settings are
61 // ready on the Java side
62 PrintSettingsCallback callback_
;
64 DISALLOW_COPY_AND_ASSIGN(PrintingContextAndroid
);
67 } // namespace printing
69 #endif // PRINTING_PRINTING_CONTEXT_ANDROID_H_