RemotePrintJobParent.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef mozilla_layout_RemotePrintJobParent_h
  6. #define mozilla_layout_RemotePrintJobParent_h
  7. #include "mozilla/layout/PRemotePrintJobParent.h"
  8. #include "nsCOMArray.h"
  9. #include "nsCOMPtr.h"
  10. #include "mozilla/RefPtr.h"
  11. #include "mozilla/UniquePtr.h"
  12. #include "mozilla/layout/PrintTranslator.h"
  13. class nsDeviceContext;
  14. class nsIPrintSettings;
  15. class nsIWebProgressListener;
  16. namespace mozilla {
  17. namespace layout {
  18. class RemotePrintJobParent final : public PRemotePrintJobParent
  19. {
  20. public:
  21. explicit RemotePrintJobParent(nsIPrintSettings* aPrintSettings);
  22. void ActorDestroy(ActorDestroyReason aWhy) final;
  23. bool RecvInitializePrint(const nsString& aDocumentTitle,
  24. const nsString& aPrintToFile,
  25. const int32_t& aStartPage,
  26. const int32_t& aEndPage) final;
  27. bool RecvProcessPage(const nsCString& aPageFileName) final;
  28. bool RecvFinalizePrint() final;
  29. bool RecvAbortPrint(const nsresult& aRv) final;
  30. bool RecvStateChange(const long& aStateFlags,
  31. const nsresult& aStatus) final;
  32. bool RecvProgressChange(const long& aCurSelfProgress,
  33. const long& aMaxSelfProgress,
  34. const long& aCurTotalProgress,
  35. const long& aMaxTotalProgress) final;
  36. bool RecvStatusChange(const nsresult& aStatus) final;
  37. /**
  38. * Register a progress listener to receive print progress updates.
  39. *
  40. * @param aListener the progress listener to register. Must not be null.
  41. */
  42. void RegisterListener(nsIWebProgressListener* aListener);
  43. /**
  44. * @return the print settings for this remote print job.
  45. */
  46. already_AddRefed<nsIPrintSettings> GetPrintSettings();
  47. private:
  48. ~RemotePrintJobParent() final;
  49. nsresult InitializePrintDevice(const nsString& aDocumentTitle,
  50. const nsString& aPrintToFile,
  51. const int32_t& aStartPage,
  52. const int32_t& aEndPage);
  53. nsresult PrintPage(const nsCString& aPageFileName);
  54. nsCOMPtr<nsIPrintSettings> mPrintSettings;
  55. RefPtr<nsDeviceContext> mPrintDeviceContext;
  56. UniquePtr<PrintTranslator> mPrintTranslator;
  57. nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
  58. };
  59. } // namespace layout
  60. } // namespace mozilla
  61. #endif // mozilla_layout_RemotePrintJobParent_h