diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-02-01 10:24:14 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-02-01 10:24:14 -0800 |
commit | 3859258ebe9e81e1f766b57e7f78c786ae4ed495 (patch) | |
tree | 60e9a7b68698842b775a0a8bc84a6585bee1927a /samples | |
parent | 56d618ac9b4c82a9a350f21bbc6ec2ec6a95c8b0 (diff) | |
download | pdfium-3859258ebe9e81e1f766b57e7f78c786ae4ed495.tar.xz |
Use JS_ExpandKeywordParams() in app.response()
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1654523002 .
Diffstat (limited to 'samples')
-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 31de532842..2d2c734a91 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; |