preview_mode_client.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // Copyright (c) 2011 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 PDF_PREVIEW_MODE_CLIENT_H_
  5. #define PDF_PREVIEW_MODE_CLIENT_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. #include "base/callback_forward.h"
  10. #include "base/memory/raw_ptr.h"
  11. #include "pdf/pdf_engine.h"
  12. namespace chrome_pdf {
  13. // The interface that's provided to the print preview rendering engine.
  14. class PreviewModeClient : public PDFEngine::Client {
  15. public:
  16. class Client {
  17. public:
  18. virtual void PreviewDocumentLoadFailed() = 0;
  19. virtual void PreviewDocumentLoadComplete() = 0;
  20. };
  21. explicit PreviewModeClient(Client* client);
  22. ~PreviewModeClient() override;
  23. // PDFEngine::Client implementation.
  24. void ProposeDocumentLayout(const DocumentLayout& layout) override;
  25. void Invalidate(const gfx::Rect& rect) override;
  26. void DidScroll(const gfx::Vector2d& offset) override;
  27. void ScrollToX(int x_in_screen_coords) override;
  28. void ScrollToY(int y_in_screen_coords) override;
  29. void ScrollBy(const gfx::Vector2d& scroll_delta) override;
  30. void ScrollToPage(int page) override;
  31. void NavigateTo(const std::string& url,
  32. WindowOpenDisposition disposition) override;
  33. void UpdateCursor(ui::mojom::CursorType cursor_type) override;
  34. void UpdateTickMarks(const std::vector<gfx::Rect>& tickmarks) override;
  35. void NotifyNumberOfFindResultsChanged(int total, bool final_result) override;
  36. void NotifySelectedFindResultChanged(int current_find_index,
  37. bool final_result) override;
  38. void GetDocumentPassword(
  39. base::OnceCallback<void(const std::string&)> callback) override;
  40. void Alert(const std::string& message) override;
  41. bool Confirm(const std::string& message) override;
  42. std::string Prompt(const std::string& question,
  43. const std::string& default_answer) override;
  44. std::string GetURL() override;
  45. void Email(const std::string& to,
  46. const std::string& cc,
  47. const std::string& bcc,
  48. const std::string& subject,
  49. const std::string& body) override;
  50. void Print() override;
  51. void SubmitForm(const std::string& url,
  52. const void* data,
  53. int length) override;
  54. std::unique_ptr<UrlLoader> CreateUrlLoader() override;
  55. std::vector<SearchStringResult> SearchString(const char16_t* string,
  56. const char16_t* term,
  57. bool case_sensitive) override;
  58. void DocumentLoadComplete() override;
  59. void DocumentLoadFailed() override;
  60. void DocumentHasUnsupportedFeature(const std::string& feature) override;
  61. void FormFieldFocusChange(PDFEngine::FocusFieldType type) override;
  62. bool IsPrintPreview() const override;
  63. SkColor GetBackgroundColor() const override;
  64. void SetSelectedText(const std::string& selected_text) override;
  65. void SetLinkUnderCursor(const std::string& link_under_cursor) override;
  66. bool IsValidLink(const std::string& url) override;
  67. private:
  68. const raw_ptr<Client> client_;
  69. };
  70. } // namespace chrome_pdf
  71. #endif // PDF_PREVIEW_MODE_CLIENT_H_