| 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 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 } | 1326 } |
| 1327 | 1327 |
| 1328 if (i == targetFrames.size()) | 1328 if (i == targetFrames.size()) |
| 1329 shouldClose = true; | 1329 shouldClose = true; |
| 1330 } | 1330 } |
| 1331 return shouldClose; | 1331 return shouldClose; |
| 1332 } | 1332 } |
| 1333 | 1333 |
| 1334 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, | 1334 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque
st, const SubstituteData& substituteData, |
| 1335 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl
dContentSecurityPolicy, | 1335 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl
dContentSecurityPolicy, |
| 1336 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte
m, bool isClientRedirect) | 1336 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte
m, bool isClientRedirect, HTMLFormElement* form) |
| 1337 { | 1337 { |
| 1338 // Don't ask if we are loading an empty URL. | 1338 // Don't ask if we are loading an empty URL. |
| 1339 if (request.url().isEmpty() || substituteData.isValid()) | 1339 if (request.url().isEmpty() || substituteData.isValid()) |
| 1340 return true; | 1340 return true; |
| 1341 | 1341 |
| 1342 // If we're loading content into a subframe, check against the parent's Cont
ent Security Policy | 1342 // If we're loading content into a subframe, check against the parent's Cont
ent Security Policy |
| 1343 // and kill the load if that check fails, unless we should bypass the main w
orld's CSP. | 1343 // and kill the load if that check fails, unless we should bypass the main w
orld's CSP. |
| 1344 // FIXME: CSP checks are broken for OOPI. For now, this policy always allows
frames with a remote parent... | 1344 // FIXME: CSP checks are broken for OOPI. For now, this policy always allows
frames with a remote parent... |
| 1345 if ((shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy
) && (m_frame->deprecatedLocalOwner() && !m_frame->deprecatedLocalOwner()->docum
ent().contentSecurityPolicy()->allowChildFrameFromSource(request.url(), request.
followedRedirect() ? ContentSecurityPolicy::DidRedirect : ContentSecurityPolicy:
:DidNotRedirect))) { | 1345 if ((shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy
) && (m_frame->deprecatedLocalOwner() && !m_frame->deprecatedLocalOwner()->docum
ent().contentSecurityPolicy()->allowChildFrameFromSource(request.url(), request.
followedRedirect() ? ContentSecurityPolicy::DidRedirect : ContentSecurityPolicy:
:DidNotRedirect))) { |
| 1346 // Fire a load event, as timing attacks would otherwise reveal that the | 1346 // Fire a load event, as timing attacks would otherwise reveal that the |
| 1347 // frame was blocked. This way, it looks like every other cross-origin | 1347 // frame was blocked. This way, it looks like every other cross-origin |
| 1348 // page load. | 1348 // page load. |
| 1349 m_frame->document()->enforceSandboxFlags(SandboxOrigin); | 1349 m_frame->document()->enforceSandboxFlags(SandboxOrigin); |
| 1350 m_frame->owner()->dispatchLoad(); | 1350 m_frame->owner()->dispatchLoad(); |
| 1351 return false; | 1351 return false; |
| 1352 } | 1352 } |
| 1353 | 1353 |
| 1354 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; | 1354 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig
ationTypeFormResubmitted; |
| 1355 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) | 1355 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow
FormAction(request.url())) |
| 1356 return false; | 1356 return false; |
| 1357 | 1357 |
| 1358 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); | 1358 policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem, isClientRedirect); |
| 1359 if (policy == NavigationPolicyCurrentTab) | 1359 if (policy == NavigationPolicyCurrentTab) |
| 1360 return true; | 1360 return true; |
| 1361 if (policy == NavigationPolicyIgnore) | 1361 if (policy == NavigationPolicyIgnore) |
| 1362 return false; | 1362 return false; |
| 1363 if (policy == NavigationPolicyHandledByClient) { | 1363 if (policy == NavigationPolicyHandledByClient) { |
| 1364 // Mark the frame as loading since the embedder is handling the navigati
on. | 1364 // Mark the frame as loading since the embedder is handling the navigati
on. |
| 1365 m_progressTracker->progressStarted(); | 1365 m_progressTracker->progressStarted(); |
| 1366 |
| 1367 // If this is a form submit, dispatch that a form is being submitted |
| 1368 // since the embedder is handling the navigation. |
| 1369 if (form) |
| 1370 client()->dispatchWillSubmitForm(form); |
| 1371 |
| 1366 return false; | 1372 return false; |
| 1367 } | 1373 } |
| 1368 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi
ngUserGesture()) | 1374 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi
ngUserGesture()) |
| 1369 return false; | 1375 return false; |
| 1370 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); | 1376 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); |
| 1371 return false; | 1377 return false; |
| 1372 } | 1378 } |
| 1373 | 1379 |
| 1374 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) | 1380 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) |
| 1375 { | 1381 { |
| 1376 ASSERT(client()->hasWebView()); | 1382 ASSERT(client()->hasWebView()); |
| 1377 // Lots of things in this function can detach the LocalFrame (stopAllLoaders
, beforeunload handlers, etc.), so protect the frame. | 1383 // Lots of things in this function can detach the LocalFrame (stopAllLoaders
, beforeunload handlers, etc.), so protect the frame. |
| 1378 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1384 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
| 1379 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 1385 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
| 1380 return; | 1386 return; |
| 1381 | 1387 |
| 1382 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); | 1388 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); |
| 1383 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); | 1389 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); |
| 1384 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); | 1390 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); |
| 1385 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1391 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
| 1386 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na
vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo
adRequest.clientRedirect() == ClientRedirect)) | 1392 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, |
| 1393 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigation
Type, |
| 1394 navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, |
| 1395 frameLoadRequest.clientRedirect() == ClientRedirect, frameLoadRequest.fo
rm())) { |
| 1387 return; | 1396 return; |
| 1397 } |
| 1398 |
| 1388 if (!shouldClose(navigationType == NavigationTypeReload)) | 1399 if (!shouldClose(navigationType == NavigationTypeReload)) |
| 1389 return; | 1400 return; |
| 1390 | 1401 |
| 1391 m_frame->document()->cancelParsing(); | 1402 m_frame->document()->cancelParsing(); |
| 1392 | 1403 |
| 1393 if (m_provisionalDocumentLoader) { | 1404 if (m_provisionalDocumentLoader) { |
| 1394 m_provisionalDocumentLoader->stopLoading(); | 1405 m_provisionalDocumentLoader->stopLoading(); |
| 1395 detachDocumentLoader(m_provisionalDocumentLoader); | 1406 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1396 } | 1407 } |
| 1397 | 1408 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 // FIXME: We need a way to propagate insecure requests policy flags to | 1583 // FIXME: We need a way to propagate insecure requests policy flags to |
| 1573 // out-of-process frames. For now, we'll always use default behavior. | 1584 // out-of-process frames. For now, we'll always use default behavior. |
| 1574 if (!parentFrame->isLocalFrame()) | 1585 if (!parentFrame->isLocalFrame()) |
| 1575 return nullptr; | 1586 return nullptr; |
| 1576 | 1587 |
| 1577 ASSERT(toLocalFrame(parentFrame)->document()); | 1588 ASSERT(toLocalFrame(parentFrame)->document()); |
| 1578 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1589 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
| 1579 } | 1590 } |
| 1580 | 1591 |
| 1581 } // namespace blink | 1592 } // namespace blink |
| OLD | NEW |