summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_mgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-06-22 15:13:36 -0700
committerLei Zhang <thestig@chromium.org>2015-06-22 15:13:36 -0700
commit5ab3fc60fc44aca144607416d18e7efdc1203fe6 (patch)
treea87fb76fff5cbb9865cddb6b593afc347b02c381 /fpdfsdk/src/fsdk_mgr.cpp
parent06864f7992891d555f9f86efcf4feb06a2856b36 (diff)
downloadpdfium-5ab3fc60fc44aca144607416d18e7efdc1203fe6.tar.xz
Cleanup: Remove more checks for new returning NULL.
R=jam@chromium.org Review URL: https://codereview.chromium.org/1198903002.
Diffstat (limited to 'fpdfsdk/src/fsdk_mgr.cpp')
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index ad27aeb92f..527538cd09 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -5,6 +5,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "../../public/fpdf_ext.h"
+#include "../../third_party/base/nonstd_unique_ptr.h"
#include "../include/fsdk_define.h"
#include "../include/fsdk_mgr.h"
#include "../include/formfiller/FFL_FormFiller.h"
@@ -254,6 +255,55 @@ CPDFDoc_Environment::~CPDFDoc_Environment()
m_pActionHandler = NULL;
}
+CFX_WideString CPDFDoc_Environment::JS_fieldBrowse()
+{
+ if (!m_pInfo ||
+ !m_pInfo->m_pJsPlatform ||
+ !m_pInfo->m_pJsPlatform->Field_browse) {
+ return L"";
+ }
+
+ const int nRequiredLen = m_pInfo->m_pJsPlatform->Field_browse(
+ m_pInfo->m_pJsPlatform, nullptr, 0);
+ if (nRequiredLen <= 0)
+ return L"";
+
+ nonstd::unique_ptr<char[]> pBuff(new char[nRequiredLen]);
+ memset(pBuff.get(), 0, nRequiredLen);
+ const int nActualLen = m_pInfo->m_pJsPlatform->Field_browse(
+ m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen);
+ if (nActualLen <= 0 || nActualLen > nRequiredLen)
+ return L"";
+
+ CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen);
+ CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
+ return wsRet;
+}
+
+CFX_WideString CPDFDoc_Environment::JS_docGetFilePath()
+{
+ if (!m_pInfo ||
+ !m_pInfo->m_pJsPlatform ||
+ !m_pInfo->m_pJsPlatform->Doc_getFilePath) {
+ return L"";
+ }
+
+ const int nRequiredLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
+ m_pInfo->m_pJsPlatform, nullptr, 0);
+ if (nRequiredLen <= 0)
+ return L"";
+
+ nonstd::unique_ptr<char[]> pBuff(new char[nRequiredLen]);
+ memset(pBuff.get(), 0, nRequiredLen);
+ const int nActualLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(
+ m_pInfo->m_pJsPlatform, pBuff.get(), nRequiredLen);
+ if (nActualLen <= 0 || nActualLen > nRequiredLen)
+ return L"";
+
+ CFX_ByteString bsRet = CFX_ByteString(pBuff.get(), nActualLen);
+ CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet);
+ return wsRet;
+}
IFXJS_Runtime* CPDFDoc_Environment::GetJSRuntime()
{