Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1949)

Unified Diff: samples/pdfium_test.cc

Issue 1658753002: Merge to XFA: Use JS_ExpandKeywordParams() in app.response() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/javascript/app.cpp ('k') | testing/resources/javascript/app_repsonse.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/pdfium_test.cc
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index e3e28a50346876af776b4591e723db625cd49b01..11afc2fcd68aeb1939ced9f06eabd8c987a54c24 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -195,6 +195,9 @@ void WriteEmf(FPDF_PAGE page, const char* pdf_name, int num) {
}
#endif
+// These example JS platform callback handlers are entirely optional,
+// and exist here to show the flow of information from a document back
+// to the embedder.
int ExampleAppAlert(IPDF_JSPLATFORM*,
FPDF_WIDESTRING msg,
FPDF_WIDESTRING title,
@@ -207,6 +210,29 @@ int ExampleAppAlert(IPDF_JSPLATFORM*,
return 0;
}
+int ExampleAppResponse(IPDF_JSPLATFORM*,
+ FPDF_WIDESTRING question,
+ FPDF_WIDESTRING title,
+ FPDF_WIDESTRING defaultValue,
+ FPDF_WIDESTRING label,
+ FPDF_BOOL isPassword,
+ void* response,
+ int length) {
+ printf("%ls: %ls, defaultValue=%ls, label=%ls, isPassword=%d, length=%d\n",
+ GetPlatformWString(title).c_str(),
+ GetPlatformWString(question).c_str(),
+ GetPlatformWString(defaultValue).c_str(),
+ GetPlatformWString(label).c_str(), isPassword, length);
+
+ // UTF-16, always LE regardless of platform.
+ uint8_t* ptr = static_cast<uint8_t*>(response);
+ ptr[0] = 'N';
+ ptr[1] = 0;
+ ptr[2] = 'o';
+ ptr[3] = 0;
+ return 4;
+}
+
void ExampleDocGotoPage(IPDF_JSPLATFORM*, int pageNumber) {
printf("Goto Page: %d\n", pageNumber);
}
@@ -425,6 +451,7 @@ void RenderPdf(const std::string& name, const char* pBuf, size_t len,
memset(&platform_callbacks, '\0', sizeof(platform_callbacks));
platform_callbacks.version = 3;
platform_callbacks.app_alert = ExampleAppAlert;
+ platform_callbacks.app_response = ExampleAppResponse;
platform_callbacks.Doc_gotoPage = ExampleDocGotoPage;
platform_callbacks.Doc_mail = ExampleDocMail;
« no previous file with comments | « fpdfsdk/src/javascript/app.cpp ('k') | testing/resources/javascript/app_repsonse.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698