#include "pdf/pdfium/pdfium_form_filler.h"
#include <algorithm>
#include <memory>
#include <string>
#include <utility>
#include "base/auto_reset.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "pdf/pdf_features.h"
#include "pdf/pdfium/pdfium_engine.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/pdfium/public/fpdf_annot.h"
#include "ui/base/window_open_disposition_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "v8/include/v8-isolate.h"
namespace chrome_pdf {
namespace {
int g_last_timer_id = …;
#if defined(PDF_ENABLE_V8)
std::string WideStringToString(FPDF_WIDESTRING wide_string) { … }
#endif
}
PDFiumFormFiller::ScriptOption PDFiumFormFiller::DefaultScriptOption() { … }
PDFiumFormFiller::PDFiumFormFiller(PDFiumEngine* engine,
ScriptOption script_option)
: … { … }
PDFiumFormFiller::~PDFiumFormFiller() = default;
void PDFiumFormFiller::Form_Invalidate(FPDF_FORMFILLINFO* param,
FPDF_PAGE page,
double left,
double top,
double right,
double bottom) { … }
void PDFiumFormFiller::Form_OutputSelectedRect(FPDF_FORMFILLINFO* param,
FPDF_PAGE page,
double left,
double top,
double right,
double bottom) { … }
void PDFiumFormFiller::Form_SetCursor(FPDF_FORMFILLINFO* param,
int cursor_type) { … }
int PDFiumFormFiller::Form_SetTimer(FPDF_FORMFILLINFO* param,
int elapse,
TimerCallback timer_func) { … }
void PDFiumFormFiller::Form_KillTimer(FPDF_FORMFILLINFO* param, int timer_id) { … }
FPDF_SYSTEMTIME PDFiumFormFiller::Form_GetLocalTime(FPDF_FORMFILLINFO* param) { … }
void PDFiumFormFiller::Form_OnChange(FPDF_FORMFILLINFO* param) { … }
FPDF_PAGE PDFiumFormFiller::Form_GetPage(FPDF_FORMFILLINFO* param,
FPDF_DOCUMENT document,
int page_index) { … }
FPDF_PAGE PDFiumFormFiller::Form_GetCurrentPage(FPDF_FORMFILLINFO* param,
FPDF_DOCUMENT document) { … }
int PDFiumFormFiller::Form_GetRotation(FPDF_FORMFILLINFO* param,
FPDF_PAGE page) { … }
void PDFiumFormFiller::Form_ExecuteNamedAction(FPDF_FORMFILLINFO* param,
FPDF_BYTESTRING named_action) { … }
void PDFiumFormFiller::Form_SetTextFieldFocus(FPDF_FORMFILLINFO* param,
FPDF_WIDESTRING value,
FPDF_DWORD valueLen,
FPDF_BOOL is_focus) { … }
void PDFiumFormFiller::Form_OnFocusChange(FPDF_FORMFILLINFO* param,
FPDF_ANNOTATION annot,
int page_index) { … }
void PDFiumFormFiller::Form_DoURIAction(FPDF_FORMFILLINFO* param,
FPDF_BYTESTRING uri) { … }
void PDFiumFormFiller::Form_DoGoToAction(FPDF_FORMFILLINFO* param,
int page_index,
int zoom_mode,
float* position_array,
int size_of_array) { … }
void PDFiumFormFiller::Form_DoURIActionWithKeyboardModifier(
FPDF_FORMFILLINFO* param,
FPDF_BYTESTRING uri,
int modifiers) { … }
#if defined(PDF_ENABLE_V8)
#if defined(PDF_ENABLE_XFA)
void PDFiumFormFiller::Form_EmailTo(FPDF_FORMFILLINFO* param,
FPDF_FILEHANDLER* file_handler,
FPDF_WIDESTRING to,
FPDF_WIDESTRING subject,
FPDF_WIDESTRING cc,
FPDF_WIDESTRING bcc,
FPDF_WIDESTRING message) { … }
void PDFiumFormFiller::Form_DisplayCaret(FPDF_FORMFILLINFO* param,
FPDF_PAGE page,
FPDF_BOOL visible,
double left,
double top,
double right,
double bottom) { … }
void PDFiumFormFiller::Form_SetCurrentPage(FPDF_FORMFILLINFO* param,
FPDF_DOCUMENT document,
int page) { … }
int PDFiumFormFiller::Form_GetCurrentPageIndex(FPDF_FORMFILLINFO* param,
FPDF_DOCUMENT document) { … }
void PDFiumFormFiller::Form_GetPageViewRect(FPDF_FORMFILLINFO* param,
FPDF_PAGE page,
double* left,
double* top,
double* right,
double* bottom) { … }
int PDFiumFormFiller::Form_GetPlatform(FPDF_FORMFILLINFO* param,
void* platform,
int length) { … }
void PDFiumFormFiller::Form_PageEvent(FPDF_FORMFILLINFO* param,
int page_count,
unsigned long event_type) { … }
FPDF_BOOL PDFiumFormFiller::Form_PopupMenu(FPDF_FORMFILLINFO* param,
FPDF_PAGE page,
FPDF_WIDGET widget,
int menu_flag,
float x,
float y) { … }
FPDF_BOOL PDFiumFormFiller::Form_PostRequestURL(FPDF_FORMFILLINFO* param,
FPDF_WIDESTRING url,
FPDF_WIDESTRING data,
FPDF_WIDESTRING content_type,
FPDF_WIDESTRING encode,
FPDF_WIDESTRING header,
FPDF_BSTR* response) { … }
FPDF_BOOL PDFiumFormFiller::Form_PutRequestURL(FPDF_FORMFILLINFO* param,
FPDF_WIDESTRING url,
FPDF_WIDESTRING data,
FPDF_WIDESTRING encode) { … }
void PDFiumFormFiller::Form_UploadTo(FPDF_FORMFILLINFO* param,
FPDF_FILEHANDLER* file_handle,
int file_flag,
FPDF_WIDESTRING to) { … }
FPDF_FILEHANDLER* PDFiumFormFiller::Form_DownloadFromURL(
FPDF_FORMFILLINFO* param,
FPDF_WIDESTRING url) { … }
FPDF_FILEHANDLER* PDFiumFormFiller::Form_OpenFile(FPDF_FORMFILLINFO* param,
int file_flag,
FPDF_WIDESTRING url,
const char* mode) { … }
void PDFiumFormFiller::Form_GotoURL(FPDF_FORMFILLINFO* param,
FPDF_DOCUMENT document,
FPDF_WIDESTRING url) { … }
int PDFiumFormFiller::Form_GetLanguage(FPDF_FORMFILLINFO* param,
void* language,
int length) { … }
#endif
int PDFiumFormFiller::Form_Alert(IPDF_JSPLATFORM* param,
FPDF_WIDESTRING message,
FPDF_WIDESTRING title,
int type,
int icon) { … }
void PDFiumFormFiller::Form_Beep(IPDF_JSPLATFORM* param, int type) { … }
int PDFiumFormFiller::Form_Response(IPDF_JSPLATFORM* param,
FPDF_WIDESTRING question,
FPDF_WIDESTRING title,
FPDF_WIDESTRING default_response,
FPDF_WIDESTRING label,
FPDF_BOOL password,
void* response,
int length) { … }
int PDFiumFormFiller::Form_GetFilePath(IPDF_JSPLATFORM* param,
void* file_path,
int length) { … }
void PDFiumFormFiller::Form_Mail(IPDF_JSPLATFORM* param,
void* mail_data,
int length,
FPDF_BOOL ui,
FPDF_WIDESTRING to,
FPDF_WIDESTRING subject,
FPDF_WIDESTRING cc,
FPDF_WIDESTRING bcc,
FPDF_WIDESTRING message) { … }
void PDFiumFormFiller::Form_Print(IPDF_JSPLATFORM* param,
FPDF_BOOL ui,
int start,
int end,
FPDF_BOOL silent,
FPDF_BOOL shrink_to_fit,
FPDF_BOOL print_as_image,
FPDF_BOOL reverse,
FPDF_BOOL annotations) { … }
void PDFiumFormFiller::Form_SubmitForm(IPDF_JSPLATFORM* param,
void* form_data,
int length,
FPDF_WIDESTRING url) { … }
void PDFiumFormFiller::Form_GotoPage(IPDF_JSPLATFORM* param, int page_number) { … }
#endif
PDFiumFormFiller::EngineInIsolateScope::EngineInIsolateScope(
PDFiumEngine* engine,
v8::Isolate* isolate)
: … { … }
PDFiumFormFiller::EngineInIsolateScope::EngineInIsolateScope(
EngineInIsolateScope&&) noexcept = default;
PDFiumFormFiller::EngineInIsolateScope&
PDFiumFormFiller::EngineInIsolateScope::operator=(
EngineInIsolateScope&&) noexcept = default;
PDFiumFormFiller::EngineInIsolateScope::~EngineInIsolateScope() = default;
PDFiumFormFiller::EngineInIsolateScopeFactory::EngineInIsolateScopeFactory(
PDFiumEngine* engine,
ScriptOption script_option)
: … { … }
PDFiumFormFiller::EngineInIsolateScopeFactory::~EngineInIsolateScopeFactory() =
default;
PDFiumFormFiller::EngineInIsolateScope
PDFiumFormFiller::EngineInIsolateScopeFactory::GetEngineInIsolateScope() const { … }
PDFiumFormFiller::EngineInIsolateScope
PDFiumFormFiller::GetEngineInIsolateScope(FPDF_FORMFILLINFO* info) { … }
PDFiumFormFiller::EngineInIsolateScope
PDFiumFormFiller::GetEngineInIsolateScope(IPDF_JSPLATFORM* platform) { … }
int PDFiumFormFiller::SetTimer(const base::TimeDelta& delay,
TimerCallback timer_func) { … }
void PDFiumFormFiller::KillTimer(int timer_id) { … }
}