diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-02-01 10:32:14 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-02-01 10:32:14 -0800 |
commit | 58fb36a3de3174db41669c2ed0d67e4a18a4a6de (patch) | |
tree | 5a91f3a0fdd2d6e4a28cf919040482c62a8a64e1 /samples/pdfium_test.cc | |
parent | 6c5acbd5478a316b31f7700fa33c45af7f9be6d5 (diff) | |
download | pdfium-58fb36a3de3174db41669c2ed0d67e4a18a4a6de.tar.xz |
Merge to XFA: Use JS_ExpandKeywordParams() in app.response()
Original Review URL: https://codereview.chromium.org/1654523002 .
(cherry picked from commit 3859258ebe9e81e1f766b57e7f78c786ae4ed495)
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1658753002 .
Diffstat (limited to 'samples/pdfium_test.cc')
-rw-r--r-- | samples/pdfium_test.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc index e3e28a5034..11afc2fcd6 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; |