Enable security removal in FPDF_Doc_Save

R=jam@chromium.org

Review URL: https://codereview.chromium.org/333753002
diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h
index 87ec7b5..a91870b 100644
--- a/core/include/fpdfapi/fpdf_serial.h
+++ b/core/include/fpdfapi/fpdf_serial.h
@@ -1,7 +1,7 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
- 
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #ifndef _FPDF_SERIAL_
@@ -121,6 +121,8 @@
 
     ~CPDF_Creator();
 
+    void				RemoveSecurity();
+
     FX_BOOL				Create(FX_LPCWSTR filename, FX_DWORD flags = 0);
 
     FX_BOOL				Create(FX_LPCSTR filename, FX_DWORD flags = 0);
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index e5bb1cf..bdbcccd 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -1,7 +1,7 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
- 
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
 #include "../../../include/fpdfapi/fpdf_serial.h"
@@ -2113,6 +2113,13 @@
     m_FileVersion = fileVersion;
     return TRUE;
 }
+void CPDF_Creator::RemoveSecurity()
+{
+    ResetStandardSecurity();
+    m_bSecurityChanged = TRUE;
+    m_pEncryptDict = NULL;
+    m_pCryptoHandler = NULL;
+}
 void CPDF_Creator::ResetStandardSecurity()
 {
     if ((m_bStandardSecurity || m_bNewCrypto) && m_pCryptoHandler) {
diff --git a/fpdfsdk/include/fpdfsave.h b/fpdfsdk/include/fpdfsave.h
index a694560..0909d5a 100644
--- a/fpdfsdk/include/fpdfsave.h
+++ b/fpdfsdk/include/fpdfsave.h
@@ -47,7 +47,8 @@
 #define FPDF_INCREMENTAL		1
 /** @brief No Incremental. */
 #define FPDF_NO_INCREMENTAL		2
-
+/** @brief Remove security. */
+#define FPDF_REMOVE_SECURITY	3
 
 // Function: FPDF_SaveAsCopy
 //			Saves the copy of specified document in custom way.
diff --git a/fpdfsdk/src/fpdfsave.cpp b/fpdfsdk/src/fpdfsave.cpp
index 0c7acc8..6637c78 100644
--- a/fpdfsdk/src/fpdfsave.cpp
+++ b/fpdfsdk/src/fpdfsave.cpp
@@ -60,7 +60,7 @@
 	if (!pDoc) 
 		return 0;
 	
-	if ( flags < 1 || flags > 2 )
+	if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
 	{
 		flags = 0;
 	}
@@ -68,6 +68,11 @@
 	CPDF_Creator FileMaker(pDoc);
 	if(bSetVersion)
 		FileMaker.SetFileVersion(fileVerion);
+	if(flags == FPDF_REMOVE_SECURITY)
+	{
+		flags =  0;
+		FileMaker.RemoveSecurity();
+	}
 	CFX_IFileWrite* pStreamWrite = NULL;
 	FX_BOOL bRet;
 	pStreamWrite = new CFX_IFileWrite;