2010-07-16  Nate Chapin  <japhet@chromium.org>

        Reviewed by Darin Fisher.

        Regression in r63100: Don't clear m_loadType in
        FrameLoader::handledOnloadEvents, as it is used
        to make some decisions after the load has actually
        completed.

        Tickling this bug requires manipulation
        via the API (layout tests don't appear to traverse
        the correct codepath), so no layout test.

        https://bugs.webkit.org/show_bug.cgi?id=42298

        * loader/FrameLoader.cpp:
        (WebCore::FrameLoader::handledOnloadEvents): Don't reset m_loadType.
        (WebCore::FrameLoader::addExtraFieldsToRequest): Set subresource cache
           policy in one place and don't depend on m_loadType.
2010-07-16  Nate Chapin  <japhet@chromium.org>

        Reviewed by Darin Fisher.

        Uncomment an assert that broke due to r63100.

        https://bugs.webkit.org/show_bug.cgi?id=42298

        * tests/testwebview.c:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63528 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp
index d8aca14..51a0695 100644
--- a/WebCore/loader/FrameLoader.cpp
+++ b/WebCore/loader/FrameLoader.cpp
@@ -2609,8 +2609,6 @@
 {
     m_client->dispatchDidHandleOnloadEvents();
 
-    m_loadType = FrameLoadTypeStandard;
-
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     if (documentLoader())
         documentLoader()->applicationCacheHost()->stopDeferringEvents();
@@ -2690,7 +2688,14 @@
     // 2. Delegates that modify the cache policy using willSendRequest: should
     //    not affect any other resources. Such changes need to be done
     //    per request.
-    if (loadType == FrameLoadTypeReload) {
+    if (!mainResource) {
+        if (request.isConditional())
+            request.setCachePolicy(ReloadIgnoringCacheData);
+        else if (documentLoader()->isLoadingInAPISense())
+            request.setCachePolicy(documentLoader()->originalRequest().cachePolicy());
+        else
+            request.setCachePolicy(UseProtocolCachePolicy);
+    } else if (loadType == FrameLoadTypeReload) {
         request.setCachePolicy(ReloadIgnoringCacheData);
         request.setHTTPHeaderField("Cache-Control", "max-age=0");
     } else if (loadType == FrameLoadTypeReloadFromOrigin) {
@@ -2701,8 +2706,6 @@
         request.setCachePolicy(ReloadIgnoringCacheData);
     else if (isBackForwardLoadType(loadType) && m_stateMachine.committedFirstRealDocumentLoad() && !request.url().protocolIs("https"))
         request.setCachePolicy(ReturnCacheDataElseLoad);
-    else if (!mainResource && documentLoader()->isLoadingInAPISense())
-        request.setCachePolicy(documentLoader()->originalRequest().cachePolicy());
     
     if (mainResource)
         request.setHTTPAccept(defaultAcceptHeader);