[M120 Migration][VD] Remove accessing oom_score_adj in zygote process
[platform/framework/web/chromium-efl.git] / printing / printing_context_android.h
1 // Copyright 2013 The Chromium Authors
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
8 #include <string>
9
10 #include "base/android/scoped_java_ref.h"
11 #include "base/file_descriptor_posix.h"
12 #include "printing/mojom/print.mojom.h"
13 #include "printing/printing_context.h"
14
15 namespace ui {
16 class WindowAndroid;
17 }
18
19 namespace printing {
20
21 // Android subclass of PrintingContext. This class communicates with the
22 // Java side through JNI.
23 class COMPONENT_EXPORT(PRINTING) PrintingContextAndroid
24     : public PrintingContext {
25  public:
26   explicit PrintingContextAndroid(Delegate* delegate);
27   PrintingContextAndroid(const PrintingContextAndroid&) = delete;
28   PrintingContextAndroid& operator=(const PrintingContextAndroid&) = delete;
29   ~PrintingContextAndroid() override;
30
31   // Called when the page is successfully written to a PDF using the file
32   // descriptor specified, or when the printing operation failed. On success,
33   // the PDF has `page_count` pages. Non-positive `page_count` indicates
34   // failure.
35   static void PdfWritingDone(int page_count);
36
37   static void SetPendingPrint(
38       ui::WindowAndroid* window,
39       const base::android::ScopedJavaLocalRef<jobject>& printable,
40       int render_process_id,
41       int render_frame_id);
42
43   // Called from Java, when printing settings from the user are ready or the
44   // printing operation is canceled.
45   void AskUserForSettingsReply(JNIEnv* env,
46                                const base::android::JavaParamRef<jobject>& obj,
47                                jboolean success);
48
49   // Called from Java, when a printing process initiated by a script finishes.
50   void ShowSystemDialogDone(JNIEnv* env,
51                             const base::android::JavaParamRef<jobject>& obj);
52
53   // PrintingContext implementation.
54   void AskUserForSettings(int max_pages,
55                           bool has_selection,
56                           bool is_scripted,
57                           PrintSettingsCallback callback) override;
58   mojom::ResultCode UseDefaultSettings() override;
59   gfx::Size GetPdfPaperSizeDeviceUnits() override;
60   mojom::ResultCode UpdatePrinterSettings(
61       const PrinterSettings& printer_settings) override;
62   mojom::ResultCode NewDocument(const std::u16string& document_name) override;
63   mojom::ResultCode PrintDocument(const MetafilePlayer& metafile,
64                                   const PrintSettings& settings,
65                                   uint32_t num_pages) override;
66   mojom::ResultCode DocumentDone() override;
67   void Cancel() override;
68   void ReleaseContext() override;
69   printing::NativeDrawingContext context() const override;
70
71  private:
72   bool is_file_descriptor_valid() const { return fd_ > base::kInvalidFd; }
73
74   base::android::ScopedJavaGlobalRef<jobject> j_printing_context_;
75
76   // The callback from AskUserForSettings to be called when the settings are
77   // ready on the Java side
78   PrintSettingsCallback callback_;
79
80   int fd_ = base::kInvalidFd;
81 };
82
83 }  // namespace printing
84
85 #endif  // PRINTING_PRINTING_CONTEXT_ANDROID_H_