| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // If the document specified an application cache manifest, it violates the
author's intent if we store it in the memory cache | 339 // If the document specified an application cache manifest, it violates the
author's intent if we store it in the memory cache |
| 340 // and deny the appcache the chance to intercept it in the future, so remove
from the memory cache. | 340 // and deny the appcache the chance to intercept it in the future, so remove
from the memory cache. |
| 341 if (m_frame) { | 341 if (m_frame) { |
| 342 if (m_mainResource && m_frame->document()->hasManifest()) | 342 if (m_mainResource && m_frame->document()->hasManifest()) |
| 343 memoryCache()->remove(m_mainResource.get()); | 343 memoryCache()->remove(m_mainResource.get()); |
| 344 } | 344 } |
| 345 m_applicationCacheHost->finishedLoadingMainResource(); | 345 m_applicationCacheHost->finishedLoadingMainResource(); |
| 346 clearMainResourceHandle(); | 346 clearMainResourceHandle(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool DocumentLoader::isPostOrRedirectAfterPost(const ResourceRequest& newRequest
, const ResourceResponse& redirectResponse) | 349 bool DocumentLoader::isRedirectAfterPost(const ResourceRequest& newRequest, cons
t ResourceResponse& redirectResponse) |
| 350 { | 350 { |
| 351 if (newRequest.httpMethod() == "POST") | |
| 352 return true; | |
| 353 | |
| 354 int status = redirectResponse.httpStatusCode(); | 351 int status = redirectResponse.httpStatusCode(); |
| 355 if (((status >= 301 && status <= 303) || status == 307) | 352 if (((status >= 301 && status <= 303) || status == 307) |
| 356 && m_originalRequest.httpMethod() == "POST") | 353 && m_originalRequest.httpMethod() == "POST") |
| 357 return true; | 354 return true; |
| 358 | 355 |
| 359 return false; | 356 return false; |
| 360 } | 357 } |
| 361 | 358 |
| 362 void DocumentLoader::handleSubstituteDataLoadNow(DocumentLoaderTimer*) | 359 void DocumentLoader::handleSubstituteDataLoadNow(DocumentLoaderTimer*) |
| 363 { | 360 { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 } | 442 } |
| 446 | 443 |
| 447 // Update cookie policy base URL as URL changes, except for subframes, which
use the | 444 // Update cookie policy base URL as URL changes, except for subframes, which
use the |
| 448 // URL of the main frame which doesn't change when we redirect. | 445 // URL of the main frame which doesn't change when we redirect. |
| 449 if (frameLoader()->isLoadingMainFrame()) | 446 if (frameLoader()->isLoadingMainFrame()) |
| 450 newRequest.setFirstPartyForCookies(newRequest.url()); | 447 newRequest.setFirstPartyForCookies(newRequest.url()); |
| 451 | 448 |
| 452 // If we're fielding a redirect in response to a POST, force a load from ori
gin, since | 449 // If we're fielding a redirect in response to a POST, force a load from ori
gin, since |
| 453 // this is a common site technique to return to a page viewing some data tha
t the POST | 450 // this is a common site technique to return to a page viewing some data tha
t the POST |
| 454 // just modified. | 451 // just modified. |
| 455 // Also, POST requests always load from origin, but this does not affect sub
resources. | 452 if (newRequest.cachePolicy() == UseProtocolCachePolicy && isRedirectAfterPos
t(newRequest, redirectResponse)) |
| 456 if (newRequest.cachePolicy() == UseProtocolCachePolicy && isPostOrRedirectAf
terPost(newRequest, redirectResponse)) | |
| 457 newRequest.setCachePolicy(ReloadIgnoringCacheData); | 453 newRequest.setCachePolicy(ReloadIgnoringCacheData); |
| 458 | 454 |
| 459 Frame* parent = m_frame->tree()->parent(); | 455 Frame* parent = m_frame->tree()->parent(); |
| 460 if (parent) { | 456 if (parent) { |
| 461 if (!parent->loader()->mixedContentChecker()->canRunInsecureContent(pare
nt->document()->securityOrigin(), newRequest.url())) { | 457 if (!parent->loader()->mixedContentChecker()->canRunInsecureContent(pare
nt->document()->securityOrigin(), newRequest.url())) { |
| 462 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url(
))); | 458 cancelMainResourceLoad(ResourceError::cancelledError(newRequest.url(
))); |
| 463 return; | 459 return; |
| 464 } | 460 } |
| 465 } | 461 } |
| 466 | 462 |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) | 1001 void DocumentLoader::replaceDocument(const String& source, Document* ownerDocume
nt) |
| 1006 { | 1002 { |
| 1007 m_frame->loader()->stopAllLoaders(); | 1003 m_frame->loader()->stopAllLoaders(); |
| 1008 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : "", m_writer ? m_writer->encod
ingWasChosenByUser() : false, true); | 1004 m_writer = createWriterFor(m_frame, ownerDocument, m_frame->document()->url(
), mimeType(), m_writer ? m_writer->encoding() : "", m_writer ? m_writer->encod
ingWasChosenByUser() : false, true); |
| 1009 if (!source.isNull()) | 1005 if (!source.isNull()) |
| 1010 m_writer->appendReplacingData(source); | 1006 m_writer->appendReplacingData(source); |
| 1011 endWriting(m_writer.get()); | 1007 endWriting(m_writer.get()); |
| 1012 } | 1008 } |
| 1013 | 1009 |
| 1014 } // namespace WebCore | 1010 } // namespace WebCore |
| OLD | NEW |