1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PDF_PREVIEW_MODE_CLIENT_H_
6 #define PDF_PREVIEW_MODE_CLIENT_H_
13 #include "base/callback_forward.h"
14 #include "base/memory/raw_ptr.h"
15 #include "pdf/pdf_engine.h"
17 namespace chrome_pdf {
19 // The interface that's provided to the print preview rendering engine.
20 class PreviewModeClient : public PDFEngine::Client {
24 virtual void PreviewDocumentLoadFailed() = 0;
25 virtual void PreviewDocumentLoadComplete() = 0;
28 explicit PreviewModeClient(Client* client);
29 ~PreviewModeClient() override;
31 // PDFEngine::Client implementation.
32 void ProposeDocumentLayout(const DocumentLayout& layout) override;
33 void Invalidate(const gfx::Rect& rect) override;
34 void DidScroll(const gfx::Vector2d& offset) override;
35 void ScrollToX(int x_in_screen_coords) override;
36 void ScrollToY(int y_in_screen_coords) override;
37 void ScrollBy(const gfx::Vector2d& scroll_delta) override;
38 void ScrollToPage(int page) override;
39 void NavigateTo(const std::string& url,
40 WindowOpenDisposition disposition) override;
41 void UpdateCursor(ui::mojom::CursorType cursor_type) override;
42 void UpdateTickMarks(const std::vector<gfx::Rect>& tickmarks) override;
43 void NotifyNumberOfFindResultsChanged(int total, bool final_result) override;
44 void NotifySelectedFindResultChanged(int current_find_index,
45 bool final_result) override;
46 void GetDocumentPassword(
47 base::OnceCallback<void(const std::string&)> callback) override;
48 void Alert(const std::string& message) override;
49 bool Confirm(const std::string& message) override;
50 std::string Prompt(const std::string& question,
51 const std::string& default_answer) override;
52 std::string GetURL() override;
53 void Email(const std::string& to,
54 const std::string& cc,
55 const std::string& bcc,
56 const std::string& subject,
57 const std::string& body) override;
58 void Print() override;
59 void SubmitForm(const std::string& url,
62 std::unique_ptr<UrlLoader> CreateUrlLoader() override;
63 std::vector<SearchStringResult> SearchString(const char16_t* string,
65 bool case_sensitive) override;
66 void DocumentLoadComplete() override;
67 void DocumentLoadFailed() override;
68 void DocumentHasUnsupportedFeature(const std::string& feature) override;
69 void FormFieldFocusChange(PDFEngine::FocusFieldType type) override;
70 bool IsPrintPreview() const override;
71 SkColor GetBackgroundColor() const override;
72 void SetSelectedText(const std::string& selected_text) override;
73 void SetLinkUnderCursor(const std::string& link_under_cursor) override;
74 bool IsValidLink(const std::string& url) override;
77 const raw_ptr<Client> client_;
80 } // namespace chrome_pdf
82 #endif // PDF_PREVIEW_MODE_CLIENT_H_