aw_pdf_exporter.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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.
  4. #ifndef ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_
  5. #define ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_
  6. #include "base/android/jni_weak_ref.h"
  7. #include "base/android/scoped_java_ref.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "printing/page_range.h"
  10. namespace content {
  11. class WebContents;
  12. }
  13. namespace printing {
  14. class PrintSettings;
  15. }
  16. namespace android_webview {
  17. class AwPdfExporter {
  18. public:
  19. AwPdfExporter(JNIEnv* env,
  20. const base::android::JavaRef<jobject>& obj,
  21. content::WebContents* web_contents);
  22. AwPdfExporter(const AwPdfExporter&) = delete;
  23. AwPdfExporter& operator=(const AwPdfExporter&) = delete;
  24. ~AwPdfExporter();
  25. void ExportToPdf(JNIEnv* env,
  26. const base::android::JavaParamRef<jobject>& obj,
  27. int fd,
  28. const base::android::JavaParamRef<jintArray>& pages,
  29. const base::android::JavaParamRef<jobject>& cancel_signal);
  30. private:
  31. std::unique_ptr<printing::PrintSettings> CreatePdfSettings(
  32. JNIEnv* env,
  33. const base::android::JavaRef<jobject>& obj,
  34. const printing::PageRanges& page_ranges);
  35. void DidExportPdf(int page_count);
  36. JavaObjectWeakGlobalRef java_ref_;
  37. raw_ptr<content::WebContents> web_contents_;
  38. };
  39. } // namespace android_webview
  40. #endif // ANDROID_WEBVIEW_BROWSER_AW_PDF_EXPORTER_H_