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 #include "pdf/preview_mode_client.h"
13 #include "base/functional/callback.h"
14 #include "base/notreached.h"
15 #include "base/time/time.h"
16 #include "pdf/document_layout.h"
17 #include "pdf/loader/url_loader.h"
18 #include "third_party/skia/include/core/SkColor.h"
19 #include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
21 namespace chrome_pdf {
23 PreviewModeClient::PreviewModeClient(Client* client) : client_(client) {}
25 PreviewModeClient::~PreviewModeClient() = default;
27 void PreviewModeClient::ProposeDocumentLayout(const DocumentLayout& layout) {
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.
32 void PreviewModeClient::Invalidate(const gfx::Rect& rect) {
36 void PreviewModeClient::DidScroll(const gfx::Vector2d& point) {
40 void PreviewModeClient::ScrollToX(int x_in_screen_coords) {
44 void PreviewModeClient::ScrollToY(int y_in_screen_coords) {
48 void PreviewModeClient::ScrollBy(const gfx::Vector2d& scroll_delta) {
52 void PreviewModeClient::ScrollToPage(int page) {
56 void PreviewModeClient::NavigateTo(const std::string& url,
57 WindowOpenDisposition disposition) {
61 void PreviewModeClient::UpdateCursor(ui::mojom::CursorType cursor_type) {
65 void PreviewModeClient::UpdateTickMarks(
66 const std::vector<gfx::Rect>& tickmarks) {
70 void PreviewModeClient::NotifyNumberOfFindResultsChanged(int total,
75 void PreviewModeClient::NotifySelectedFindResultChanged(int current_find_index,
80 void PreviewModeClient::GetDocumentPassword(
81 base::OnceCallback<void(const std::string&)> callback) {
82 std::move(callback).Run("");
85 void PreviewModeClient::Alert(const std::string& message) {
89 bool PreviewModeClient::Confirm(const std::string& message) {
94 std::string PreviewModeClient::Prompt(const std::string& question,
95 const std::string& default_answer) {
100 std::string PreviewModeClient::GetURL() {
102 return std::string();
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) {
113 void PreviewModeClient::Print() {
117 void PreviewModeClient::SubmitForm(const std::string& url,
123 std::unique_ptr<UrlLoader> PreviewModeClient::CreateUrlLoader() {
128 std::vector<PDFEngine::Client::SearchStringResult>
129 PreviewModeClient::SearchString(const char16_t* string,
130 const char16_t* term,
131 bool case_sensitive) {
133 return std::vector<SearchStringResult>();
136 void PreviewModeClient::DocumentLoadComplete() {
137 client_->PreviewDocumentLoadComplete();
140 void PreviewModeClient::DocumentLoadFailed() {
141 client_->PreviewDocumentLoadFailed();
144 void PreviewModeClient::DocumentHasUnsupportedFeature(
145 const std::string& feature) {
149 void PreviewModeClient::FormFieldFocusChange(PDFEngine::FocusFieldType type) {
153 bool PreviewModeClient::IsPrintPreview() const {
157 SkColor PreviewModeClient::GetBackgroundColor() const {
159 return SK_ColorTRANSPARENT;
162 void PreviewModeClient::SetSelectedText(const std::string& selected_text) {
166 void PreviewModeClient::SetLinkUnderCursor(
167 const std::string& link_under_cursor) {
171 bool PreviewModeClient::IsValidLink(const std::string& url) {
176 } // namespace chrome_pdf