diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-04-17 21:23:58 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 21:23:58 +0000 |
commit | 35939f83e45b67de4ccc8c3e70e5e00be40326b6 (patch) | |
tree | 9f9745d8f9202be75498690968391b39c04da9a6 /fpdfsdk/cpdfsdk_formfillenvironment.cpp | |
parent | aed62531a9b08deb236cc423dc27dbe0810d6d1a (diff) | |
download | pdfium-35939f83e45b67de4ccc8c3e70e5e00be40326b6.tar.xz |
Avoid some string -> ptr -> string duplicate allocations in FF Environment
Change-Id: I4bd89b64cd77a4e2fe0ffc2dcc415cc8fe34667a
Reviewed-on: https://pdfium-review.googlesource.com/30871
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_formfillenvironment.cpp')
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 262a56e2d1..b3375d4501 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -58,25 +58,25 @@ CPDFSDK_FormFillEnvironment::~CPDFSDK_FormFillEnvironment() { m_pInfo->Release(m_pInfo); } -int CPDFSDK_FormFillEnvironment::JS_appAlert(const wchar_t* Msg, - const wchar_t* Title, +int CPDFSDK_FormFillEnvironment::JS_appAlert(const WideString& Msg, + const WideString& Title, uint32_t Type, uint32_t Icon) { if (!m_pInfo || !m_pInfo->m_pJsPlatform || !m_pInfo->m_pJsPlatform->app_alert) { return -1; } - ByteString bsMsg = WideString(Msg).UTF16LE_Encode(); - ByteString bsTitle = WideString(Title).UTF16LE_Encode(); + ByteString bsMsg = Msg.UTF16LE_Encode(); + ByteString bsTitle = Title.UTF16LE_Encode(); return m_pInfo->m_pJsPlatform->app_alert( m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsMsg), AsFPDFWideString(&bsTitle), Type, Icon); } -int CPDFSDK_FormFillEnvironment::JS_appResponse(const wchar_t* Question, - const wchar_t* Title, - const wchar_t* Default, - const wchar_t* cLabel, +int CPDFSDK_FormFillEnvironment::JS_appResponse(const WideString& Question, + const WideString& Title, + const WideString& Default, + const WideString& Label, FPDF_BOOL bPassword, void* response, int length) { @@ -84,10 +84,10 @@ int CPDFSDK_FormFillEnvironment::JS_appResponse(const wchar_t* Question, !m_pInfo->m_pJsPlatform->app_response) { return -1; } - ByteString bsQuestion = WideString(Question).UTF16LE_Encode(); - ByteString bsTitle = WideString(Title).UTF16LE_Encode(); - ByteString bsDefault = WideString(Default).UTF16LE_Encode(); - ByteString bsLabel = WideString(cLabel).UTF16LE_Encode(); + ByteString bsQuestion = Question.UTF16LE_Encode(); + ByteString bsTitle = Title.UTF16LE_Encode(); + ByteString bsDefault = Default.UTF16LE_Encode(); + ByteString bsLabel = Label.UTF16LE_Encode(); return m_pInfo->m_pJsPlatform->app_response( m_pInfo->m_pJsPlatform, AsFPDFWideString(&bsQuestion), AsFPDFWideString(&bsTitle), AsFPDFWideString(&bsDefault), @@ -144,34 +144,33 @@ WideString CPDFSDK_FormFillEnvironment::JS_docGetFilePath() { void CPDFSDK_FormFillEnvironment::JS_docSubmitForm(void* formData, int length, - const wchar_t* URL) { + const WideString& URL) { if (!m_pInfo || !m_pInfo->m_pJsPlatform || !m_pInfo->m_pJsPlatform->Doc_submitForm) { return; } - ByteString bsDestination = WideString(URL).UTF16LE_Encode(); + ByteString bsUrl = URL.UTF16LE_Encode(); m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, - length, - AsFPDFWideString(&bsDestination)); + length, AsFPDFWideString(&bsUrl)); } void CPDFSDK_FormFillEnvironment::JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI, - const wchar_t* To, - const wchar_t* Subject, - const wchar_t* CC, - const wchar_t* BCC, - const wchar_t* Msg) { + const WideString& To, + const WideString& Subject, + const WideString& CC, + const WideString& BCC, + const WideString& Msg) { if (!m_pInfo || !m_pInfo->m_pJsPlatform || !m_pInfo->m_pJsPlatform->Doc_mail) { return; } - ByteString bsTo = WideString(To).UTF16LE_Encode(); - ByteString bsSubject = WideString(Subject).UTF16LE_Encode(); - ByteString bsCC = WideString(CC).UTF16LE_Encode(); - ByteString bsBcc = WideString(BCC).UTF16LE_Encode(); - ByteString bsMsg = WideString(Msg).UTF16LE_Encode(); + ByteString bsTo = To.UTF16LE_Encode(); + ByteString bsSubject = Subject.UTF16LE_Encode(); + ByteString bsCC = CC.UTF16LE_Encode(); + ByteString bsBcc = BCC.UTF16LE_Encode(); + ByteString bsMsg = Msg.UTF16LE_Encode(); m_pInfo->m_pJsPlatform->Doc_mail( m_pInfo->m_pJsPlatform, mailData, length, bUI, AsFPDFWideString(&bsTo), AsFPDFWideString(&bsSubject), AsFPDFWideString(&bsCC), @@ -435,11 +434,11 @@ FPDF_FILEHANDLER* CPDFSDK_FormFillEnvironment::OpenFile(int fileType, } RetainPtr<IFX_SeekableReadStream> CPDFSDK_FormFillEnvironment::DownloadFromURL( - const wchar_t* url) { + const WideString& url) { if (!m_pInfo || !m_pInfo->FFI_DownloadFromURL) return nullptr; - ByteString bstrURL = WideString(url).UTF16LE_Encode(); + ByteString bstrURL = url.UTF16LE_Encode(); FPDF_LPFILEHANDLER fileHandler = m_pInfo->FFI_DownloadFromURL(m_pInfo, AsFPDFWideString(&bstrURL)); @@ -447,19 +446,19 @@ RetainPtr<IFX_SeekableReadStream> CPDFSDK_FormFillEnvironment::DownloadFromURL( } WideString CPDFSDK_FormFillEnvironment::PostRequestURL( - const wchar_t* wsURL, - const wchar_t* wsData, - const wchar_t* wsContentType, - const wchar_t* wsEncode, - const wchar_t* wsHeader) { + const WideString& wsURL, + const WideString& wsData, + const WideString& wsContentType, + const WideString& wsEncode, + const WideString& wsHeader) { if (!m_pInfo || !m_pInfo->FFI_PostRequestURL) return L""; - ByteString bsURL = WideString(wsURL).UTF16LE_Encode(); - ByteString bsData = WideString(wsData).UTF16LE_Encode(); - ByteString bsContentType = WideString(wsContentType).UTF16LE_Encode(); - ByteString bsEncode = WideString(wsEncode).UTF16LE_Encode(); - ByteString bsHeader = WideString(wsHeader).UTF16LE_Encode(); + ByteString bsURL = wsURL.UTF16LE_Encode(); + ByteString bsData = wsData.UTF16LE_Encode(); + ByteString bsContentType = wsContentType.UTF16LE_Encode(); + ByteString bsEncode = wsEncode.UTF16LE_Encode(); + ByteString bsHeader = wsHeader.UTF16LE_Encode(); FPDF_BSTR response; FPDF_BStr_Init(&response); @@ -476,15 +475,16 @@ WideString CPDFSDK_FormFillEnvironment::PostRequestURL( return wsRet; } -FPDF_BOOL CPDFSDK_FormFillEnvironment::PutRequestURL(const wchar_t* wsURL, - const wchar_t* wsData, - const wchar_t* wsEncode) { +FPDF_BOOL CPDFSDK_FormFillEnvironment::PutRequestURL( + const WideString& wsURL, + const WideString& wsData, + const WideString& wsEncode) { if (!m_pInfo || !m_pInfo->FFI_PutRequestURL) return false; - ByteString bsURL = WideString(wsURL).UTF16LE_Encode(); - ByteString bsData = WideString(wsData).UTF16LE_Encode(); - ByteString bsEncode = WideString(wsEncode).UTF16LE_Encode(); + ByteString bsURL = wsURL.UTF16LE_Encode(); + ByteString bsData = wsData.UTF16LE_Encode(); + ByteString bsEncode = wsEncode.UTF16LE_Encode(); return m_pInfo->FFI_PutRequestURL(m_pInfo, AsFPDFWideString(&bsURL), AsFPDFWideString(&bsData), |