aw_print_manager.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2015 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_PRINT_MANAGER_H_
  5. #define ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_
  6. #include <memory>
  7. #include "components/printing/browser/print_manager.h"
  8. #include "components/printing/common/print.mojom-forward.h"
  9. #include "content/public/browser/web_contents_user_data.h"
  10. #include "printing/print_settings.h"
  11. namespace android_webview {
  12. class AwPrintManager : public printing::PrintManager,
  13. public content::WebContentsUserData<AwPrintManager> {
  14. public:
  15. AwPrintManager(const AwPrintManager&) = delete;
  16. AwPrintManager& operator=(const AwPrintManager&) = delete;
  17. ~AwPrintManager() override;
  18. static void BindPrintManagerHost(
  19. mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost>
  20. receiver,
  21. content::RenderFrameHost* rfh);
  22. // printing::PrintManager:
  23. void PdfWritingDone(int page_count) override;
  24. bool PrintNow();
  25. // Updates the parameters for printing.
  26. void UpdateParam(std::unique_ptr<printing::PrintSettings> settings,
  27. int file_descriptor,
  28. PdfWritingDoneCallback callback);
  29. private:
  30. friend class content::WebContentsUserData<AwPrintManager>;
  31. explicit AwPrintManager(content::WebContents* contents);
  32. // mojom::PrintManagerHost:
  33. void DidPrintDocument(printing::mojom::DidPrintDocumentParamsPtr params,
  34. DidPrintDocumentCallback callback) override;
  35. void GetDefaultPrintSettings(
  36. GetDefaultPrintSettingsCallback callback) override;
  37. void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params,
  38. ScriptedPrintCallback callback) override;
  39. static void OnDidPrintDocumentWritingDone(
  40. const PdfWritingDoneCallback& callback,
  41. DidPrintDocumentCallback did_print_document_cb,
  42. uint32_t page_count);
  43. std::unique_ptr<printing::PrintSettings> settings_;
  44. // The file descriptor into which the PDF of the document will be written.
  45. int fd_ = -1;
  46. WEB_CONTENTS_USER_DATA_KEY_DECL();
  47. };
  48. } // namespace android_webview
  49. #endif // ANDROID_WEBVIEW_BROWSER_AW_PRINT_MANAGER_H_