print_view_manager_basic.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASIC_H_
  5. #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASIC_H_
  6. #include "chrome/browser/printing/print_view_manager_base.h"
  7. #include "content/public/browser/web_contents_user_data.h"
  8. #if defined(OS_ANDROID)
  9. #include "base/file_descriptor_posix.h"
  10. #endif
  11. namespace printing {
  12. // Manages the print commands for a WebContents - basic version.
  13. class PrintViewManagerBasic
  14. : public PrintViewManagerBase,
  15. public content::WebContentsUserData<PrintViewManagerBasic> {
  16. public:
  17. ~PrintViewManagerBasic() override;
  18. #if defined(OS_ANDROID)
  19. // Sets the file descriptor into which the PDF will be written.
  20. void set_file_descriptor(const base::FileDescriptor& file_descriptor) {
  21. file_descriptor_ = file_descriptor;
  22. }
  23. // Gets the file descriptor into which the PDF will be written.
  24. base::FileDescriptor file_descriptor() const { return file_descriptor_; }
  25. // content::WebContentsObserver implementation.
  26. // Terminates or cancels the print job if one was pending.
  27. virtual void RenderProcessGone(base::TerminationStatus status) override;
  28. // content::WebContentsObserver implementation.
  29. virtual bool OnMessageReceived(const IPC::Message& message) override;
  30. #endif
  31. private:
  32. explicit PrintViewManagerBasic(content::WebContents* web_contents);
  33. friend class content::WebContentsUserData<PrintViewManagerBasic>;
  34. #if defined(OS_ANDROID)
  35. virtual void OnPrintingFailed(int cookie) override;
  36. // The file descriptor into which the PDF of the page will be written.
  37. base::FileDescriptor file_descriptor_;
  38. #endif
  39. DISALLOW_COPY_AND_ASSIGN(PrintViewManagerBasic);
  40. };
  41. } // namespace printing
  42. #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_BASIC_H_