print_dialog_linux_interface.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2012 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 PRINTING_PRINT_DIALOG_LINUX_INTERFACE_H_
  5. #define PRINTING_PRINT_DIALOG_LINUX_INTERFACE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "printing/printing_context_linux.h"
  9. #include "ui/gfx/native_widget_types.h"
  10. namespace printing {
  11. class MetafilePlayer;
  12. class PrintSettings;
  13. // An interface for Linux printing dialogs. Classes that live outside of
  14. // printing/ can implement this interface and get threading requirements
  15. // correct without exposing those requirements to printing/.
  16. class PrintDialogLinuxInterface {
  17. public:
  18. // Tell the dialog to use the default print setting.
  19. virtual void UseDefaultSettings() = 0;
  20. // Updates the dialog to use `settings`. Only used when printing without the
  21. // system print dialog. E.g. for Print Preview.
  22. virtual void UpdateSettings(std::unique_ptr<PrintSettings> settings) = 0;
  23. // Shows the dialog and handles the response with `callback`. Only used when
  24. // printing with the native print dialog.
  25. virtual void ShowDialog(
  26. gfx::NativeView parent_view,
  27. bool has_selection,
  28. PrintingContextLinux::PrintSettingsCallback callback) = 0;
  29. // Prints the document named `document_name` contained in `metafile`.
  30. // Called from the print worker thread. Once called, the
  31. // PrintDialogLinuxInterface instance should not be reused.
  32. virtual void PrintDocument(const MetafilePlayer& metafile,
  33. const std::u16string& document_name) = 0;
  34. // Releases the caller's ownership of the PrintDialogLinuxInterface. When
  35. // called, the caller must not access the PrintDialogLinuxInterface
  36. // afterwards, and vice versa.
  37. virtual void ReleaseDialog() = 0;
  38. protected:
  39. virtual ~PrintDialogLinuxInterface() = default;
  40. };
  41. } // namespace printing
  42. #endif // PRINTING_PRINT_DIALOG_LINUX_INTERFACE_H_