Avi Drissman | db497b3 | 2022-09-15 19:47:28 | [diff] [blame] | 1 | // Copyright 2011 The Chromium Authors |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "pdf/preview_mode_client.h" |
| 6 | |
avi | a7c09d5 | 2015-12-21 19:49:43 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
K. Moon | 071f48d | 2020-09-10 17:07:18 | [diff] [blame] | 9 | #include <memory> |
K. Moon | 82fd9de | 2020-07-08 16:17:32 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <utility> |
| 12 | |
Avi Drissman | 821ca309 | 2023-01-11 22:42:15 | [diff] [blame] | 13 | #include "base/functional/callback.h" |
Hans Wennborg | 5078d10 | 2020-04-29 18:26:46 | [diff] [blame] | 14 | #include "base/notreached.h" |
Hui Yingst | 86a6a36 | 2020-12-21 21:40:12 | [diff] [blame] | 15 | #include "base/time/time.h" |
K Moon | bf59df5 | 2019-09-27 00:32:58 | [diff] [blame] | 16 | #include "pdf/document_layout.h" |
K. Moon | efbad4c9 | 2022-06-16 20:34:48 | [diff] [blame] | 17 | #include "pdf/loader/url_loader.h" |
Hui Yingst | 2b4a554 | 2021-02-02 03:02:36 | [diff] [blame] | 18 | #include "third_party/skia/include/core/SkColor.h" |
Daniel Hosseinian | d333fe6c | 2021-03-25 01:54:49 | [diff] [blame] | 19 | #include "ui/base/cursor/mojom/cursor_type.mojom-shared.h" |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 20 | |
| 21 | namespace chrome_pdf { |
| 22 | |
thestig | 98913ba | 2017-04-21 19:03:25 | [diff] [blame] | 23 | PreviewModeClient::PreviewModeClient(Client* client) : client_(client) {} |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 24 | |
Lei Zhang | 67d503d | 2021-03-26 07:20:05 | [diff] [blame] | 25 | PreviewModeClient::~PreviewModeClient() = default; |
| 26 | |
K Moon | bf59df5 | 2019-09-27 00:32:58 | [diff] [blame] | 27 | void PreviewModeClient::ProposeDocumentLayout(const DocumentLayout& layout) { |
K Moon | aee0742 | 2019-10-02 21:19:15 | [diff] [blame] | 28 | // This will be invoked if the PreviewModeClient is used, which currently |
| 29 | // occurs if and only if loading a non-PDF document with more than 1 page. |
K Moon | bf59df5 | 2019-09-27 00:32:58 | [diff] [blame] | 30 | } |
| 31 | |
Ankit Kumar 🌪️ | 56d2751 | 2020-09-03 23:18:14 | [diff] [blame] | 32 | void PreviewModeClient::Invalidate(const gfx::Rect& rect) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 33 | NOTREACHED(); |
| 34 | } |
| 35 | |
K. Moon | 30466c9 | 2020-07-21 21:46:03 | [diff] [blame] | 36 | void PreviewModeClient::DidScroll(const gfx::Vector2d& point) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 37 | NOTREACHED(); |
| 38 | } |
| 39 | |
Henrique Nakashima | 2ab2e4e9 | 2017-09-26 16:11:07 | [diff] [blame] | 40 | void PreviewModeClient::ScrollToX(int x_in_screen_coords) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 41 | NOTREACHED(); |
| 42 | } |
| 43 | |
dpapad | 7463a45 | 2021-02-04 08:18:25 | [diff] [blame] | 44 | void PreviewModeClient::ScrollToY(int y_in_screen_coords) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 45 | NOTREACHED(); |
| 46 | } |
| 47 | |
Ankit Kumar 🌪️ | 7f59e78 | 2020-08-18 22:31:29 | [diff] [blame] | 48 | void PreviewModeClient::ScrollBy(const gfx::Vector2d& scroll_delta) { |
Henrique Nakashima | 585c7af0 | 2018-03-27 04:55:21 | [diff] [blame] | 49 | NOTREACHED(); |
| 50 | } |
| 51 | |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 52 | void PreviewModeClient::ScrollToPage(int page) { |
| 53 | NOTREACHED(); |
| 54 | } |
| 55 | |
| 56 | void PreviewModeClient::NavigateTo(const std::string& url, |
jaepark | 1b44ac41 | 2016-07-26 17:24:01 | [diff] [blame] | 57 | WindowOpenDisposition disposition) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 58 | NOTREACHED(); |
| 59 | } |
| 60 | |
Daniel Hosseinian | d333fe6c | 2021-03-25 01:54:49 | [diff] [blame] | 61 | void PreviewModeClient::UpdateCursor(ui::mojom::CursorType cursor_type) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 62 | NOTREACHED(); |
| 63 | } |
| 64 | |
| 65 | void PreviewModeClient::UpdateTickMarks( |
Ankit Kumar 🌪️ | b5b4be9 | 2020-08-29 07:49:27 | [diff] [blame] | 66 | const std::vector<gfx::Rect>& tickmarks) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 67 | NOTREACHED(); |
| 68 | } |
| 69 | |
| 70 | void PreviewModeClient::NotifyNumberOfFindResultsChanged(int total, |
| 71 | bool final_result) { |
| 72 | NOTREACHED(); |
| 73 | } |
| 74 | |
Lei Zhang | 733e70c3 | 2022-08-19 20:57:32 | [diff] [blame] | 75 | void PreviewModeClient::NotifySelectedFindResultChanged(int current_find_index, |
| 76 | bool final_result) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 77 | NOTREACHED(); |
| 78 | } |
| 79 | |
| 80 | void PreviewModeClient::GetDocumentPassword( |
K. Moon | 82fd9de | 2020-07-08 16:17:32 | [diff] [blame] | 81 | base::OnceCallback<void(const std::string&)> callback) { |
| 82 | std::move(callback).Run(""); |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void PreviewModeClient::Alert(const std::string& message) { |
| 86 | NOTREACHED(); |
| 87 | } |
| 88 | |
| 89 | bool PreviewModeClient::Confirm(const std::string& message) { |
| 90 | NOTREACHED(); |
| 91 | return false; |
| 92 | } |
| 93 | |
| 94 | std::string PreviewModeClient::Prompt(const std::string& question, |
| 95 | const std::string& default_answer) { |
| 96 | NOTREACHED(); |
| 97 | return std::string(); |
| 98 | } |
| 99 | |
| 100 | std::string PreviewModeClient::GetURL() { |
| 101 | NOTREACHED(); |
| 102 | return std::string(); |
| 103 | } |
| 104 | |
| 105 | void PreviewModeClient::Email(const std::string& to, |
| 106 | const std::string& cc, |
| 107 | const std::string& bcc, |
| 108 | const std::string& subject, |
| 109 | const std::string& body) { |
| 110 | NOTREACHED(); |
| 111 | } |
| 112 | |
| 113 | void PreviewModeClient::Print() { |
| 114 | NOTREACHED(); |
| 115 | } |
| 116 | |
| 117 | void PreviewModeClient::SubmitForm(const std::string& url, |
| 118 | const void* data, |
| 119 | int length) { |
| 120 | NOTREACHED(); |
| 121 | } |
| 122 | |
K. Moon | 071f48d | 2020-09-10 17:07:18 | [diff] [blame] | 123 | std::unique_ptr<UrlLoader> PreviewModeClient::CreateUrlLoader() { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 124 | NOTREACHED(); |
K. Moon | cbd6636d | 2020-08-29 11:21:18 | [diff] [blame] | 125 | return nullptr; |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 126 | } |
| 127 | |
Lei Zhang | 90784b92 | 2024-01-04 18:49:03 | [diff] [blame] | 128 | v8::Isolate* PreviewModeClient::GetIsolate() { |
| 129 | NOTREACHED_NORETURN(); |
| 130 | } |
| 131 | |
Lei Zhang | 49baa88 | 2017-10-20 23:31:41 | [diff] [blame] | 132 | std::vector<PDFEngine::Client::SearchStringResult> |
Jan Wilken Dörrie | a17b04b | 2021-03-09 20:51:01 | [diff] [blame] | 133 | PreviewModeClient::SearchString(const char16_t* string, |
| 134 | const char16_t* term, |
Lei Zhang | 49baa88 | 2017-10-20 23:31:41 | [diff] [blame] | 135 | bool case_sensitive) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 136 | NOTREACHED(); |
Lei Zhang | 49baa88 | 2017-10-20 23:31:41 | [diff] [blame] | 137 | return std::vector<SearchStringResult>(); |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 138 | } |
| 139 | |
Daniel Hosseinian | 571e1ea | 2021-02-05 02:30:10 | [diff] [blame] | 140 | void PreviewModeClient::DocumentLoadComplete() { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 141 | client_->PreviewDocumentLoadComplete(); |
| 142 | } |
| 143 | |
| 144 | void PreviewModeClient::DocumentLoadFailed() { |
| 145 | client_->PreviewDocumentLoadFailed(); |
| 146 | } |
| 147 | |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 148 | void PreviewModeClient::DocumentHasUnsupportedFeature( |
| 149 | const std::string& feature) { |
| 150 | NOTREACHED(); |
| 151 | } |
| 152 | |
Lei Zhang | f2f4bef | 2021-11-04 18:02:02 | [diff] [blame] | 153 | void PreviewModeClient::FormFieldFocusChange(PDFEngine::FocusFieldType type) { |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 154 | NOTREACHED(); |
| 155 | } |
| 156 | |
Daniel Hosseinian | e439754 | 2021-08-07 15:20:18 | [diff] [blame] | 157 | bool PreviewModeClient::IsPrintPreview() const { |
Ankit Kumar | 55015efd | 2020-05-22 08:09:10 | [diff] [blame] | 158 | return true; |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 159 | } |
| 160 | |
K. Moon | e22ef3c | 2022-05-23 20:33:52 | [diff] [blame] | 161 | SkColor PreviewModeClient::GetBackgroundColor() const { |
raymes | 8a9c0f3 | 2015-02-09 02:36:13 | [diff] [blame] | 162 | NOTREACHED(); |
Hui Yingst | 2b4a554 | 2021-02-02 03:02:36 | [diff] [blame] | 163 | return SK_ColorTRANSPARENT; |
raymes | 8a9c0f3 | 2015-02-09 02:36:13 | [diff] [blame] | 164 | } |
| 165 | |
Hui Yingst | 57d6cee | 2020-10-20 17:22:09 | [diff] [blame] | 166 | void PreviewModeClient::SetSelectedText(const std::string& selected_text) { |
| 167 | NOTREACHED(); |
| 168 | } |
| 169 | |
| 170 | void PreviewModeClient::SetLinkUnderCursor( |
| 171 | const std::string& link_under_cursor) { |
| 172 | NOTREACHED(); |
| 173 | } |
| 174 | |
Ankit Kumar 🌪️ | 02fcb69 | 2020-10-29 18:55:24 | [diff] [blame] | 175 | bool PreviewModeClient::IsValidLink(const std::string& url) { |
| 176 | NOTREACHED(); |
| 177 | return false; |
| 178 | } |
| 179 | |
jam@chromium.org | 1b1e9eff | 2014-05-20 01:56:40 | [diff] [blame] | 180 | } // namespace chrome_pdf |