Skip to content

Commit

Permalink
Remove most browser-side plugin-side PPAPI PDF interfaces.
Browse files Browse the repository at this point in the history
These private interfaces no longer have any users, now that the PDF
Viewer stopped using PPAPI. Delete the APIs, messages, and tests.

Keep a minimal interface to be removed in a follow-up.

Bug: 1302684
Change-Id: Ib6c72c1b9e5ece524189009fe38f454a0a3c5cab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3505370
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#979360}
  • Loading branch information
leizleiz authored and Chromium LUCI CQ committed Mar 9, 2022
1 parent fba088f commit 91a602d
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 1,059 deletions.
13 changes: 0 additions & 13 deletions chrome/browser/ui/pdf/chrome_pdf_web_contents_helper_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,9 @@
#include "chrome/browser/ui/tab_contents/core_tab_helper.h"
#include "chrome/common/content_restriction.h"
#include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h"
#include "ppapi/c/private/ppb_pdf.h"

namespace {

// For the UpdateContentRestrictions() call below, ensure the enum values in
// chrome/common/content_restriction.h and ppapi/c/private/ppb_pdf.h match.
#define STATIC_ASSERT_ENUM(a, b) \
static_assert(static_cast<int>(a) == static_cast<int>(b), \
"mismatching enums: " #a)

STATIC_ASSERT_ENUM(CONTENT_RESTRICTION_COPY, PP_CONTENT_RESTRICTION_COPY);
STATIC_ASSERT_ENUM(CONTENT_RESTRICTION_CUT, PP_CONTENT_RESTRICTION_CUT);
STATIC_ASSERT_ENUM(CONTENT_RESTRICTION_PASTE, PP_CONTENT_RESTRICTION_PASTE);
STATIC_ASSERT_ENUM(CONTENT_RESTRICTION_PRINT, PP_CONTENT_RESTRICTION_PRINT);
STATIC_ASSERT_ENUM(CONTENT_RESTRICTION_SAVE, PP_CONTENT_RESTRICTION_SAVE);

content::WebContents* GetWebContentsToUse(
content::WebContents* web_contents) {
// If we're viewing the PDF in a MimeHandlerViewGuest, use its embedder
Expand Down
3 changes: 0 additions & 3 deletions ppapi/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ source_set("ppapi_tests_sources") {
"tests/test_file_chooser.h",
"tests/test_net_address_private.cc",
"tests/test_net_address_private.h",
"tests/test_pdf.cc",
"tests/test_pdf.h",
"tests/test_tcp_socket_private_trusted.cc",
"tests/test_tcp_socket_private_trusted.h",
"tests/test_url_util.cc",
Expand Down Expand Up @@ -296,7 +294,6 @@ test("ppapi_unittests") {
"proxy/mock_resource.cc",
"proxy/mock_resource.h",
"proxy/nacl_message_scanner_unittest.cc",
"proxy/pdf_resource_unittest.cc",
"proxy/plugin_dispatcher_unittest.cc",
"proxy/plugin_resource_tracker_unittest.cc",
"proxy/plugin_var_tracker_unittest.cc",
Expand Down
116 changes: 0 additions & 116 deletions ppapi/c/private/ppb_pdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,129 +5,13 @@
#ifndef PPAPI_C_PRIVATE_PPB_PDF_H_
#define PPAPI_C_PRIVATE_PPB_PDF_H_

#include <stdint.h>

#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/private/pp_private_font_charset.h"

#define PPB_PDF_INTERFACE "PPB_PDF;1"

typedef enum {
PP_PDFFEATURE_HIDPI = 0,
PP_PDFFEATURE_PRINTING = 1
} PP_PDFFeature;

typedef enum {
PP_CONTENT_RESTRICTION_COPY = 1 << 0,
PP_CONTENT_RESTRICTION_CUT = 1 << 1,
PP_CONTENT_RESTRICTION_PASTE = 1 << 2,
PP_CONTENT_RESTRICTION_PRINT = 1 << 3,
PP_CONTENT_RESTRICTION_SAVE = 1 << 4
} PP_ContentRestriction;

struct PP_PrivateFontFileDescription {
const char* face;
uint32_t weight;
bool italic;
};

struct PP_PrivateFindResult {
int start_index;
int length;
};

struct PPB_PDF {
// Returns a resource identifying a font file corresponding to the given font
// request after applying the browser-specific fallback.
//
// Currently Linux-only.
PP_Resource (*GetFontFileWithFallback)(
PP_Instance instance,
const struct PP_BrowserFont_Trusted_Description* description,
PP_PrivateFontCharset charset);

// Given a resource previously returned by GetFontFileWithFallback, returns
// a pointer to the requested font table. Linux only.
bool (*GetFontTableForPrivateFontFile)(PP_Resource font_file,
uint32_t table,
void* output,
uint32_t* output_length);

// Search the given string using ICU. Use PPB_Core's MemFree on results when
// done.
void (*SearchString)(PP_Instance instance,
const unsigned short* string,
const unsigned short* term,
bool case_sensitive,
struct PP_PrivateFindResult** results,
uint32_t* count);

// Since WebFrame doesn't know about PPAPI requests, it'll think the page has
// finished loading even if there are outstanding requests by the plugin.
// Take this out once WebFrame knows about requests by PPAPI plugins.
void (*DidStartLoading)(PP_Instance instance);
void (*DidStopLoading)(PP_Instance instance);

// Sets content restriction for a full-page plugin (i.e. can't copy/print).
// The value is a bitfield of PP_ContentRestriction enums.
void (*SetContentRestriction)(PP_Instance instance, int restrictions);

// Notifies the browser that the given action has been performed.
void (*UserMetricsRecordAction)(PP_Instance instance, struct PP_Var action);

// Notifies the browser that the PDF has an unsupported feature.
void (*HasUnsupportedFeature)(PP_Instance instance);

// Invoke SaveAs... dialog, similar to the right-click or wrench menu.
void (*SaveAs)(PP_Instance instance);

// Invoke Print dialog for plugin.
void (*Print)(PP_Instance instance);

PP_Bool(*IsFeatureEnabled)(PP_Instance instance, PP_PDFFeature feature);

// Sets the selected text of the plugin.
void(*SetSelectedText)(PP_Instance instance, const char* selected_text);

// Sets the link currently under the cursor.
void (*SetLinkUnderCursor)(PP_Instance instance, const char* url);

// Gets pointers to the mmap'd V8 snapshot file and its size.
// This is needed when loading V8's initial snapshot from an external file.
void (*GetV8ExternalSnapshotData)(PP_Instance instance,
const char** snapshot_data_out,
int* snapshot_size_out);

// Sends information about the PDF's URL and the embedder's URL.
void (*SetCrashData)(PP_Instance instance,
const char* pdf_url,
const char* top_level_url);

// Sets the current selection bounding edges.
void (*SelectionChanged)(PP_Instance instance,
const struct PP_FloatPoint* left,
int32_t left_height,
const struct PP_FloatPoint* right,
int32_t right_height);

// Sets whether the PDF viewer can handle save commands internally.
void (*SetPluginCanSave)(PP_Instance instance, bool can_save);

// Displays an alert dialog.
void (*ShowAlertDialog)(PP_Instance instance, const char* message);

// Displays a confirmation dialog. This method is synchronous.
bool (*ShowConfirmDialog)(PP_Instance instance, const char* message);

// Displays a prompt dialog. This method is synchronous.
struct PP_Var (*ShowPromptDialog)(PP_Instance instance,
const char* message,
const char* default_answer);
};

#endif // PPAPI_C_PRIVATE_PPB_PDF_H_
177 changes: 0 additions & 177 deletions ppapi/cpp/private/pdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@

#include "ppapi/cpp/private/pdf.h"

#include "ppapi/c/trusted/ppb_browser_font_trusted.h"
#include "ppapi/cpp/image_data.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/cpp/module_impl.h"
#include "ppapi/cpp/var.h"

namespace pp {

Expand All @@ -25,184 +22,10 @@ bool PDF::IsAvailable() {
return has_interface<PPB_PDF>();
}

// static
PP_Resource PDF::GetFontFileWithFallback(
const InstanceHandle& instance,
const PP_BrowserFont_Trusted_Description* description,
PP_PrivateFontCharset charset) {
if (has_interface<PPB_PDF>()) {
return get_interface<PPB_PDF>()->GetFontFileWithFallback(
instance.pp_instance(), description, charset);
}
return 0;
}

// static
bool PDF::GetFontTableForPrivateFontFile(PP_Resource font_file,
uint32_t table,
void* output,
uint32_t* output_length) {
if (has_interface<PPB_PDF>()) {
return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile(font_file,
table, output, output_length);
}
return false;
}

// static
void PDF::SearchString(const InstanceHandle& instance,
const unsigned short* string,
const unsigned short* term,
bool case_sensitive,
PP_PrivateFindResult** results,
uint32_t* count) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SearchString(instance.pp_instance(), string,
term, case_sensitive, results, count);
}
}

// static
void PDF::DidStartLoading(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->DidStartLoading(instance.pp_instance());
}

// static
void PDF::DidStopLoading(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->DidStopLoading(instance.pp_instance());
}

// static
void PDF::SetContentRestriction(const InstanceHandle& instance,
int restrictions) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetContentRestriction(instance.pp_instance(),
restrictions);
}
}

// static
void PDF::UserMetricsRecordAction(const InstanceHandle& instance,
const Var& action) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->UserMetricsRecordAction(instance.pp_instance(),
action.pp_var());
}
}

