Commit e5de01b2 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Give many PDFEngine::Client methods default implementations.

To make it possible to write a test client without having to write too
many empty implementations.

Change-Id: I45139957848a4d48e02740cc349605ab4b75e3a0
Reviewed-on: https://chromium-review.googlesource.com/1013997
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatardsinclair <dsinclair@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553781}
parent 5bdf8f57
...@@ -129,60 +129,60 @@ class PDFEngine { ...@@ -129,60 +129,60 @@ class PDFEngine {
virtual ~Client() {} virtual ~Client() {}
// Informs the client about the document's size in pixels. // Informs the client about the document's size in pixels.
virtual void DocumentSizeUpdated(const pp::Size& size) = 0; virtual void DocumentSizeUpdated(const pp::Size& size) {}
// Informs the client that the given rect needs to be repainted. // Informs the client that the given rect needs to be repainted.
virtual void Invalidate(const pp::Rect& rect) = 0; virtual void Invalidate(const pp::Rect& rect) {}
// Informs the client to scroll the plugin area by the given offset. // Informs the client to scroll the plugin area by the given offset.
virtual void DidScroll(const pp::Point& point) = 0; virtual void DidScroll(const pp::Point& point) {}
// Scroll the horizontal/vertical scrollbars to a given position. // Scroll the horizontal/vertical scrollbars to a given position.
// Values are in screen coordinates, where 0 is the top/left of the document // Values are in screen coordinates, where 0 is the top/left of the document
// and a positive value is the distance in pixels from that line. // and a positive value is the distance in pixels from that line.
// For ScrollToY, setting |compensate_for_toolbar| will align the position // For ScrollToY, setting |compensate_for_toolbar| will align the position
// with the bottom of the toolbar so the given position is always visible. // with the bottom of the toolbar so the given position is always visible.
virtual void ScrollToX(int x_in_screen_coords) = 0; virtual void ScrollToX(int x_in_screen_coords) {}
virtual void ScrollToY(int y_in_screen_coords, virtual void ScrollToY(int y_in_screen_coords,
bool compensate_for_toolbar) = 0; bool compensate_for_toolbar) {}
// Scroll by a given delta relative to the current position. // Scroll by a given delta relative to the current position.
virtual void ScrollBy(const pp::Point& point) = 0; virtual void ScrollBy(const pp::Point& point) {}
// Scroll to zero-based |page|. // Scroll to zero-based |page|.
virtual void ScrollToPage(int page) = 0; virtual void ScrollToPage(int page) {}
// Navigate to the given url. // Navigate to the given url.
virtual void NavigateTo(const std::string& url, virtual void NavigateTo(const std::string& url,
WindowOpenDisposition disposition) = 0; WindowOpenDisposition disposition) {}
// Updates the cursor. // Updates the cursor.
virtual void UpdateCursor(PP_CursorType_Dev cursor) = 0; virtual void UpdateCursor(PP_CursorType_Dev cursor) {}
// Updates the tick marks in the vertical scrollbar. // Updates the tick marks in the vertical scrollbar.
virtual void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) = 0; virtual void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) {}
// Updates the number of find results for the current search term. If // Updates the number of find results for the current search term. If
// there are no matches 0 should be passed in. Only when the plugin has // there are no matches 0 should be passed in. Only when the plugin has
// finished searching should it pass in the final count with final_result // finished searching should it pass in the final count with final_result
// set to true. // set to true.
virtual void NotifyNumberOfFindResultsChanged(int total, virtual void NotifyNumberOfFindResultsChanged(int total,
bool final_result) = 0; bool final_result) {}
// Updates the index of the currently selected search item. // Updates the index of the currently selected search item.
virtual void NotifySelectedFindResultChanged(int current_find_index) = 0; virtual void NotifySelectedFindResultChanged(int current_find_index) {}
// Notifies a page became visible. // Notifies a page became visible.
virtual void NotifyPageBecameVisible( virtual void NotifyPageBecameVisible(
const PDFEngine::PageFeatures* page_features) = 0; const PDFEngine::PageFeatures* page_features) {}
// Prompts the user for a password to open this document. The callback is // Prompts the user for a password to open this document. The callback is
// called when the password is retrieved. // called when the password is retrieved.
virtual void GetDocumentPassword( virtual void GetDocumentPassword(
pp::CompletionCallbackWithOutput<pp::Var> callback) = 0; pp::CompletionCallbackWithOutput<pp::Var> callback) {}
// Puts up an alert with the given message. // Puts up an alert with the given message.
virtual void Alert(const std::string& message) = 0; virtual void Alert(const std::string& message) {}
// Puts up a confirm with the given message, and returns true if the user // Puts up a confirm with the given message, and returns true if the user
// presses OK, or false if they press cancel. // presses OK, or false if they press cancel.
...@@ -201,24 +201,24 @@ class PDFEngine { ...@@ -201,24 +201,24 @@ class PDFEngine {
const std::string& cc, const std::string& cc,
const std::string& bcc, const std::string& bcc,
const std::string& subject, const std::string& subject,
const std::string& body) = 0; const std::string& body) {}
// Put up the print dialog. // Put up the print dialog.
virtual void Print() = 0; virtual void Print() {}
// Submit the data using HTTP POST. // Submit the data using HTTP POST.
virtual void SubmitForm(const std::string& url, virtual void SubmitForm(const std::string& url,
const void* data, const void* data,
int length) = 0; int length) {}
// Creates and returns new URL loader for partial document requests. // Creates and returns new URL loader for partial document requests.
virtual pp::URLLoader CreateURLLoader() = 0; virtual pp::URLLoader CreateURLLoader() = 0;
// Calls the client's OnCallback() function in |delay| with the given |id|. // Calls the client's OnCallback() function in |delay| with the given |id|.
virtual void ScheduleCallback(int id, base::TimeDelta delay) = 0; virtual void ScheduleCallback(int id, base::TimeDelta delay) {}
// Calls the client's OnTouchTimerCallback() function in |delay| with the // Calls the client's OnTouchTimerCallback() function in |delay| with the
// given |id|. // given |id|.
virtual void ScheduleTouchTimerCallback(int id, base::TimeDelta delay) = 0; virtual void ScheduleTouchTimerCallback(int id, base::TimeDelta delay) {}
// Searches the given string for "term" and returns the results. Unicode- // Searches the given string for "term" and returns the results. Unicode-
// aware. // aware.
...@@ -232,29 +232,28 @@ class PDFEngine { ...@@ -232,29 +232,28 @@ class PDFEngine {
bool case_sensitive) = 0; bool case_sensitive) = 0;
// Notifies the client that the engine has painted a page from the document. // Notifies the client that the engine has painted a page from the document.
virtual void DocumentPaintOccurred() = 0; virtual void DocumentPaintOccurred() {}
// Notifies the client that the document has finished loading. // Notifies the client that the document has finished loading.
virtual void DocumentLoadComplete(const DocumentFeatures& document_features, virtual void DocumentLoadComplete(const DocumentFeatures& document_features,
uint32_t file_size) = 0; uint32_t file_size) {}
// Notifies the client that the document has failed to load. // Notifies the client that the document has failed to load.
virtual void DocumentLoadFailed() = 0; virtual void DocumentLoadFailed() {}
// Notifies the client that the document has requested substitute fonts. // Notifies the client that the document has requested substitute fonts.
virtual void FontSubstituted() = 0; virtual void FontSubstituted() {}
virtual pp::Instance* GetPluginInstance() = 0; virtual pp::Instance* GetPluginInstance() = 0;
// Notifies that an unsupported feature in the PDF was encountered. // Notifies that an unsupported feature in the PDF was encountered.
virtual void DocumentHasUnsupportedFeature(const std::string& feature) = 0; virtual void DocumentHasUnsupportedFeature(const std::string& feature) {}
// Notifies the client about document load progress. // Notifies the client about document load progress.
virtual void DocumentLoadProgress(uint32_t available, virtual void DocumentLoadProgress(uint32_t available, uint32_t doc_size) {}
uint32_t doc_size) = 0;
// Notifies the client about focus changes for form text fields. // Notifies the client about focus changes for form text fields.
virtual void FormTextFieldFocusChange(bool in_focus) = 0; virtual void FormTextFieldFocusChange(bool in_focus) {}
// Returns true if the plugin has been opened within print preview. // Returns true if the plugin has been opened within print preview.
virtual bool IsPrintPreview() = 0; virtual bool IsPrintPreview() = 0;
...@@ -263,7 +262,7 @@ class PDFEngine { ...@@ -263,7 +262,7 @@ class PDFEngine {
virtual uint32_t GetBackgroundColor() = 0; virtual uint32_t GetBackgroundColor() = 0;
// Cancel browser initiated document download. // Cancel browser initiated document download.
virtual void CancelBrowserDownload() = 0; virtual void CancelBrowserDownload() {}
// Sets selection status. // Sets selection status.
virtual void IsSelectingChanged(bool is_selecting) {} virtual void IsSelectingChanged(bool is_selecting) {}
......
...@@ -12,8 +12,6 @@ namespace chrome_pdf { ...@@ -12,8 +12,6 @@ namespace chrome_pdf {
PreviewModeClient::PreviewModeClient(Client* client) : client_(client) {} PreviewModeClient::PreviewModeClient(Client* client) : client_(client) {}
void PreviewModeClient::DocumentSizeUpdated(const pp::Size& size) {}
void PreviewModeClient::Invalidate(const pp::Rect& rect) { void PreviewModeClient::Invalidate(const pp::Rect& rect) {
NOTREACHED(); NOTREACHED();
} }
...@@ -63,9 +61,6 @@ void PreviewModeClient::NotifySelectedFindResultChanged( ...@@ -63,9 +61,6 @@ void PreviewModeClient::NotifySelectedFindResultChanged(
NOTREACHED(); NOTREACHED();
} }
void PreviewModeClient::NotifyPageBecameVisible(
const PDFEngine::PageFeatures* page_features) {}
void PreviewModeClient::GetDocumentPassword( void PreviewModeClient::GetDocumentPassword(
pp::CompletionCallbackWithOutput<pp::Var> callback) { pp::CompletionCallbackWithOutput<pp::Var> callback) {
callback.Run(PP_ERROR_FAILED); callback.Run(PP_ERROR_FAILED);
...@@ -158,9 +153,6 @@ void PreviewModeClient::FontSubstituted() { ...@@ -158,9 +153,6 @@ void PreviewModeClient::FontSubstituted() {
NOTREACHED(); NOTREACHED();
} }
void PreviewModeClient::DocumentLoadProgress(uint32_t available,
uint32_t doc_size) {}
void PreviewModeClient::FormTextFieldFocusChange(bool in_focus) { void PreviewModeClient::FormTextFieldFocusChange(bool in_focus) {
NOTREACHED(); NOTREACHED();
} }
...@@ -170,8 +162,6 @@ bool PreviewModeClient::IsPrintPreview() { ...@@ -170,8 +162,6 @@ bool PreviewModeClient::IsPrintPreview() {
return false; return false;
} }
void PreviewModeClient::CancelBrowserDownload() {}
float PreviewModeClient::GetToolbarHeightInScreenCoords() { float PreviewModeClient::GetToolbarHeightInScreenCoords() {
return 0.0f; return 0.0f;
} }
......
...@@ -27,7 +27,6 @@ class PreviewModeClient : public PDFEngine::Client { ...@@ -27,7 +27,6 @@ class PreviewModeClient : public PDFEngine::Client {
~PreviewModeClient() override {} ~PreviewModeClient() override {}
// PDFEngine::Client implementation. // PDFEngine::Client implementation.
void DocumentSizeUpdated(const pp::Size& size) override;
void Invalidate(const pp::Rect& rect) override; void Invalidate(const pp::Rect& rect) override;
void DidScroll(const pp::Point& point) override; void DidScroll(const pp::Point& point) override;
void ScrollToX(int x_in_screen_coords) override; void ScrollToX(int x_in_screen_coords) override;
...@@ -40,8 +39,6 @@ class PreviewModeClient : public PDFEngine::Client { ...@@ -40,8 +39,6 @@ class PreviewModeClient : public PDFEngine::Client {
void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) override; void UpdateTickMarks(const std::vector<pp::Rect>& tickmarks) override;
void NotifyNumberOfFindResultsChanged(int total, bool final_result) override; void NotifyNumberOfFindResultsChanged(int total, bool final_result) override;
void NotifySelectedFindResultChanged(int current_find_index) override; void NotifySelectedFindResultChanged(int current_find_index) override;
void NotifyPageBecameVisible(
const PDFEngine::PageFeatures* page_features) override;
void GetDocumentPassword( void GetDocumentPassword(
pp::CompletionCallbackWithOutput<pp::Var> callback) override; pp::CompletionCallbackWithOutput<pp::Var> callback) override;
void Alert(const std::string& message) override; void Alert(const std::string& message) override;
...@@ -72,10 +69,8 @@ class PreviewModeClient : public PDFEngine::Client { ...@@ -72,10 +69,8 @@ class PreviewModeClient : public PDFEngine::Client {
void FontSubstituted() override; void FontSubstituted() override;
pp::Instance* GetPluginInstance() override; pp::Instance* GetPluginInstance() override;
void DocumentHasUnsupportedFeature(const std::string& feature) override; void DocumentHasUnsupportedFeature(const std::string& feature) override;
void DocumentLoadProgress(uint32_t available, uint32_t doc_size) override;
void FormTextFieldFocusChange(bool in_focus) override; void FormTextFieldFocusChange(bool in_focus) override;
bool IsPrintPreview() override; bool IsPrintPreview() override;
void CancelBrowserDownload() override;
float GetToolbarHeightInScreenCoords() override; float GetToolbarHeightInScreenCoords() override;
uint32_t GetBackgroundColor() override; uint32_t GetBackgroundColor() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment