Revert "Revert "[PDF] Avoid sending unnecessary SetPluginCanSave messages""
This reverts commit73dcfc0ec3
. Reason for revert: LUCI Bisection has identified this change as the culprit of a build failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/compile-analysis/b/8731798983355037505 Sample failed build: https://ci.chromium.org/b/8731798983355037505 If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F6006316&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Fcompile-analysis%2Fb%2F8731798983355037505&type=BUG Original change's description: > Revert "[PDF] Avoid sending unnecessary SetPluginCanSave messages" > > This reverts commit1b98c1c3c1
. > > Reason for revert: Causing failure on linux-chromeos-chrome > https://ci.chromium.org/ui/p/chrome/builders/ci/linux-chromeos-chrome/46306/overview > > Original change's description: > > [PDF] Avoid sending unnecessary SetPluginCanSave messages > > > > SetPluginCanSave is a renderer-to-browser message that PdfViewWebPlugin > > sends to let the browser know that the plugin will handle the save. > > PdfViewWebPlugin can send the message multiple times, even if the > > browser already knows if the plugin will handle the save. Avoid > > redundant calls. > > > > Change-Id: Ice4dbc0d97fd70a48d7314adf7dc50f9a5a2dabf > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6001192 > > Reviewed-by: Lei Zhang <thestig@chromium.org> > > Commit-Queue: Andy Phan <andyphan@chromium.org> > > Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> > > Cr-Commit-Position: refs/heads/main@{#1380560} > > Change-Id: Ie8f963e9d763f5c830ee1a57dc3a200df045534b > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6006316 > Owners-Override: Di Zhang <dizhangg@google.com> > Commit-Queue: Di Zhang <dizhangg@chromium.org> > Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> > Cr-Commit-Position: refs/heads/main@{#1380649} > Change-Id: I1af9a60d05ba4febe96df789843b1738b4270f6f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6006340 Bot-Commit: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Commit-Queue: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Owners-Override: luci-bisection@appspot.gserviceaccount.com <luci-bisection@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1380708}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
533db116bb
commit
e8ef050781
@ -1380,7 +1380,7 @@ void PdfViewWebPlugin::SelectionChanged(const gfx::Rect& left,
|
||||
|
||||
void PdfViewWebPlugin::EnteredEditMode() {
|
||||
edit_mode_ = true;
|
||||
pdf_host_->SetPluginCanSave(true);
|
||||
SetPluginCanSave(true);
|
||||
|
||||
base::Value::Dict message;
|
||||
message.Set("type", "setIsEditing");
|
||||
@ -1690,17 +1690,19 @@ void PdfViewWebPlugin::HandleSaveMessage(const base::Value::Dict& message) {
|
||||
#if BUILDFLAG(ENABLE_INK)
|
||||
// In annotation mode, assume the user will make edits and prefer saving
|
||||
// using the plugin data.
|
||||
pdf_host_->SetPluginCanSave(true);
|
||||
SetPluginCanSave(true);
|
||||
SaveToBuffer(token);
|
||||
return;
|
||||
#else
|
||||
NOTREACHED();
|
||||
#endif // BUILDFLAG(ENABLE_INK)
|
||||
case SaveRequestType::kOriginal:
|
||||
pdf_host_->SetPluginCanSave(false);
|
||||
case SaveRequestType::kOriginal: {
|
||||
const bool can_save = plugin_can_save_ || edit_mode_;
|
||||
SetPluginCanSave(false);
|
||||
SaveToFile(token);
|
||||
pdf_host_->SetPluginCanSave(edit_mode_);
|
||||
SetPluginCanSave(can_save);
|
||||
return;
|
||||
}
|
||||
case SaveRequestType::kEdited:
|
||||
SaveToBuffer(token);
|
||||
return;
|
||||
@ -1909,6 +1911,15 @@ void PdfViewWebPlugin::SaveToFile(const std::string& token) {
|
||||
pdf_host_->SaveUrlAs(GURL(url_), network::mojom::ReferrerPolicy::kDefault);
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::SetPluginCanSave(bool can_save) {
|
||||
if (plugin_can_save_ == can_save) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin_can_save_ = can_save;
|
||||
pdf_host_->SetPluginCanSave(can_save);
|
||||
}
|
||||
|
||||
void PdfViewWebPlugin::InvalidatePluginContainer() {
|
||||
client_->Invalidate();
|
||||
}
|
||||
|
@ -556,6 +556,11 @@ class PdfViewWebPlugin final : public PDFiumEngineClient,
|
||||
void SaveToBuffer(const std::string& token);
|
||||
void SaveToFile(const std::string& token);
|
||||
|
||||
// Sets whether the plugin can and should handle the save by using `pdf_host_`
|
||||
// to notify the browser. Prevents duplicate notifications to the browser if
|
||||
// the state has not changed.
|
||||
void SetPluginCanSave(bool can_save);
|
||||
|
||||
// Converts a scroll offset (which is relative to a UI direction-dependent
|
||||
// scroll origin) to a scroll position (which is always relative to the
|
||||
// top-left corner).
|
||||
@ -702,6 +707,8 @@ class PdfViewWebPlugin final : public PDFiumEngineClient,
|
||||
|
||||
bool initialized_ = false;
|
||||
|
||||
bool plugin_can_save_ = false;
|
||||
|
||||
blink::WebString selected_text_;
|
||||
|
||||
std::unique_ptr<Client> const client_;
|
||||
|
@ -2014,10 +2014,8 @@ TEST_F(PdfViewWebPluginSaveTest, OriginalInNonEditMode) {
|
||||
{
|
||||
InSequence pdf_host_sequence;
|
||||
|
||||
EXPECT_CALL(pdf_host_, SetPluginCanSave(false));
|
||||
EXPECT_CALL(pdf_host_, SaveUrlAs(GURL(kPdfUrl),
|
||||
network::mojom::ReferrerPolicy::kDefault));
|
||||
EXPECT_CALL(pdf_host_, SetPluginCanSave(false));
|
||||
}
|
||||
|
||||
ExpectUpdateTextInputState(blink::WebTextInputType::kWebTextInputTypeNone);
|
||||
|
Reference in New Issue
Block a user