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 "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 4906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4917 if (!pDoc) | 4917 if (!pDoc) |
4918 return; | 4918 return; |
4919 | 4919 |
4920 IXFA_AppProvider* pAppProvider = pDoc->GetNotify()->GetAppProvider(); | 4920 IXFA_AppProvider* pAppProvider = pDoc->GetNotify()->GetAppProvider(); |
4921 if (!pAppProvider) | 4921 if (!pAppProvider) |
4922 return; | 4922 return; |
4923 | 4923 |
4924 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); | 4924 std::unique_ptr<CFXJSE_Value> argOne = GetSimpleValue(pThis, args, 0); |
4925 CFX_ByteString urlString; | 4925 CFX_ByteString urlString; |
4926 ValueToUTF8String(argOne.get(), urlString); | 4926 ValueToUTF8String(argOne.get(), urlString); |
4927 IFX_SeekableReadStream* pFile = pAppProvider->DownloadURL( | 4927 CFX_RetainPtr<IFX_SeekableReadStream> pFile = pAppProvider->DownloadURL( |
4928 CFX_WideString::FromUTF8(urlString.AsStringC())); | 4928 CFX_WideString::FromUTF8(urlString.AsStringC())); |
4929 if (!pFile) | 4929 if (!pFile) |
4930 return; | 4930 return; |
4931 | 4931 |
4932 int32_t size = pFile->GetSize(); | 4932 int32_t size = pFile->GetSize(); |
4933 std::unique_ptr<uint8_t> pData(FX_Alloc(uint8_t, size)); | 4933 std::unique_ptr<uint8_t> pData(FX_Alloc(uint8_t, size)); |
4934 pFile->ReadBlock(pData.get(), size); | 4934 pFile->ReadBlock(pData.get(), size); |
4935 args.GetReturnValue()->SetString(CFX_ByteStringC(pData.get(), size)); | 4935 args.GetReturnValue()->SetString(CFX_ByteStringC(pData.get(), size)); |
4936 pFile->Release(); | |
4937 } | 4936 } |
4938 | 4937 |
4939 // static | 4938 // static |
4940 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, | 4939 void CXFA_FM2JSContext::Post(CFXJSE_Value* pThis, |
4941 const CFX_ByteStringC& szFuncName, | 4940 const CFX_ByteStringC& szFuncName, |
4942 CFXJSE_Arguments& args) { | 4941 CFXJSE_Arguments& args) { |
4943 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); | 4942 CXFA_FM2JSContext* pContext = ToJSContext(pThis, nullptr); |
4944 int32_t argc = args.GetLength(); | 4943 int32_t argc = args.GetLength(); |
4945 if (argc < 2 || argc > 5) { | 4944 if (argc < 2 || argc > 5) { |
4946 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); | 4945 pContext->ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"Post"); |
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6516 CFX_WideString wsFormat; | 6515 CFX_WideString wsFormat; |
6517 pAppProvider->LoadString(iStringID, wsFormat); | 6516 pAppProvider->LoadString(iStringID, wsFormat); |
6518 CFX_WideString wsMessage; | 6517 CFX_WideString wsMessage; |
6519 va_list arg_ptr; | 6518 va_list arg_ptr; |
6520 va_start(arg_ptr, iStringID); | 6519 va_start(arg_ptr, iStringID); |
6521 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 6520 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
6522 va_end(arg_ptr); | 6521 va_end(arg_ptr); |
6523 FXJSE_ThrowMessage( | 6522 FXJSE_ThrowMessage( |
6524 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 6523 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
6525 } | 6524 } |
OLD | NEW |