| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 | 776 |
| 777 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url) | 777 void FrameLoader::reportLocalLoadFailed(Frame* frame, const String& url) |
| 778 { | 778 { |
| 779 ASSERT(!url.isEmpty()); | 779 ASSERT(!url.isEmpty()); |
| 780 if (!frame) | 780 if (!frame) |
| 781 return; | 781 return; |
| 782 | 782 |
| 783 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); | 783 frame->document()->addConsoleMessage(SecurityMessageSource, ErrorMessageLeve
l, "Not allowed to load local resource: " + url); |
| 784 } | 784 } |
| 785 | 785 |
| 786 bool FrameLoader::willLoadMediaElementURL(KURL& url) | |
| 787 { | |
| 788 ResourceRequest request(url); | |
| 789 | |
| 790 unsigned long identifier; | |
| 791 ResourceError error; | |
| 792 requestFromDelegate(request, identifier, error); | |
| 793 m_frame->fetchContext().sendRemainingDelegateMessages(m_documentLoader.get()
, identifier, ResourceResponse(url, String(), -1, String(), String()), 0, -1, -1
, error); | |
| 794 | |
| 795 url = request.url(); | |
| 796 | |
| 797 return error.isNull(); | |
| 798 } | |
| 799 | |
| 800 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st String& overrideEncoding) | 786 void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
st String& overrideEncoding) |
| 801 { | 787 { |
| 802 DocumentLoader* documentLoader = activeDocumentLoader(); | 788 DocumentLoader* documentLoader = activeDocumentLoader(); |
| 803 if (!documentLoader) | 789 if (!documentLoader) |
| 804 return; | 790 return; |
| 805 | 791 |
| 806 if (m_state == FrameStateProvisional) | 792 if (m_state == FrameStateProvisional) |
| 807 insertDummyHistoryItem(); | 793 insertDummyHistoryItem(); |
| 808 frame()->loader()->history()->saveDocumentAndScrollState(); | 794 frame()->loader()->history()->saveDocumentAndScrollState(); |
| 809 | 795 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1251 if (origin.isEmpty()) { | 1237 if (origin.isEmpty()) { |
| 1252 // If we don't know what origin header to attach, we attach the value | 1238 // If we don't know what origin header to attach, we attach the value |
| 1253 // for an empty origin. | 1239 // for an empty origin. |
| 1254 request.setHTTPOrigin(SecurityOrigin::createUnique()->toString()); | 1240 request.setHTTPOrigin(SecurityOrigin::createUnique()->toString()); |
| 1255 return; | 1241 return; |
| 1256 } | 1242 } |
| 1257 | 1243 |
| 1258 request.setHTTPOrigin(origin); | 1244 request.setHTTPOrigin(origin); |
| 1259 } | 1245 } |
| 1260 | 1246 |
| 1261 unsigned long FrameLoader::loadResourceSynchronously(const ResourceRequest& requ
est, StoredCredentials storedCredentials, ResourceError& error, ResourceResponse
& response, Vector<char>& data) | |
| 1262 { | |
| 1263 ASSERT(m_frame->document()); | |
| 1264 String referrer = SecurityPolicy::generateReferrerHeader(m_frame->document()
->referrerPolicy(), request.url(), outgoingReferrer()); | |
| 1265 | |
| 1266 ResourceRequest initialRequest = request; | |
| 1267 initialRequest.setTimeoutInterval(10); | |
| 1268 | |
| 1269 if (!referrer.isEmpty()) | |
| 1270 initialRequest.setHTTPReferrer(referrer); | |
| 1271 addHTTPOriginIfNeeded(initialRequest, outgoingOrigin()); | |
| 1272 | |
| 1273 addExtraFieldsToRequest(initialRequest); | |
| 1274 | |
| 1275 unsigned long identifier = 0; | |
| 1276 ResourceRequest newRequest(initialRequest); | |
| 1277 requestFromDelegate(newRequest, identifier, error); | |
| 1278 | |
| 1279 if (error.isNull()) { | |
| 1280 ASSERT(!newRequest.isNull()); | |
| 1281 documentLoader()->applicationCacheHost()->willStartLoadingSynchronously(
newRequest); | |
| 1282 ResourceLoader::loadResourceSynchronously(newRequest, storedCredentials,
error, response, data); | |
| 1283 } | |
| 1284 int encodedDataLength = response.resourceLoadInfo() ? static_cast<int>(respo
nse.resourceLoadInfo()->encodedDataLength) : -1; | |
| 1285 m_frame->fetchContext().sendRemainingDelegateMessages(m_documentLoader.get()
, identifier, response, data.data(), data.size(), encodedDataLength, error); | |
| 1286 return identifier; | |
| 1287 } | |
| 1288 | |
| 1289 const ResourceRequest& FrameLoader::originalRequest() const | 1247 const ResourceRequest& FrameLoader::originalRequest() const |
| 1290 { | 1248 { |
| 1291 return activeDocumentLoader()->originalRequestCopy(); | 1249 return activeDocumentLoader()->originalRequestCopy(); |
| 1292 } | 1250 } |
| 1293 | 1251 |
| 1294 void FrameLoader::receivedMainResourceError(const ResourceError& error) | 1252 void FrameLoader::receivedMainResourceError(const ResourceError& error) |
| 1295 { | 1253 { |
| 1296 // Retain because the stop may release the last reference to it. | 1254 // Retain because the stop may release the last reference to it. |
| 1297 RefPtr<Frame> protect(m_frame); | 1255 RefPtr<Frame> protect(m_frame); |
| 1298 | 1256 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 if (!m_suppressOpenerInNewFrame) { | 1457 if (!m_suppressOpenerInNewFrame) { |
| 1500 mainFrame->loader()->setOpener(frame.get()); | 1458 mainFrame->loader()->setOpener(frame.get()); |
| 1501 mainFrame->document()->setReferrerPolicy(frame->document()->referrerPoli
cy()); | 1459 mainFrame->document()->setReferrerPolicy(frame->document()->referrerPoli
cy()); |
| 1502 } | 1460 } |
| 1503 | 1461 |
| 1504 // FIXME: We can't just send our NavigationAction to the new FrameLoader's l
oadWithNavigationAction(), we need to | 1462 // FIXME: We can't just send our NavigationAction to the new FrameLoader's l
oadWithNavigationAction(), we need to |
| 1505 // create a new one with a default NavigationType and no triggering event. W
e should figure out why. | 1463 // create a new one with a default NavigationType and no triggering event. W
e should figure out why. |
| 1506 mainFrame->loader()->loadWithNavigationAction(action.resourceRequest(), Navi
gationAction(action.resourceRequest()), FrameLoadTypeStandard, formState, Substi
tuteData()); | 1464 mainFrame->loader()->loadWithNavigationAction(action.resourceRequest(), Navi
gationAction(action.resourceRequest()), FrameLoadTypeStandard, formState, Substi
tuteData()); |
| 1507 } | 1465 } |
| 1508 | 1466 |
| 1509 void FrameLoader::requestFromDelegate(ResourceRequest& request, unsigned long& i
dentifier, ResourceError& error) | |
| 1510 { | |
| 1511 ASSERT(!request.isNull()); | |
| 1512 | |
| 1513 identifier = 0; | |
| 1514 if (m_frame->page()) | |
| 1515 identifier = createUniqueIdentifier(); | |
| 1516 | |
| 1517 ResourceRequest newRequest(request); | |
| 1518 m_frame->fetchContext().dispatchWillSendRequest(m_documentLoader.get(), iden
tifier, newRequest, ResourceResponse()); | |
| 1519 | |
| 1520 if (newRequest.isNull()) | |
| 1521 error = ResourceError::cancelledError(request.url()); | |
| 1522 else | |
| 1523 error = ResourceError(); | |
| 1524 | |
| 1525 request = newRequest; | |
| 1526 } | |
| 1527 | |
| 1528 void FrameLoader::loadedResourceFromMemoryCache(Resource* resource) | |
| 1529 { | |
| 1530 Page* page = m_frame->page(); | |
| 1531 if (!page) | |
| 1532 return; | |
| 1533 | |
| 1534 if (!resource->shouldSendResourceLoadCallbacks()) | |
| 1535 return; | |
| 1536 | |
| 1537 // Main resource delegate messages are synthesized in MainResourceLoader, so
we must not send them here. | |
| 1538 if (resource->type() == Resource::MainResource) | |
| 1539 return; | |
| 1540 | |
| 1541 ResourceRequest request(resource->url()); | |
| 1542 m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), req
uest, resource->response(), resource->encodedSize()); | |
| 1543 | |
| 1544 unsigned long identifier; | |
| 1545 ResourceError error; | |
| 1546 requestFromDelegate(request, identifier, error); | |
| 1547 InspectorInstrumentation::markResourceAsCached(page, identifier); | |
| 1548 m_frame->fetchContext().sendRemainingDelegateMessages(m_documentLoader.get()
, identifier, resource->response(), 0, resource->encodedSize(), 0, error); | |
| 1549 } | |
| 1550 | |
| 1551 void FrameLoader::applyUserAgent(ResourceRequest& request) | 1467 void FrameLoader::applyUserAgent(ResourceRequest& request) |
| 1552 { | 1468 { |
| 1553 String userAgent = this->userAgent(request.url()); | 1469 String userAgent = this->userAgent(request.url()); |
| 1554 ASSERT(!userAgent.isNull()); | 1470 ASSERT(!userAgent.isNull()); |
| 1555 request.setHTTPUserAgent(userAgent); | 1471 request.setHTTPUserAgent(userAgent); |
| 1556 } | 1472 } |
| 1557 | 1473 |
| 1558 bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con
st KURL& url, unsigned long requestIdentifier) | 1474 bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con
st KURL& url, unsigned long requestIdentifier) |
| 1559 { | 1475 { |
| 1560 UseCounter::count(m_frame->document(), UseCounter::XFrameOptions); | 1476 UseCounter::count(m_frame->document(), UseCounter::XFrameOptions); |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1711 { | 1627 { |
| 1712 SandboxFlags flags = m_forcedSandboxFlags; | 1628 SandboxFlags flags = m_forcedSandboxFlags; |
| 1713 if (Frame* parentFrame = m_frame->tree()->parent()) | 1629 if (Frame* parentFrame = m_frame->tree()->parent()) |
| 1714 flags |= parentFrame->document()->sandboxFlags(); | 1630 flags |= parentFrame->document()->sandboxFlags(); |
| 1715 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1631 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
| 1716 flags |= ownerElement->sandboxFlags(); | 1632 flags |= ownerElement->sandboxFlags(); |
| 1717 return flags; | 1633 return flags; |
| 1718 } | 1634 } |
| 1719 | 1635 |
| 1720 } // namespace WebCore | 1636 } // namespace WebCore |
| OLD | NEW |