// static
void PDF::HasUnsupportedFeature(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->HasUnsupportedFeature(instance.pp_instance());
}

// static
void PDF::ShowAlertDialog(const InstanceHandle& instance, const char* message) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->ShowAlertDialog(instance.pp_instance(), message);
}

// static
bool PDF::ShowConfirmDialog(const InstanceHandle& instance,
const char* message) {
if (has_interface<PPB_PDF>()) {
return get_interface<PPB_PDF>()->ShowConfirmDialog(instance.pp_instance(),
message);
}
return false;
}

// static
pp::Var PDF::ShowPromptDialog(const InstanceHandle& instance,
const char* message,
const char* default_answer) {
if (has_interface<PPB_PDF>()) {
return pp::Var(PASS_REF,
get_interface<PPB_PDF>()->ShowPromptDialog(
instance.pp_instance(), message, default_answer));
}
return pp::Var();
}

// static
void PDF::SaveAs(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->SaveAs(instance.pp_instance());
}

// static
void PDF::Print(const InstanceHandle& instance) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->Print(instance.pp_instance());
}

// static
bool PDF::IsFeatureEnabled(const InstanceHandle& instance,
PP_PDFFeature feature) {
if (has_interface<PPB_PDF>())
return PP_ToBool(get_interface<PPB_PDF>()->IsFeatureEnabled(
instance.pp_instance(), feature));
return false;
}

