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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 visitor->trace(m_provisionalItem); | 194 visitor->trace(m_provisionalItem); |
195 visitor->trace(m_deferredHistoryLoad); | 195 visitor->trace(m_deferredHistoryLoad); |
196 } | 196 } |
197 | 197 |
198 void FrameLoader::init() | 198 void FrameLoader::init() |
199 { | 199 { |
200 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); | 200 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); |
201 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 201 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
202 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); | 202 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); |
203 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); | 203 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); |
204 m_provisionalDocumentLoader->startLoadingMainResource(CheckContentSecurityPo
licy); | 204 m_provisionalDocumentLoader->startLoadingMainResource(); |
205 m_frame->document()->cancelParsing(); | 205 m_frame->document()->cancelParsing(); |
206 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); | 206 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); |
207 takeObjectSnapshot(); | 207 takeObjectSnapshot(); |
208 } | 208 } |
209 | 209 |
210 FrameLoaderClient* FrameLoader::client() const | 210 FrameLoaderClient* FrameLoader::client() const |
211 { | 211 { |
212 return static_cast<FrameLoaderClient*>(m_frame->client()); | 212 return static_cast<FrameLoaderClient*>(m_frame->client()); |
213 } | 213 } |
214 | 214 |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 } | 1351 } |
1352 | 1352 |
1353 if (i == targetFrames.size()) | 1353 if (i == targetFrames.size()) |
1354 shouldClose = true; | 1354 shouldClose = true; |
1355 } | 1355 } |
1356 | 1356 |
1357 return shouldClose; | 1357 return shouldClose; |
1358 } | 1358 } |
1359 | 1359 |
1360 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, | 1360 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, |
1361 DocumentLoader* loader, NavigationType type, NavigationPolicy policy, bool r
eplacesCurrentHistoryItem, bool isClientRedirect) | 1361 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl
dContentSecurityPolicy, |
| 1362 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte
m, bool isClientRedirect) |
1362 { | 1363 { |
1363 // Don't ask if we are loading an empty URL. | 1364 // Don't ask if we are loading an empty URL. |
1364 if (request.url().isEmpty() || substituteData.isValid()) | 1365 if (request.url().isEmpty() || substituteData.isValid()) |
1365 return true; | 1366 return true; |
1366 | 1367 |
1367 // TODO(mkwst): Look into moving this to 'FrameFetchContext::canRequestInter
nal' alongside the | 1368 // If we're loading content into a subframe, check against the parent's Cont
ent Security Policy |
1368 // 'frame-src' checks. | 1369 // and kill the load if that check fails, unless we should bypass the main w
orld's CSP. |
| 1370 if (shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy)
{ |
| 1371 Frame* parentFrame = m_frame->tree().parent(); |
| 1372 if (parentFrame) { |
| 1373 ContentSecurityPolicy* parentPolicy = parentFrame->securityContext()
->contentSecurityPolicy(); |
| 1374 if (!parentPolicy->allowChildFrameFromSource(request.url(), request.
redirectStatus())) { |
| 1375 // Fire a load event, as timing attacks would otherwise reveal t
hat the |
| 1376 // frame was blocked. This way, it looks like every other cross-
origin |
| 1377 // page load. |
| 1378 m_frame->document()->enforceSandboxFlags(SandboxOrigin); |
| 1379 m_frame->owner()->dispatchLoad(); |
| 1380 return false; |
| 1381 } |
| 1382 } |
| 1383 } |
| 1384 |
1369 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; | 1385 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; |
1370 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) | 1386 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) |
1371 return false; | 1387 return false; |
1372 | 1388 |
1373 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); | 1389 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); |
1374 if (policy == NavigationPolicyCurrentTab) | 1390 if (policy == NavigationPolicyCurrentTab) |
1375 return true; | 1391 return true; |
1376 if (policy == NavigationPolicyIgnore) | 1392 if (policy == NavigationPolicyIgnore) |
1377 return false; | 1393 return false; |
1378 if (policy == NavigationPolicyHandledByClient) { | 1394 if (policy == NavigationPolicyHandledByClient) { |
(...skipping 10 matching lines...) Expand all Loading... |
1389 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) | 1405 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) |
1390 { | 1406 { |
1391 ASSERT(client()->hasWebView()); | 1407 ASSERT(client()->hasWebView()); |
1392 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 1408 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
1393 return; | 1409 return; |
1394 | 1410 |
1395 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); | 1411 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); |
1396 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); | 1412 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); |
1397 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); | 1413 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); |
1398 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1414 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
1399 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, navigationType, navigationPolicy, type == FrameLoadTypeReplaceCu
rrentItem, frameLoadRequest.clientRedirect() == ClientRedirectPolicy::ClientRedi
rect)) | 1415 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na
vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo
adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) |
1400 return; | 1416 return; |
1401 | 1417 |
1402 m_frame->document()->cancelParsing(); | 1418 m_frame->document()->cancelParsing(); |
1403 if (m_provisionalDocumentLoader) { | 1419 if (m_provisionalDocumentLoader) { |
1404 FrameNavigationDisabler navigationDisabler(*m_frame); | 1420 FrameNavigationDisabler navigationDisabler(*m_frame); |
1405 detachDocumentLoader(m_provisionalDocumentLoader); | 1421 detachDocumentLoader(m_provisionalDocumentLoader); |
1406 } | 1422 } |
1407 | 1423 |
1408 // beforeunload fired above, and detaching a DocumentLoader can fire | 1424 // beforeunload fired above, and detaching a DocumentLoader can fire |
1409 // events, which can detach this frame. | 1425 // events, which can detach this frame. |
(...skipping 15 matching lines...) Expand all Loading... |
1425 if (frameLoadRequest.form()) | 1441 if (frameLoadRequest.form()) |
1426 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1442 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
1427 | 1443 |
1428 m_progressTracker->progressStarted(); | 1444 m_progressTracker->progressStarted(); |
1429 if (m_provisionalDocumentLoader->isClientRedirect()) | 1445 if (m_provisionalDocumentLoader->isClientRedirect()) |
1430 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url()); | 1446 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url()); |
1431 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req
uest().url()); | 1447 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req
uest().url()); |
1432 double triggeringEventTime = frameLoadRequest.triggeringEvent() ? frameLoadR
equest.triggeringEvent()->platformTimeStamp() : 0; | 1448 double triggeringEventTime = frameLoadRequest.triggeringEvent() ? frameLoadR
equest.triggeringEvent()->platformTimeStamp() : 0; |
1433 client()->dispatchDidStartProvisionalLoad(triggeringEventTime); | 1449 client()->dispatchDidStartProvisionalLoad(triggeringEventTime); |
1434 ASSERT(m_provisionalDocumentLoader); | 1450 ASSERT(m_provisionalDocumentLoader); |
1435 m_provisionalDocumentLoader->startLoadingMainResource(frameLoadRequest.shoul
dCheckMainWorldContentSecurityPolicy()); | 1451 m_provisionalDocumentLoader->startLoadingMainResource(); |
1436 | 1452 |
1437 takeObjectSnapshot(); | 1453 takeObjectSnapshot(); |
1438 } | 1454 } |
1439 | 1455 |
1440 void FrameLoader::applyUserAgent(ResourceRequest& request) | 1456 void FrameLoader::applyUserAgent(ResourceRequest& request) |
1441 { | 1457 { |
1442 String userAgent = this->userAgent(); | 1458 String userAgent = this->userAgent(); |
1443 ASSERT(!userAgent.isNull()); | 1459 ASSERT(!userAgent.isNull()); |
1444 request.setHTTPUserAgent(AtomicString(userAgent)); | 1460 request.setHTTPUserAgent(AtomicString(userAgent)); |
1445 } | 1461 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); | 1608 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa
der->url() : String()); |
1593 return tracedValue; | 1609 return tracedValue; |
1594 } | 1610 } |
1595 | 1611 |
1596 inline void FrameLoader::takeObjectSnapshot() const | 1612 inline void FrameLoader::takeObjectSnapshot() const |
1597 { | 1613 { |
1598 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); | 1614 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced
Value()); |
1599 } | 1615 } |
1600 | 1616 |
1601 } // namespace blink | 1617 } // namespace blink |
OLD | NEW |