| // Copyright 2020 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef PDF_PDF_VIEW_WEB_PLUGIN_H_ |
| #define PDF_PDF_VIEW_WEB_PLUGIN_H_ |
| |
| #include "pdf/pdf_view_plugin_base.h" |
| #include "third_party/blink/public/web/web_plugin.h" |
| |
| namespace blink { |
| class WebPluginContainer; |
| struct WebPluginParams; |
| } // namespace blink |
| |
| namespace chrome_pdf { |
| |
| // Skeleton for a `blink::WebPlugin` to replace `OutOfProcessInstance`. |
| class PdfViewWebPlugin final : public PdfViewPluginBase, |
| public blink::WebPlugin { |
| public: |
| explicit PdfViewWebPlugin(const blink::WebPluginParams& params); |
| PdfViewWebPlugin(const PdfViewWebPlugin& other) = delete; |
| PdfViewWebPlugin& operator=(const PdfViewWebPlugin& other) = delete; |
| |
| // blink::WebPlugin: |
| bool Initialize(blink::WebPluginContainer* container) override; |
| void Destroy() override; |
| blink::WebPluginContainer* Container() const override; |
| void UpdateAllLifecyclePhases(blink::DocumentUpdateReason reason) override; |
| void Paint(cc::PaintCanvas* canvas, const blink::WebRect& rect) override; |
| void UpdateGeometry(const blink::WebRect& window_rect, |
| const blink::WebRect& clip_rect, |
| const blink::WebRect& unobscured_rect, |
| bool is_visible) override; |
| void UpdateFocus(bool focused, blink::mojom::FocusType focus_type) override; |
| void UpdateVisibility(bool visibility) override; |
| blink::WebInputEventResult HandleInputEvent( |
| const blink::WebCoalescedInputEvent& event, |
| ui::Cursor* cursor) override; |
| void DidReceiveResponse(const blink::WebURLResponse& response) override; |
| void DidReceiveData(const char* data, size_t data_length) override; |
| void DidFinishLoading() override; |
| void DidFailLoading(const blink::WebURLError& error) override; |
| |
| // PdfViewPluginBase: |
| void ProposeDocumentLayout(const DocumentLayout& layout) override; |
| void Invalidate(const pp::Rect& rect) override; |
| void DidScroll(const gfx::Vector2d& offset) override; |
| void ScrollToX(int x_in_screen_coords) override; |
| void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override; |
| void ScrollBy(const gfx::Vector2d& scroll_delta) override; |
| void ScrollToPage(int page) override; |
| void NavigateTo(const std::string& url, |
| WindowOpenDisposition disposition) override; |
| void NavigateToDestination(int page, |
| const float* x, |
| const float* y, |
| const float* zoom) override; |
| void UpdateCursor(PP_CursorType_Dev cursor) override; |
| void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) override; |
| void NotifyNumberOfFindResultsChanged(int total, bool final_result) override; |
| void NotifySelectedFindResultChanged(int current_find_index) override; |
| void NotifyTouchSelectionOccurred() override; |
| void GetDocumentPassword( |
| base::OnceCallback<void(const std::string&)> callback) override; |
| void Beep() override; |
| void Alert(const std::string& message) override; |
| bool Confirm(const std::string& message) override; |
| std::string Prompt(const std::string& question, |
| const std::string& default_answer) override; |
| std::string GetURL() override; |
| void Email(const std::string& to, |
| const std::string& cc, |
| const std::string& bcc, |
| const std::string& subject, |
| const std::string& body) override; |
| void Print() override; |
| void SubmitForm(const std::string& url, |
| const void* data, |
| int length) override; |
| pp::URLLoader CreateURLLoader() override; |
| std::vector<SearchStringResult> SearchString(const base::char16* string, |
| const base::char16* term, |
| bool case_sensitive) override; |
| void DocumentLoadComplete( |
| const PDFEngine::DocumentFeatures& document_features) override; |
| void DocumentLoadFailed() override; |
| pp::Instance* GetPluginInstance() override; |
| void DocumentHasUnsupportedFeature(const std::string& feature) override; |
| void DocumentLoadProgress(uint32_t available, uint32_t doc_size) override; |
| void FormTextFieldFocusChange(bool in_focus) override; |
| bool IsPrintPreview() override; |
| uint32_t GetBackgroundColor() override; |
| void IsSelectingChanged(bool is_selecting) override; |
| void SelectionChanged(const pp::Rect& left, const pp::Rect& right) override; |
| void EnteredEditMode() override; |
| float GetToolbarHeightInScreenCoords() override; |
| void DocumentFocusChanged(bool document_has_focus) override; |
| |
| private: |
| // Call `Destroy()` instead. |
| ~PdfViewWebPlugin() override; |
| |
| blink::WebPluginContainer* container_ = nullptr; |
| }; |
| |
| } // namespace chrome_pdf |
| |
| #endif // PDF_PDF_VIEW_WEB_PLUGIN_H_ |