OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "app.h" | 7 #include "app.h" |
8 | 8 |
| 9 #include <memory> |
| 10 |
9 #include "Document.h" | 11 #include "Document.h" |
10 #include "JS_Context.h" | 12 #include "JS_Context.h" |
11 #include "JS_Define.h" | 13 #include "JS_Define.h" |
12 #include "JS_EventHandler.h" | 14 #include "JS_EventHandler.h" |
13 #include "JS_Object.h" | 15 #include "JS_Object.h" |
14 #include "JS_Runtime.h" | 16 #include "JS_Runtime.h" |
15 #include "JS_Value.h" | 17 #include "JS_Value.h" |
16 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. | 18 #include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment. |
17 #include "fpdfsdk/include/javascript/IJavaScript.h" | 19 #include "fpdfsdk/include/javascript/IJavaScript.h" |
18 #include "resource.h" | 20 #include "resource.h" |
19 #include "third_party/base/nonstd_unique_ptr.h" | |
20 | 21 |
21 BEGIN_JS_STATIC_CONST(CJS_TimerObj) | 22 BEGIN_JS_STATIC_CONST(CJS_TimerObj) |
22 END_JS_STATIC_CONST() | 23 END_JS_STATIC_CONST() |
23 | 24 |
24 BEGIN_JS_STATIC_PROP(CJS_TimerObj) | 25 BEGIN_JS_STATIC_PROP(CJS_TimerObj) |
25 END_JS_STATIC_PROP() | 26 END_JS_STATIC_PROP() |
26 | 27 |
27 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) | 28 BEGIN_JS_STATIC_METHOD(CJS_TimerObj) |
28 END_JS_STATIC_METHOD() | 29 END_JS_STATIC_METHOD() |
29 | 30 |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 // FALLTHROUGH | 763 // FALLTHROUGH |
763 default: | 764 default: |
764 break; | 765 break; |
765 } | 766 } |
766 } | 767 } |
767 | 768 |
768 CJS_Context* pContext = (CJS_Context*)cc; | 769 CJS_Context* pContext = (CJS_Context*)cc; |
769 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); | 770 CPDFDoc_Environment* pApp = pContext->GetReaderApp(); |
770 | 771 |
771 const int MAX_INPUT_BYTES = 2048; | 772 const int MAX_INPUT_BYTES = 2048; |
772 nonstd::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); | 773 std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]); |
773 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); | 774 memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2); |
774 int nLengthBytes = pApp->JS_appResponse( | 775 int nLengthBytes = pApp->JS_appResponse( |
775 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), | 776 swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(), |
776 bPassWord, pBuff.get(), MAX_INPUT_BYTES); | 777 bPassWord, pBuff.get(), MAX_INPUT_BYTES); |
777 if (nLengthBytes <= 0) { | 778 if (nLengthBytes <= 0) { |
778 vRet.SetNull(); | 779 vRet.SetNull(); |
779 return FALSE; | 780 return FALSE; |
780 } | 781 } |
781 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); | 782 nLengthBytes = std::min(nLengthBytes, MAX_INPUT_BYTES); |
782 | 783 |
783 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( | 784 CFX_WideString ret_string = CFX_WideString::FromUTF16LE( |
784 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); | 785 (unsigned short*)pBuff.get(), nLengthBytes / sizeof(unsigned short)); |
785 vRet = ret_string.c_str(); | 786 vRet = ret_string.c_str(); |
786 return TRUE; | 787 return TRUE; |
787 } | 788 } |
788 | 789 |
789 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 790 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
790 return FALSE; | 791 return FALSE; |
791 } | 792 } |
792 | 793 |
793 FX_BOOL app::execDialog(IJS_Context* cc, | 794 FX_BOOL app::execDialog(IJS_Context* cc, |
794 const std::vector<CJS_Value>& params, | 795 const std::vector<CJS_Value>& params, |
795 CJS_Value& vRet, | 796 CJS_Value& vRet, |
796 CFX_WideString& sError) { | 797 CFX_WideString& sError) { |
797 return TRUE; | 798 return TRUE; |
798 } | 799 } |
OLD | NEW |