// static
void PDF::SetSelectedText(const InstanceHandle& instance,
const char* selected_text) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetSelectedText(instance.pp_instance(),
selected_text);
}
}

// static
void PDF::SetLinkUnderCursor(const InstanceHandle& instance, const char* url) {
if (has_interface<PPB_PDF>())
get_interface<PPB_PDF>()->SetLinkUnderCursor(instance.pp_instance(), url);
}

// static
void PDF::GetV8ExternalSnapshotData(const InstanceHandle& instance,
const char** snapshot_data_out,
int* snapshot_size_out) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->GetV8ExternalSnapshotData(
instance.pp_instance(), snapshot_data_out, snapshot_size_out);
return;
}
*snapshot_data_out = NULL;
*snapshot_size_out = 0;
}

// static
void PDF::SetCrashData(const InstanceHandle& instance,
const char* pdf_url,
const char* top_level_url) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetCrashData(instance.pp_instance(), pdf_url,
top_level_url);
}
}

// static
void PDF::SelectionChanged(const InstanceHandle& instance,
const PP_FloatPoint& left,
int32_t left_height,
const PP_FloatPoint& right,
int32_t right_height) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SelectionChanged(
instance.pp_instance(), &left, left_height, &right, right_height);
}
}

// static
void PDF::SetPluginCanSave(const InstanceHandle& instance, bool can_save) {
if (has_interface<PPB_PDF>()) {
get_interface<PPB_PDF>()->SetPluginCanSave(instance.pp_instance(),
can_save);
}
}

} // namespace pp
Loading

0 comments on commit 91a602d

Please sign in to comment.