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> | 9 #include <memory> |
10 | 10 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 CJS_Value& vRet, | 526 CJS_Value& vRet, |
527 CFX_WideString& sError) { | 527 CFX_WideString& sError) { |
528 // Not supported. | 528 // Not supported. |
529 return TRUE; | 529 return TRUE; |
530 } | 530 } |
531 | 531 |
532 FX_BOOL app::mailMsg(IJS_Context* cc, | 532 FX_BOOL app::mailMsg(IJS_Context* cc, |
533 const std::vector<CJS_Value>& params, | 533 const std::vector<CJS_Value>& params, |
534 CJS_Value& vRet, | 534 CJS_Value& vRet, |
535 CFX_WideString& sError) { | 535 CFX_WideString& sError) { |
536 if (params.size() < 1) | |
537 return FALSE; | |
538 | |
539 FX_BOOL bUI = TRUE; | |
540 CFX_WideString cTo = L""; | |
541 CFX_WideString cCc = L""; | |
542 CFX_WideString cBcc = L""; | |
543 CFX_WideString cSubject = L""; | |
544 CFX_WideString cMsg = L""; | |
545 | |
546 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 536 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
547 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 537 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
548 v8::Isolate* isolate = pRuntime->GetIsolate(); | 538 std::vector<CJS_Value> newParams = |
| 539 JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", |
| 540 L"cBcc", L"cSubject", L"cMsg"); |
549 | 541 |
550 if (params[0].GetType() == CJS_Value::VT_object) { | 542 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
551 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 543 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 544 return FALSE; |
| 545 } |
| 546 bool bUI = newParams[0].ToBool(); |
552 | 547 |
553 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); | 548 CFX_WideString cTo; |
554 bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 549 if (newParams[1].GetType() != CJS_Value::VT_unknown) { |
555 | 550 cTo = newParams[1].ToCFXWideString(); |
556 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); | |
557 cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
558 | |
559 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); | |
560 cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
561 | |
562 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); | |
563 cBcc = | |
564 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
565 | |
566 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); | |
567 cSubject = | |
568 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
569 | |
570 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); | |
571 cMsg = | |
572 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
573 } else { | 551 } else { |
574 if (params.size() < 2) | 552 if (!bUI) { |
| 553 // cTo parameter required when UI not invoked. |
| 554 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
575 return FALSE; | 555 return FALSE; |
576 | 556 } |
577 bUI = params[0].ToBool(); | |
578 cTo = params[1].ToCFXWideString(); | |
579 | |
580 if (params.size() >= 3) | |
581 cCc = params[2].ToCFXWideString(); | |
582 if (params.size() >= 4) | |
583 cBcc = params[3].ToCFXWideString(); | |
584 if (params.size() >= 5) | |
585 cSubject = params[4].ToCFXWideString(); | |
586 if (params.size() >= 6) | |
587 cMsg = params[5].ToCFXWideString(); | |
588 } | 557 } |
589 | 558 |
| 559 CFX_WideString cCc; |
| 560 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 561 cCc = newParams[2].ToCFXWideString(); |
| 562 |
| 563 CFX_WideString cBcc; |
| 564 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 565 cBcc = newParams[3].ToCFXWideString(); |
| 566 |
| 567 CFX_WideString cSubject; |
| 568 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
| 569 cSubject = newParams[4].ToCFXWideString(); |
| 570 |
| 571 CFX_WideString cMsg; |
| 572 if (newParams[5].GetType() != CJS_Value::VT_unknown) |
| 573 cMsg = newParams[5].ToCFXWideString(); |
| 574 |
590 pRuntime->BeginBlock(); | 575 pRuntime->BeginBlock(); |
591 pContext->GetReaderApp()->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), | 576 pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), |
592 cSubject.c_str(), cCc.c_str(), | 577 cSubject.c_str(), cCc.c_str(), |
593 cBcc.c_str(), cMsg.c_str()); | 578 cBcc.c_str(), cMsg.c_str()); |
594 pRuntime->EndBlock(); | 579 pRuntime->EndBlock(); |
595 | 580 return TRUE; |
596 return FALSE; | |
597 } | 581 } |
598 | 582 |
599 FX_BOOL app::launchURL(IJS_Context* cc, | 583 FX_BOOL app::launchURL(IJS_Context* cc, |
600 const std::vector<CJS_Value>& params, | 584 const std::vector<CJS_Value>& params, |
601 CJS_Value& vRet, | 585 CJS_Value& vRet, |
602 CFX_WideString& sError) { | 586 CFX_WideString& sError) { |
603 // Unsafe, not supported. | 587 // Unsafe, not supported. |
604 return TRUE; | 588 return TRUE; |
605 } | 589 } |
606 | 590 |
607 FX_BOOL app::runtimeHighlight(IJS_Context* cc, | 591 FX_BOOL app::runtimeHighlight(IJS_Context* cc, |
608 CJS_PropValue& vp, | 592 CJS_PropValue& vp, |
609 CFX_WideString& sError) { | 593 CFX_WideString& sError) { |
610 if (vp.IsSetting()) { | 594 if (vp.IsSetting()) { |
611 vp >> m_bRuntimeHighLight; | 595 vp >> m_bRuntimeHighLight; |
612 } else { | 596 } else { |
613 vp << m_bRuntimeHighLight; | 597 vp << m_bRuntimeHighLight; |
614 } | 598 } |
615 | |
616 return TRUE; | 599 return TRUE; |
617 } | 600 } |
618 | 601 |
619 FX_BOOL app::fullscreen(IJS_Context* cc, | 602 FX_BOOL app::fullscreen(IJS_Context* cc, |
620 CJS_PropValue& vp, | 603 CJS_PropValue& vp, |
621 CFX_WideString& sError) { | 604 CFX_WideString& sError) { |
622 return FALSE; | 605 return FALSE; |
623 } | 606 } |
624 | 607 |
625 FX_BOOL app::popUpMenu(IJS_Context* cc, | 608 FX_BOOL app::popUpMenu(IJS_Context* cc, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 733 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
751 return FALSE; | 734 return FALSE; |
752 } | 735 } |
753 | 736 |
754 FX_BOOL app::execDialog(IJS_Context* cc, | 737 FX_BOOL app::execDialog(IJS_Context* cc, |
755 const std::vector<CJS_Value>& params, | 738 const std::vector<CJS_Value>& params, |
756 CJS_Value& vRet, | 739 CJS_Value& vRet, |
757 CFX_WideString& sError) { | 740 CFX_WideString& sError) { |
758 return TRUE; | 741 return TRUE; |
759 } | 742 } |
OLD | NEW |