Fix the multiple form submission bug. (Bug 2098417).

Change-Id: I4eb188f6b4826f394a08c72c71f920cc212b2653
diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
index 71d5048..c567c66 100644
--- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
+++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp
@@ -467,16 +467,21 @@
 }
 
 void FrameLoaderClientAndroid::dispatchDecidePolicyForNewWindowAction(FramePolicyFunction func,
-                                const NavigationAction&, const ResourceRequest& request,
+                                const NavigationAction& action, const ResourceRequest& request,
                                 PassRefPtr<FormState> formState, const String& frameName) {
     ASSERT(m_frame);
     ASSERT(func);
     if (!func)
         return;
+
     if (request.isNull()) {
         (m_frame->loader()->*func)(PolicyIgnore);
         return;
     }
+
+    if (action.type() == NavigationTypeFormSubmitted || action.type() == NavigationTypeFormResubmitted)
+        m_frame->loader()->resetMultipleFormSubmissionProtection();
+
     // If we get to this point it means that a link has a target that was not
     // found by the frame tree. Instead of creating a new frame, return the
     // current frame in dispatchCreatePage.
@@ -505,6 +510,12 @@
         (m_frame->loader()->*func)(PolicyIgnore);
         return;
     }
+
+    // Reset multiple form submission protection. If this is a resubmission, we check with the
+    // user and reset the protection if they choose to resubmit the form (see WebCoreFrameBridge.cpp)
+    if (action.type() == NavigationTypeFormSubmitted)
+        m_frame->loader()->resetMultipleFormSubmissionProtection();
+
     if (action.type() == NavigationTypeFormResubmitted) {
         m_webFrame->decidePolicyForFormResubmission(func);
         return;
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index bb59b73..6c97acc 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -738,6 +738,10 @@
     PolicyFunctionWrapper* pFunc = (PolicyFunctionWrapper*)func;
     LOG_ASSERT(pFunc, "nativeCallPolicyFunction must take a valid function pointer!");
 
+    // If we are resending the form then we should reset the multiple submission protection.
+    if (decision == WebCore::PolicyUse)
+        pFrame->loader()->resetMultipleFormSubmissionProtection();
+
     (pFrame->loader()->*(pFunc->func))((WebCore::PolicyAction)decision);
 }