Roll src/third_party/WebKit f36d5e0:68b67cd (svn 193299:193303)
[chromium-blink-merge.git] / printing / printing_context_android.h
blob6962c099c783697fd1bd360bd3f808f467a0763f
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_
8 #include <jni.h>
10 #include <string>
12 #include "base/android/scoped_java_ref.h"
13 #include "printing/printing_context.h"
15 namespace printing {
17 // Android subclass of PrintingContext. This class communicates with the
18 // Java side through JNI.
19 class PRINTING_EXPORT PrintingContextAndroid : public PrintingContext {
20 public:
21 explicit PrintingContextAndroid(Delegate* delegate);
22 ~PrintingContextAndroid() override;
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 void AskUserForSettings(int max_pages,
37 bool has_selection,
38 bool is_scripted,
39 const PrintSettingsCallback& callback) override;
40 Result UseDefaultSettings() override;
41 gfx::Size GetPdfPaperSizeDeviceUnits() override;
42 Result UpdatePrinterSettings(bool external_preview,
43 bool show_system_dialog) override;
44 Result InitWithSettings(const PrintSettings& settings) override;
45 Result NewDocument(const base::string16& document_name) override;
46 Result NewPage() override;
47 Result PageDone() override;
48 Result DocumentDone() override;
49 void Cancel() override;
50 void ReleaseContext() override;
51 gfx::NativeDrawingContext context() const override;
53 // Registers JNI bindings for RegisterContext.
54 static bool RegisterPrintingContext(JNIEnv* env);
56 private:
57 base::android::ScopedJavaGlobalRef<jobject> j_printing_context_;
59 // The callback from AskUserForSettings to be called when the settings are
60 // ready on the Java side
61 PrintSettingsCallback callback_;
63 DISALLOW_COPY_AND_ASSIGN(PrintingContextAndroid);
66 } // namespace printing
68 #endif // PRINTING_PRINTING_CONTEXT_ANDROID_H_