0

[PDF] Remove HasUnsupportedFeature Mojo interface

This IPC message to the browser ends up as a no-op, as the browser no
longer displays an infobar in response. Remove the IPC, considering it
has been a no-op for nearly a decade.

Change-Id: I673cd8a2558b4a84afd5d573c020ff701a3c237e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6220800
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1414512}
This commit is contained in:
Lei Zhang
2025-01-31 19:00:17 -08:00
committed by Chromium LUCI CQ
parent 7a8bd71436
commit 9f667cbe2e
10 changed files with 2 additions and 42 deletions

@ -65,12 +65,6 @@ void ChromePDFDocumentHelperClient::UpdateContentRestrictions(
}
}
void ChromePDFDocumentHelperClient::OnPDFHasUnsupportedFeature(
content::WebContents* contents) {
// There is no more Adobe plugin for PDF so there is not much we can do in
// this case. Maybe simply download the file.
}
void ChromePDFDocumentHelperClient::OnSaveURL(content::WebContents* contents) {
RecordDownloadSource(DOWNLOAD_INITIATED_BY_PDF_SAVE);
}

@ -21,7 +21,6 @@ class ChromePDFDocumentHelperClient : public pdf::PDFDocumentHelperClient {
// pdf::PDFDocumentHelperClient:
void UpdateContentRestrictions(content::RenderFrameHost* render_frame_host,
int content_restrictions) override;
void OnPDFHasUnsupportedFeature(content::WebContents* contents) override;
void OnSaveURL(content::WebContents* contents) override;
void SetPluginCanSave(content::RenderFrameHost* render_frame_host,
bool can_save) override;

@ -381,10 +381,6 @@ void PDFDocumentHelper::InitTouchSelectionClientManager() {
touch_selection_controller_client_manager_->AddObserver(this);
}
void PDFDocumentHelper::HasUnsupportedFeature() {
client_->OnPDFHasUnsupportedFeature(&GetWebContents());
}
void PDFDocumentHelper::SaveUrlAs(const GURL& url,
network::mojom::ReferrerPolicy policy) {
client_->OnSaveURL(&GetWebContents());

@ -81,7 +81,6 @@ class PDFDocumentHelper
// pdf::mojom::PdfHost:
void SetListener(mojo::PendingRemote<mojom::PdfListener> listener) override;
void HasUnsupportedFeature() override;
void SaveUrlAs(const GURL& url,
network::mojom::ReferrerPolicy policy) override;
void UpdateContentRestrictions(int32_t content_restrictions) override;

@ -70,7 +70,6 @@ class TestPDFDocumentHelperClient : public PDFDocumentHelperClient {
// PDFDocumentHelperClient:
void UpdateContentRestrictions(content::RenderFrameHost* render_frame_host,
int content_restrictions) override {}
void OnPDFHasUnsupportedFeature(content::WebContents* contents) override {}
void OnSaveURL(content::WebContents* contents) override {}
void SetPluginCanSave(content::RenderFrameHost* render_frame_host,
bool can_save) override {}

@ -24,8 +24,6 @@ class PDFDocumentHelperClient {
content::RenderFrameHost* render_frame_host,
int content_restrictions) = 0;
virtual void OnPDFHasUnsupportedFeature(content::WebContents* contents) = 0;
virtual void OnSaveURL(content::WebContents* contents) = 0;
// Sets whether the PDF plugin can handle file saving internally.

@ -51,9 +51,6 @@ interface PdfHost {
// Updates the content restrictions, i.e. to disable print/copy.
UpdateContentRestrictions(int32 restrictions);
// The currently displayed PDF has an unsupported feature.
HasUnsupportedFeature();
// Brings up SaveAs... dialog to save specified URL.
SaveUrlAs(url.mojom.Url url, network.mojom.ReferrerPolicy policy);

@ -1330,14 +1330,9 @@ void PdfViewWebPlugin::DocumentHasUnsupportedFeature(
const std::string& feature) {
DCHECK(!feature.empty());
std::string metric = base::StrCat({"PDF_Unsupported_", feature});
if (unsupported_features_reported_.insert(metric).second)
if (unsupported_features_reported_.insert(metric).second) {
client_->RecordComputedAction(metric);
if (!full_frame_ || notified_browser_about_unsupported_feature_)
return;
notified_browser_about_unsupported_feature_ = true;
pdf_host_->HasUnsupportedFeature();
}
}
void PdfViewWebPlugin::DocumentLoadProgress(uint32_t available,

@ -895,10 +895,6 @@ class PdfViewWebPlugin final : public PDFiumEngineClient,
// spamming the metrics if a feature shows up many times per document.
base::flat_set<std::string> unsupported_features_reported_;
// Indicates whether the browser has been notified about an unsupported
// feature once, which helps prevent the infobar from going up more than once.
bool notified_browser_about_unsupported_feature_ = false;
// The metafile in which to save the printed output. Assigned a value only
// between `PrintBegin()` and `PrintEnd()` calls.
raw_ptr<printing::MetafileSkia> printing_metafile_ = nullptr;

@ -365,7 +365,6 @@ class FakePdfHost : public pdf::mojom::PdfHost {
(mojo::PendingRemote<pdf::mojom::PdfListener>),
(override));
MOCK_METHOD(void, UpdateContentRestrictions, (int32_t), (override));
MOCK_METHOD(void, HasUnsupportedFeature, (), (override));
MOCK_METHOD(void,
SaveUrlAs,
(const GURL&, network::mojom::ReferrerPolicy),
@ -773,9 +772,6 @@ TEST_F(PdfViewWebPluginTest, DocumentHasUnsupportedFeature) {
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature1"));
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature2"));
// `HasUnsupportedFeature()` is not called if the viewer is not full-frame.
EXPECT_CALL(pdf_host_, HasUnsupportedFeature).Times(0);
plugin_->DocumentHasUnsupportedFeature("feature1");
plugin_->DocumentHasUnsupportedFeature("feature2");
@ -787,9 +783,6 @@ TEST_F(PdfViewWebPluginTest, DocumentHasUnsupportedFeatureWithRepeatedFeature) {
EXPECT_CALL(*client_ptr_, RecordComputedAction).Times(AnyNumber());
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature"));
// `HasUnsupportedFeature()` is not called if the viewer is not full-frame.
EXPECT_CALL(pdf_host_, HasUnsupportedFeature).Times(0);
plugin_->DocumentHasUnsupportedFeature("feature");
plugin_->DocumentHasUnsupportedFeature("feature");
@ -801,9 +794,6 @@ TEST_F(PdfViewWebPluginFullFrameTest, DocumentHasUnsupportedFeature) {
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature1"));
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature2"));
// `HasUnsupportedFeature()` is called once for all features.
EXPECT_CALL(pdf_host_, HasUnsupportedFeature);
plugin_->DocumentHasUnsupportedFeature("feature1");
plugin_->DocumentHasUnsupportedFeature("feature2");
@ -816,9 +806,6 @@ TEST_F(PdfViewWebPluginFullFrameTest,
EXPECT_CALL(*client_ptr_, RecordComputedAction).Times(AnyNumber());
EXPECT_CALL(*client_ptr_, RecordComputedAction("PDF_Unsupported_feature"));
// `HasUnsupportedFeature()` is called once for all features.
EXPECT_CALL(pdf_host_, HasUnsupportedFeature);
plugin_->DocumentHasUnsupportedFeature("feature");
plugin_->DocumentHasUnsupportedFeature("feature");