[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 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 | |
| 5 | #ifndef PDF_PREVIEW_MODE_CLIENT_H_ |
| 6 | #define PDF_PREVIEW_MODE_CLIENT_H_ |
| 7 | |
avi | a7c09d5 | 2015-12-21 19:49:43 | [diff] [blame] | 8 | #include <stdint.h> |
| 9 | |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
K. Moon | 82fd9de | 2020-07-08 16:17:32 | [diff] [blame] | 13 | #include "base/callback_forward.h" |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 14 | #include "pdf/pdf_engine.h" |
| 15 | |
K. Moon | 30466c9 | 2020-07-21 21:46:03 | [diff] [blame] | 16 | namespace gfx { |
Ankit Kumar 🌪️ | b5b4be9 | 2020-08-29 07:49:27 | [diff] [blame] | 17 | class Rect; |
K. Moon | 30466c9 | 2020-07-21 21:46:03 | [diff] [blame] | 18 | class Vector2d; |
| 19 | } // namespace gfx |
| 20 | |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 21 | namespace chrome_pdf { |
| 22 | |
| 23 | // The interface that's provided to the print preview rendering engine. |
| 24 | class PreviewModeClient : public PDFEngine::Client { |
| 25 | public: |
| 26 | class Client { |
| 27 | public: |
| 28 | virtual void PreviewDocumentLoadFailed() = 0; |
| 29 | virtual void PreviewDocumentLoadComplete() = 0; |
| 30 | }; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 31 | |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 32 | explicit PreviewModeClient(Client* client); |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 33 | ~PreviewModeClient() override {} |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 34 | |
| 35 | // PDFEngine::Client implementation. |
K Moon | bf59df5 | 2019-09-27 00:32:58 | [diff] [blame] | 36 | void ProposeDocumentLayout(const DocumentLayout& layout) override; |
Ankit Kumar 🌪️ | 56d2751 | 2020-09-03 23:18:14 | [diff] [blame] | 37 | void Invalidate(const gfx::Rect& rect) override; |
K. Moon | 30466c9 | 2020-07-21 21:46:03 | [diff] [blame] | 38 | void DidScroll(const gfx::Vector2d& offset) override; |
Henrique Nakashima | 2ab2e4e9 | 2017-09-26 16:11:07 | [diff] [blame] | 39 | void ScrollToX(int x_in_screen_coords) override; |
| 40 | void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override; |
Ankit Kumar 🌪️ | 7f59e78 | 2020-08-18 22:31:29 | [diff] [blame] | 41 | void ScrollBy(const gfx::Vector2d& scroll_delta) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 42 | void ScrollToPage(int page) override; |
jaepark | 1b44ac41 | 2016-07-26 17:24:01 | [diff] [blame] | 43 | void NavigateTo(const std::string& url, |
| 44 | WindowOpenDisposition disposition) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 45 | void UpdateCursor(PP_CursorType_Dev cursor) override; |
Ankit Kumar 🌪️ | b5b4be9 | 2020-08-29 07:49:27 | [diff] [blame] | 46 | void UpdateTickMarks(const std::vector<gfx::Rect>& tickmarks) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 47 | void NotifyNumberOfFindResultsChanged(int total, bool final_result) override; |
| 48 | void NotifySelectedFindResultChanged(int current_find_index) override; |
| 49 | void GetDocumentPassword( |
K. Moon | 82fd9de | 2020-07-08 16:17:32 | [diff] [blame] | 50 | base::OnceCallback<void(const std::string&)> callback) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 51 | void Alert(const std::string& message) override; |
| 52 | bool Confirm(const std::string& message) override; |
| 53 | std::string Prompt(const std::string& question, |
| 54 | const std::string& default_answer) override; |
| 55 | std::string GetURL() override; |
| 56 | void Email(const std::string& to, |
| 57 | const std::string& cc, |
| 58 | const std::string& bcc, |
| 59 | const std::string& subject, |
| 60 | const std::string& body) override; |
| 61 | void Print() override; |
| 62 | void SubmitForm(const std::string& url, |
| 63 | const void* data, |
| 64 | int length) override; |
K. Moon | 071f48d | 2020-09-10 17:07:18 | [diff] [blame] | 65 | std::unique_ptr<UrlLoader> CreateUrlLoader() override; |
Lei Zhang | 49baa88 | 2017-10-20 23:31:41 | [diff] [blame] | 66 | std::vector<SearchStringResult> SearchString(const base::char16* string, |
| 67 | const base::char16* term, |
| 68 | bool case_sensitive) override; |
Henrique Nakashima | f14fd48 | 2017-10-16 18:29:01 | [diff] [blame] | 69 | void DocumentLoadComplete( |
Lei Zhang | aa417f0 | 2019-07-16 00:25:23 | [diff] [blame] | 70 | const PDFEngine::DocumentFeatures& document_features) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 71 | void DocumentLoadFailed() override; |
| 72 | pp::Instance* GetPluginInstance() override; |
| 73 | void DocumentHasUnsupportedFeature(const std::string& feature) override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 74 | void FormTextFieldFocusChange(bool in_focus) override; |
| 75 | bool IsPrintPreview() override; |
Virender Singh | 05d6d36 | 2020-02-06 21:39:51 | [diff] [blame] | 76 | float GetToolbarHeightInScreenCoords() override; |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 77 | uint32_t GetBackgroundColor() override; |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 78 | |
| 79 | private: |
thestig | 98638620 | 2015-12-29 22:38:15 | [diff] [blame] | 80 | Client* const client_; |
[email protected] | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace chrome_pdf |
| 84 | |
| 85 | #endif // PDF_PREVIEW_MODE_CLIENT_H_ |