summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/PublicMethods.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-08 13:03:16 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-08 13:03:16 -0700
commite1e7bd037538c6b31537fc0e3e01c508dab68132 (patch)
tree96ef5d14b8c889ab3a59a259f6ef585cef0e57eb /fpdfsdk/javascript/PublicMethods.cpp
parente3ff76b11ac6fcd0d0196ef83946d2321ab8e9bf (diff)
downloadpdfium-e1e7bd037538c6b31537fc0e3e01c508dab68132.tar.xz
Remove MsgBox()/Alert() from CJS_EmbedObj.
They're only related to the |app| object, not all embed's. Alert() itself unused. Review-Url: https://codereview.chromium.org/2224073002
Diffstat (limited to 'fpdfsdk/javascript/PublicMethods.cpp')
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 6af59bd278..aa0efb1fa6 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -77,6 +77,12 @@ CFX_WideString StrTrim(const CFX_WideString& pStr) {
return result;
}
+void AlertIfPossible(CJS_Context* pContext, const FX_WCHAR* swMsg) {
+ CPDFDoc_Environment* pApp = pContext->GetReaderApp();
+ if (pApp)
+ pApp->JS_appAlert(swMsg, nullptr, 0, 3);
+}
+
} // namespace
bool CJS_PublicMethods::IsNumber(const CFX_WideString& str) {
@@ -913,7 +919,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Keystroke(
if (!IsNumber(swTemp.c_str())) {
pEvent->Rc() = FALSE;
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
- Alert(pContext, sError.c_str());
+ AlertIfPossible(pContext, sError.c_str());
}
return TRUE; // it happens after the last keystroke and before validating,
}
@@ -1122,7 +1128,7 @@ FX_BOOL CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
return FALSE;
}
@@ -1214,7 +1220,7 @@ FX_BOOL CJS_PublicMethods::AFDate_KeystrokeEx(
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1432,7 +1438,7 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (iIndexMask != wstrMask.GetLength() ||
(iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
- Alert(
+ AlertIfPossible(
pContext,
JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
pEvent->Rc() = FALSE;
@@ -1449,23 +1455,26 @@ FX_BOOL CJS_PublicMethods::AFSpecial_KeystrokeEx(
FX_STRSIZE combined_len = valEvent.GetLength() + wChange.GetLength() +
pEvent->SelStart() - pEvent->SelEnd();
if (combined_len > wstrMask.GetLength()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
for (FX_STRSIZE i = 0; i < wChange.GetLength(); ++i) {
if (iIndexMask >= wstrMask.GetLength()) {
- Alert(pContext,
- JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
+ AlertIfPossible(
+ pContext,
+ JSGetStringFromID(pContext, IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = FALSE;
return TRUE;
}
@@ -1584,7 +1593,7 @@ FX_BOOL CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
CFX_WideString swMsg;
swMsg.Format(JSGetStringFromID(pContext, IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
- Alert((CJS_Context*)cc, swMsg.c_str());
+ AlertIfPossible((CJS_Context*)cc, swMsg.c_str());
return FALSE;
}
@@ -1768,7 +1777,7 @@ FX_BOOL CJS_PublicMethods::AFRange_Validate(
}
if (!swMsg.IsEmpty()) {
- Alert(pContext, swMsg.c_str());
+ AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = FALSE;
}
return TRUE;