Skip to content

Commit

Permalink
[unseasoned-pdf] Wrap pp::PDF::SaveAs() inside SaveAs().
Browse files Browse the repository at this point in the history
Wrap the pp::PDF::SaveAs() call inside PdfViewPluginBase::SaveAs() so
that SaveToFile() and HandleSaveMessage() can be migrated to
PdfViewPluginBase later.

Bug: 1109796
Change-Id: Ie8fbb58a5cb212a904dd6e94737cee7fe45c0cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2913138
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Daniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#889530}
  • Loading branch information
Hui Yingst authored and Chromium LUCI CQ committed Jun 5, 2021
1 parent 4eb34c1 commit 2208784
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,10 @@ void OutOfProcessInstance::SendMessage(base::Value message) {
PostMessage(VarFromValue(message));
}

void OutOfProcessInstance::SaveAs() {
pp::PDF::SaveAs(this);
}

void OutOfProcessInstance::InitImageData(const gfx::Size& size) {
pepper_image_data_ =
pp::ImageData(this, PP_IMAGEDATAFORMAT_BGRA_PREMUL, PPSizeFromSize(size),
Expand Down Expand Up @@ -904,7 +908,7 @@ void OutOfProcessInstance::NotifySelectedFindResultChanged(
void OutOfProcessInstance::SaveToFile(const std::string& token) {
engine()->KillFormFocus();
ConsumeSaveToken(token);
pp::PDF::SaveAs(this);
SaveAs();
}

void OutOfProcessInstance::Alert(const std::string& message) {
Expand Down
1 change: 1 addition & 0 deletions pdf/out_of_process_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
void DidOpenPreview(std::unique_ptr<UrlLoader> loader,
int32_t result) override;
void SendMessage(base::Value message) override;
void SaveAs() override;
void InitImageData(const gfx::Size& size) override;
Image GetPluginImageData() const override;
void SetFormFieldInFocus(bool in_focus) override;
Expand Down
3 changes: 3 additions & 0 deletions pdf/pdf_view_plugin_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class PdfViewPluginBase : public PDFEngine::Client,
// non-blocking.
virtual void SendMessage(base::Value message) = 0;

// Invokes the "SaveAs" dialog.
virtual void SaveAs() = 0;

void SaveToBuffer(const std::string& token);

// Consumes a token for saving the document.
Expand Down
2 changes: 2 additions & 0 deletions pdf/pdf_view_plugin_base_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class FakePdfViewPluginBase : public PdfViewPluginBase {
sent_message_ = std::move(message);
}

MOCK_METHOD(void, SaveAs, (), (override));

MOCK_METHOD(void, InitImageData, (const gfx::Size&), (override));

MOCK_METHOD(void, SetFormFieldInFocus, (bool in_focus), (override));
Expand Down
6 changes: 6 additions & 0 deletions pdf/pdf_view_web_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ void PdfViewWebPlugin::SendMessage(base::Value message) {
post_message_sender_.Post(std::move(message));
}

// TODO(https://crbug.com/1213294): Add a Pepper-free implementation that is
// equivalent to pp::PDF::SaveAs().
void PdfViewWebPlugin::SaveAs() {
NOTIMPLEMENTED();
}

void PdfViewWebPlugin::InitImageData(const gfx::Size& size) {
mutable_image_data() = CreateN32PremulSkBitmap(gfx::SizeToSkISize(size));
}
Expand Down
1 change: 1 addition & 0 deletions pdf/pdf_view_web_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
void DidOpenPreview(std::unique_ptr<UrlLoader> loader,
int32_t result) override;
void SendMessage(base::Value message) override;
void SaveAs() override;
void InitImageData(const gfx::Size& size) override;
void SetFormFieldInFocus(bool in_focus) override;
void SetAccessibilityDocInfo(const AccessibilityDocInfo& doc_info) override;
Expand Down

0 comments on commit 2208784

Please sign in to comment.