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 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 CJS_Value& vRet, | 560 CJS_Value& vRet, |
561 CFX_WideString& sError) { | 561 CFX_WideString& sError) { |
562 // Not supported. | 562 // Not supported. |
563 return TRUE; | 563 return TRUE; |
564 } | 564 } |
565 | 565 |
566 FX_BOOL app::mailMsg(IJS_Context* cc, | 566 FX_BOOL app::mailMsg(IJS_Context* cc, |
567 const std::vector<CJS_Value>& params, | 567 const std::vector<CJS_Value>& params, |
568 CJS_Value& vRet, | 568 CJS_Value& vRet, |
569 CFX_WideString& sError) { | 569 CFX_WideString& sError) { |
570 if (params.size() < 1) | |
571 return FALSE; | |
572 | |
573 FX_BOOL bUI = TRUE; | |
574 CFX_WideString cTo = L""; | |
575 CFX_WideString cCc = L""; | |
576 CFX_WideString cBcc = L""; | |
577 CFX_WideString cSubject = L""; | |
578 CFX_WideString cMsg = L""; | |
579 | |
580 CJS_Context* pContext = static_cast<CJS_Context*>(cc); | 570 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
581 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 571 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
582 v8::Isolate* isolate = pRuntime->GetIsolate(); | 572 std::vector<CJS_Value> newParams = |
| 573 JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", |
| 574 L"cBcc", L"cSubject", L"cMsg"); |
583 | 575 |
584 if (params[0].GetType() == CJS_Value::VT_object) { | 576 if (newParams[0].GetType() == CJS_Value::VT_unknown) { |
585 v8::Local<v8::Object> pObj = params[0].ToV8Object(); | 577 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 578 return FALSE; |
| 579 } |
| 580 bool bUI = newParams[0].ToBool(); |
586 | 581 |
587 v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI"); | 582 CFX_WideString cTo; |
588 bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool(); | 583 if (newParams[1].GetType() != CJS_Value::VT_unknown) { |
589 | 584 cTo = newParams[1].ToCFXWideString(); |
590 pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo"); | |
591 cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
592 | |
593 pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc"); | |
594 cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
595 | |
596 pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc"); | |
597 cBcc = | |
598 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
599 | |
600 pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject"); | |
601 cSubject = | |
602 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
603 | |
604 pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg"); | |
605 cMsg = | |
606 CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString(); | |
607 } else { | 585 } else { |
608 if (params.size() < 2) | 586 if (!bUI) { |
| 587 // cTo parameter required when UI not invoked. |
| 588 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
609 return FALSE; | 589 return FALSE; |
610 | 590 } |
611 bUI = params[0].ToBool(); | |
612 cTo = params[1].ToCFXWideString(); | |
613 | |
614 if (params.size() >= 3) | |
615 cCc = params[2].ToCFXWideString(); | |
616 if (params.size() >= 4) | |
617 cBcc = params[3].ToCFXWideString(); | |
618 if (params.size() >= 5) | |
619 cSubject = params[4].ToCFXWideString(); | |
620 if (params.size() >= 6) | |
621 cMsg = params[5].ToCFXWideString(); | |
622 } | 591 } |
623 | 592 |
| 593 CFX_WideString cCc; |
| 594 if (newParams[2].GetType() != CJS_Value::VT_unknown) |
| 595 cCc = newParams[2].ToCFXWideString(); |
| 596 |
| 597 CFX_WideString cBcc; |
| 598 if (newParams[3].GetType() != CJS_Value::VT_unknown) |
| 599 cBcc = newParams[3].ToCFXWideString(); |
| 600 |
| 601 CFX_WideString cSubject; |
| 602 if (newParams[4].GetType() != CJS_Value::VT_unknown) |
| 603 cSubject = newParams[4].ToCFXWideString(); |
| 604 |
| 605 CFX_WideString cMsg; |
| 606 if (newParams[5].GetType() != CJS_Value::VT_unknown) |
| 607 cMsg = newParams[5].ToCFXWideString(); |
| 608 |
624 pRuntime->BeginBlock(); | 609 pRuntime->BeginBlock(); |
625 pContext->GetReaderApp()->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), | 610 pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), |
626 cSubject.c_str(), cCc.c_str(), | 611 cSubject.c_str(), cCc.c_str(), |
627 cBcc.c_str(), cMsg.c_str()); | 612 cBcc.c_str(), cMsg.c_str()); |
628 pRuntime->EndBlock(); | 613 pRuntime->EndBlock(); |
629 | 614 return TRUE; |
630 return FALSE; | |
631 } | 615 } |
632 | 616 |
633 FX_BOOL app::launchURL(IJS_Context* cc, | 617 FX_BOOL app::launchURL(IJS_Context* cc, |
634 const std::vector<CJS_Value>& params, | 618 const std::vector<CJS_Value>& params, |
635 CJS_Value& vRet, | 619 CJS_Value& vRet, |
636 CFX_WideString& sError) { | 620 CFX_WideString& sError) { |
637 // Unsafe, not supported. | 621 // Unsafe, not supported. |
638 return TRUE; | 622 return TRUE; |
639 } | 623 } |
640 | 624 |
641 FX_BOOL app::runtimeHighlight(IJS_Context* cc, | 625 FX_BOOL app::runtimeHighlight(IJS_Context* cc, |
642 CJS_PropValue& vp, | 626 CJS_PropValue& vp, |
643 CFX_WideString& sError) { | 627 CFX_WideString& sError) { |
644 if (vp.IsSetting()) { | 628 if (vp.IsSetting()) { |
645 vp >> m_bRuntimeHighLight; | 629 vp >> m_bRuntimeHighLight; |
646 } else { | 630 } else { |
647 vp << m_bRuntimeHighLight; | 631 vp << m_bRuntimeHighLight; |
648 } | 632 } |
649 | |
650 return TRUE; | 633 return TRUE; |
651 } | 634 } |
652 | 635 |
653 FX_BOOL app::fullscreen(IJS_Context* cc, | 636 FX_BOOL app::fullscreen(IJS_Context* cc, |
654 CJS_PropValue& vp, | 637 CJS_PropValue& vp, |
655 CFX_WideString& sError) { | 638 CFX_WideString& sError) { |
656 return FALSE; | 639 return FALSE; |
657 } | 640 } |
658 | 641 |
659 FX_BOOL app::popUpMenu(IJS_Context* cc, | 642 FX_BOOL app::popUpMenu(IJS_Context* cc, |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { | 767 FX_BOOL app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) { |
785 return FALSE; | 768 return FALSE; |
786 } | 769 } |
787 | 770 |
788 FX_BOOL app::execDialog(IJS_Context* cc, | 771 FX_BOOL app::execDialog(IJS_Context* cc, |
789 const std::vector<CJS_Value>& params, | 772 const std::vector<CJS_Value>& params, |
790 CJS_Value& vRet, | 773 CJS_Value& vRet, |
791 CFX_WideString& sError) { | 774 CFX_WideString& sError) { |
792 return TRUE; | 775 return TRUE; |
793 } | 776 } |
OLD | NEW |