| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv
ed. |
| 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
| 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
| 8 * Copyright (C) 2011 Google Inc. All rights reserved. | 8 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 9 * | 9 * |
| 10 * Redistribution and use in source and binary forms, with or without | 10 * Redistribution and use in source and binary forms, with or without |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 // Always use the initiating document to generate the referrer. | 630 // Always use the initiating document to generate the referrer. |
| 631 // We need to generateReferrerHeader(), because we might not have enforced R
eferrerPolicy or https->http | 631 // We need to generateReferrerHeader(), because we might not have enforced R
eferrerPolicy or https->http |
| 632 // referrer suppression yet. | 632 // referrer suppression yet. |
| 633 String argsReferrer(request.httpReferrer()); | 633 String argsReferrer(request.httpReferrer()); |
| 634 if (argsReferrer.isEmpty()) | 634 if (argsReferrer.isEmpty()) |
| 635 argsReferrer = originDocument->outgoingReferrer(); | 635 argsReferrer = originDocument->outgoingReferrer(); |
| 636 String referrer = SecurityPolicy::generateReferrerHeader(originDocument->ref
errerPolicy(), request.url(), argsReferrer); | 636 String referrer = SecurityPolicy::generateReferrerHeader(originDocument->ref
errerPolicy(), request.url(), argsReferrer); |
| 637 | 637 |
| 638 request.setHTTPReferrer(Referrer(referrer, originDocument->referrerPolicy())
); | 638 request.setHTTPReferrer(Referrer(referrer, originDocument->referrerPolicy())
); |
| 639 RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(ref
errer); | 639 RefPtr<SecurityOrigin> referrerOrigin = SecurityOrigin::createFromString(ref
errer); |
| 640 addHTTPOriginIfNeeded(request, referrerOrigin->toAtomicString()); | 640 request.addHTTPOriginIfNeeded(referrerOrigin->toAtomicString()); |
| 641 } | 641 } |
| 642 | 642 |
| 643 bool FrameLoader::isScriptTriggeredFormSubmissionInChildFrame(const FrameLoadReq
uest& request) const | 643 bool FrameLoader::isScriptTriggeredFormSubmissionInChildFrame(const FrameLoadReq
uest& request) const |
| 644 { | 644 { |
| 645 // If this is a child frame and the form submission was triggered by a scrip
t, lock the back/forward list | 645 // If this is a child frame and the form submission was triggered by a scrip
t, lock the back/forward list |
| 646 // to match IE and Opera. | 646 // to match IE and Opera. |
| 647 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva
tion for this. | 647 // See https://bugs.webkit.org/show_bug.cgi?id=32383 for the original motiva
tion for this. |
| 648 if (!m_frame->tree().parent() || UserGestureIndicator::processingUserGesture
()) | 648 if (!m_frame->tree().parent() || UserGestureIndicator::processingUserGesture
()) |
| 649 return false; | 649 return false; |
| 650 return request.formState() && request.formState()->formSubmissionTrigger() =
= SubmittedByJavaScript; | 650 return request.formState() && request.formState()->formSubmissionTrigger() =
= SubmittedByJavaScript; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 static ResourceRequest requestFromHistoryItem(HistoryItem* item, ResourceRequest
CachePolicy cachePolicy) | 773 static ResourceRequest requestFromHistoryItem(HistoryItem* item, ResourceRequest
CachePolicy cachePolicy) |
| 774 { | 774 { |
| 775 RefPtr<FormData> formData = item->formData(); | 775 RefPtr<FormData> formData = item->formData(); |
| 776 ResourceRequest request(item->url(), item->referrer()); | 776 ResourceRequest request(item->url(), item->referrer()); |
| 777 request.setCachePolicy(cachePolicy); | 777 request.setCachePolicy(cachePolicy); |
| 778 if (formData) { | 778 if (formData) { |
| 779 request.setHTTPMethod("POST"); | 779 request.setHTTPMethod("POST"); |
| 780 request.setHTTPBody(formData); | 780 request.setHTTPBody(formData); |
| 781 request.setHTTPContentType(item->formContentType()); | 781 request.setHTTPContentType(item->formContentType()); |
| 782 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString
(item->referrer().referrer); | 782 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::createFromString
(item->referrer().referrer); |
| 783 FrameLoader::addHTTPOriginIfNeeded(request, securityOrigin->toAtomicStri
ng()); | 783 request.addHTTPOriginIfNeeded(securityOrigin->toAtomicString()); |
| 784 } | 784 } |
| 785 return request; | 785 return request; |
| 786 } | 786 } |
| 787 | 787 |
| 788 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st AtomicString& overrideEncoding) | 788 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st AtomicString& overrideEncoding) |
| 789 { | 789 { |
| 790 if (!m_currentItem) | 790 if (!m_currentItem) |
| 791 return; | 791 return; |
| 792 | 792 |
| 793 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re
loadBypassingCache : ReloadIgnoringCacheData; | 793 ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? Re
loadBypassingCache : ReloadIgnoringCacheData; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 // the frame detach code... but it is sometimes. | 1158 // the frame detach code... but it is sometimes. |
| 1159 // FIXME: Understand why this is happening so we can document this insanity. | 1159 // FIXME: Understand why this is happening so we can document this insanity. |
| 1160 if (client()) { | 1160 if (client()) { |
| 1161 // After this, we must no longer talk to the client since this clears | 1161 // After this, we must no longer talk to the client since this clears |
| 1162 // its owning reference back to our owning LocalFrame. | 1162 // its owning reference back to our owning LocalFrame. |
| 1163 client()->detachedFromParent(); | 1163 client()->detachedFromParent(); |
| 1164 m_frame->clearClient(); | 1164 m_frame->clearClient(); |
| 1165 } | 1165 } |
| 1166 } | 1166 } |
| 1167 | 1167 |
| 1168 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt
ring& origin) | |
| 1169 { | |
| 1170 if (!request.httpOrigin().isEmpty()) | |
| 1171 return; // Request already has an Origin header. | |
| 1172 | |
| 1173 // Don't send an Origin header for GET or HEAD to avoid privacy issues. | |
| 1174 // For example, if an intranet page has a hyperlink to an external web | |
| 1175 // site, we don't want to include the Origin of the request because it | |
| 1176 // will leak the internal host name. Similar privacy concerns have lead | |
| 1177 // to the widespread suppression of the Referer header at the network | |
| 1178 // layer. | |
| 1179 if (request.httpMethod() == "GET" || request.httpMethod() == "HEAD") | |
| 1180 return; | |
| 1181 | |
| 1182 // For non-GET and non-HEAD methods, always send an Origin header so the | |
| 1183 // server knows we support this feature. | |
| 1184 | |
| 1185 if (origin.isEmpty()) { | |
| 1186 // If we don't know what origin header to attach, we attach the value | |
| 1187 // for an empty origin. | |
| 1188 request.setHTTPOrigin(SecurityOrigin::createUnique()->toAtomicString()); | |
| 1189 return; | |
| 1190 } | |
| 1191 | |
| 1192 request.setHTTPOrigin(origin); | |
| 1193 } | |
| 1194 | |
| 1195 void FrameLoader::receivedMainResourceError(const ResourceError& error) | 1168 void FrameLoader::receivedMainResourceError(const ResourceError& error) |
| 1196 { | 1169 { |
| 1197 // Retain because the stop may release the last reference to it. | 1170 // Retain because the stop may release the last reference to it. |
| 1198 RefPtr<LocalFrame> protect(m_frame); | 1171 RefPtr<LocalFrame> protect(m_frame); |
| 1199 | 1172 |
| 1200 if (m_frame->document()->parser()) | 1173 if (m_frame->document()->parser()) |
| 1201 m_frame->document()->parser()->stopParsing(); | 1174 m_frame->document()->parser()->stopParsing(); |
| 1202 | 1175 |
| 1203 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some | 1176 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some |
| 1204 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). | 1177 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1474 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. | 1447 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. |
| 1475 Frame* parentFrame = m_frame->tree().parent(); | 1448 Frame* parentFrame = m_frame->tree().parent(); |
| 1476 if (parentFrame && parentFrame->isLocalFrame()) | 1449 if (parentFrame && parentFrame->isLocalFrame()) |
| 1477 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); | 1450 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); |
| 1478 if (FrameOwner* frameOwner = m_frame->owner()) | 1451 if (FrameOwner* frameOwner = m_frame->owner()) |
| 1479 flags |= frameOwner->sandboxFlags(); | 1452 flags |= frameOwner->sandboxFlags(); |
| 1480 return flags; | 1453 return flags; |
| 1481 } | 1454 } |
| 1482 | 1455 |
| 1483 } // namespace WebCore | 1456 } // namespace WebCore |
| OLD | NEW |