Chromium Code Reviews| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 { | 263 { |
| 264 // Calling document.open counts as committing the first real document load. | 264 // Calling document.open counts as committing the first real document load. |
| 265 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 265 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
| 266 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); | 266 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); |
| 267 | 267 |
| 268 // Only model a document.open() as part of a navigation if its parent is not done | 268 // Only model a document.open() as part of a navigation if its parent is not done |
| 269 // or in the process of completing. | 269 // or in the process of completing. |
| 270 if (Frame* parent = m_frame->tree().parent()) { | 270 if (Frame* parent = m_frame->tree().parent()) { |
| 271 if ((parent->isLocalFrame() && toLocalFrame(parent)->document()->loadEve ntStillNeeded()) | 271 if ((parent->isLocalFrame() && toLocalFrame(parent)->document()->loadEve ntStillNeeded()) |
| 272 || (parent->isRemoteFrame() && parent->isLoading())) { | 272 || (parent->isRemoteFrame() && parent->isLoading())) { |
| 273 m_progressTracker->progressStarted(); | 273 m_progressTracker->progressStarted(true); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results | 277 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results |
| 278 // from a subsequent window.document.open / window.document.write call. | 278 // from a subsequent window.document.open / window.document.write call. |
| 279 // Canceling redirection here works for all cases because document.open | 279 // Canceling redirection here works for all cases because document.open |
| 280 // implicitly precedes document.write. | 280 // implicitly precedes document.write. |
| 281 m_frame->navigationScheduler().cancel(); | 281 m_frame->navigationScheduler().cancel(); |
| 282 } | 282 } |
| 283 | 283 |
| (...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1298 } | 1298 } |
| 1299 | 1299 |
| 1300 if (i == targetFrames.size()) | 1300 if (i == targetFrames.size()) |
| 1301 shouldClose = true; | 1301 shouldClose = true; |
| 1302 } | 1302 } |
| 1303 return shouldClose; | 1303 return shouldClose; |
| 1304 } | 1304 } |
| 1305 | 1305 |
| 1306 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData, | 1306 bool FrameLoader::shouldContinueForNavigationPolicy(const ResourceRequest& reque st, const SubstituteData& substituteData, |
| 1307 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy, | 1307 DocumentLoader* loader, ContentSecurityPolicyDisposition shouldCheckMainWorl dContentSecurityPolicy, |
| 1308 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m) | 1308 NavigationType type, NavigationPolicy policy, bool replacesCurrentHistoryIte m, HTMLFormElement* form) |
| 1309 { | 1309 { |
| 1310 // Don't ask if we are loading an empty URL. | 1310 // Don't ask if we are loading an empty URL. |
| 1311 if (request.url().isEmpty() || substituteData.isValid()) | 1311 if (request.url().isEmpty() || substituteData.isValid()) |
| 1312 return true; | 1312 return true; |
| 1313 | 1313 |
| 1314 // If we're loading content into a subframe, check against the parent's Cont ent Security Policy | 1314 // If we're loading content into a subframe, check against the parent's Cont ent Security Policy |
| 1315 // and kill the load if that check fails, unless we should bypass the main w orld's CSP. | 1315 // and kill the load if that check fails, unless we should bypass the main w orld's CSP. |
| 1316 // FIXME: CSP checks are broken for OOPI. For now, this policy always allows frames with a remote parent... | 1316 // FIXME: CSP checks are broken for OOPI. For now, this policy always allows frames with a remote parent... |
| 1317 if ((shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy ) && (m_frame->deprecatedLocalOwner() && !m_frame->deprecatedLocalOwner()->docum ent().contentSecurityPolicy()->allowChildFrameFromSource(request.url(), request. followedRedirect() ? ContentSecurityPolicy::DidRedirect : ContentSecurityPolicy: :DidNotRedirect))) { | 1317 if ((shouldCheckMainWorldContentSecurityPolicy == CheckContentSecurityPolicy ) && (m_frame->deprecatedLocalOwner() && !m_frame->deprecatedLocalOwner()->docum ent().contentSecurityPolicy()->allowChildFrameFromSource(request.url(), request. followedRedirect() ? ContentSecurityPolicy::DidRedirect : ContentSecurityPolicy: :DidNotRedirect))) { |
| 1318 // Fire a load event, as timing attacks would otherwise reveal that the | 1318 // Fire a load event, as timing attacks would otherwise reveal that the |
| 1319 // frame was blocked. This way, it looks like every other cross-origin | 1319 // frame was blocked. This way, it looks like every other cross-origin |
| 1320 // page load. | 1320 // page load. |
| 1321 m_frame->document()->enforceSandboxFlags(SandboxOrigin); | 1321 m_frame->document()->enforceSandboxFlags(SandboxOrigin); |
| 1322 m_frame->owner()->dispatchLoad(); | 1322 m_frame->owner()->dispatchLoad(); |
| 1323 return false; | 1323 return false; |
| 1324 } | 1324 } |
| 1325 | 1325 |
| 1326 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig ationTypeFormResubmitted; | 1326 bool isFormSubmission = type == NavigationTypeFormSubmitted || type == Navig ationTypeFormResubmitted; |
| 1327 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow FormAction(request.url())) | 1327 if (isFormSubmission && !m_frame->document()->contentSecurityPolicy()->allow FormAction(request.url())) |
| 1328 return false; | 1328 return false; |
| 1329 | 1329 |
| 1330 policy = client()->decidePolicyForNavigation(request, loader, type, policy, replacesCurrentHistoryItem); | 1330 policy = client()->decidePolicyForNavigation(request, loader, type, policy, replacesCurrentHistoryItem); |
| 1331 if (policy == NavigationPolicyCurrentTab) | 1331 if (policy == NavigationPolicyCurrentTab) |
| 1332 return true; | 1332 return true; |
| 1333 if (policy == NavigationPolicyIgnore) | 1333 if (policy == NavigationPolicyIgnore) |
| 1334 return false; | 1334 return false; |
| 1335 if (policy == NavigationPolicyHandledByClient) { | 1335 if (policy == NavigationPolicyHandledByClient) { |
| 1336 // Mark the frame as loading since the embedder is handling the navigati on. | 1336 // Mark the frame as loading since the embedder is handling the |
| 1337 m_progressTracker->progressStarted(); | 1337 // navigation. However there is no need to inform the embedder that the |
| 1338 // frame is loading, since we already requested it to load the main | |
| 1339 // resource. | |
| 1340 m_progressTracker->progressStarted(false); | |
|
Nate Chapin
2015/12/08 23:18:38
I don't particularly like the special case boolean
clamy
2015/12/11 14:50:06
I think this is due to how the loading state is im
| |
| 1341 | |
| 1342 // If this is a form submit, dispatch that a form is being submitted | |
| 1343 // since the embedder is handling the navigation. | |
| 1344 if (form) | |
| 1345 client()->dispatchWillSubmitForm(form); | |
| 1346 | |
| 1338 return false; | 1347 return false; |
| 1339 } | 1348 } |
| 1340 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi ngUserGesture()) | 1349 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi ngUserGesture()) |
| 1341 return false; | 1350 return false; |
| 1342 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor yItem); | 1351 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor yItem); |
| 1343 return false; | 1352 return false; |
| 1344 } | 1353 } |
| 1345 | 1354 |
| 1346 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty pe, NavigationPolicy navigationPolicy) | 1355 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty pe, NavigationPolicy navigationPolicy) |
| 1347 { | 1356 { |
| 1348 ASSERT(client()->hasWebView()); | 1357 ASSERT(client()->hasWebView()); |
| 1349 // Lots of things in this function can detach the LocalFrame (stopAllLoaders , beforeunload handlers, etc.), so protect the frame. | 1358 // Lots of things in this function can detach the LocalFrame (stopAllLoaders , beforeunload handlers, etc.), so protect the frame. |
| 1350 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1359 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
| 1351 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) | 1360 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) |
| 1352 return; | 1361 return; |
| 1353 | 1362 |
| 1354 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); | 1363 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); |
| 1355 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); | 1364 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); |
| 1356 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); | 1365 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); |
| 1357 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1366 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
| 1358 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem)) | 1367 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, |
| 1368 frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), navigation Type, | |
| 1369 navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLoadRequ est.form())) { | |
| 1359 return; | 1370 return; |
| 1371 } | |
| 1360 if (!shouldClose(navigationType == NavigationTypeReload)) | 1372 if (!shouldClose(navigationType == NavigationTypeReload)) |
| 1361 return; | 1373 return; |
| 1362 | 1374 |
| 1363 m_frame->document()->cancelParsing(); | 1375 m_frame->document()->cancelParsing(); |
| 1364 | 1376 |
| 1365 if (m_provisionalDocumentLoader) { | 1377 if (m_provisionalDocumentLoader) { |
| 1366 m_provisionalDocumentLoader->stopLoading(); | 1378 m_provisionalDocumentLoader->stopLoading(); |
| 1367 detachDocumentLoader(m_provisionalDocumentLoader); | 1379 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1368 } | 1380 } |
| 1369 | 1381 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1380 InspectorInstrumentation::didStartProvisionalLoad(m_frame); | 1392 InspectorInstrumentation::didStartProvisionalLoad(m_frame); |
| 1381 | 1393 |
| 1382 m_frame->navigationScheduler().cancel(); | 1394 m_frame->navigationScheduler().cancel(); |
| 1383 m_checkTimer.stop(); | 1395 m_checkTimer.stop(); |
| 1384 | 1396 |
| 1385 m_loadType = type; | 1397 m_loadType = type; |
| 1386 | 1398 |
| 1387 if (frameLoadRequest.form()) | 1399 if (frameLoadRequest.form()) |
| 1388 client()->dispatchWillSubmitForm(frameLoadRequest.form()); | 1400 client()->dispatchWillSubmitForm(frameLoadRequest.form()); |
| 1389 | 1401 |
| 1390 m_progressTracker->progressStarted(); | 1402 m_progressTracker->progressStarted(true); |
| 1391 if (m_provisionalDocumentLoader->isClientRedirect()) | 1403 if (m_provisionalDocumentLoader->isClientRedirect()) |
| 1392 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url()); | 1404 m_provisionalDocumentLoader->appendRedirect(m_frame->document()->url()); |
| 1393 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req uest().url()); | 1405 m_provisionalDocumentLoader->appendRedirect(m_provisionalDocumentLoader->req uest().url()); |
| 1394 double triggeringEventTime = frameLoadRequest.triggeringEvent() ? frameLoadR equest.triggeringEvent()->platformTimeStamp() : 0; | 1406 double triggeringEventTime = frameLoadRequest.triggeringEvent() ? frameLoadR equest.triggeringEvent()->platformTimeStamp() : 0; |
| 1395 client()->dispatchDidStartProvisionalLoad(triggeringEventTime); | 1407 client()->dispatchDidStartProvisionalLoad(triggeringEventTime); |
| 1396 ASSERT(m_provisionalDocumentLoader); | 1408 ASSERT(m_provisionalDocumentLoader); |
| 1397 m_provisionalDocumentLoader->startLoadingMainResource(); | 1409 m_provisionalDocumentLoader->startLoadingMainResource(); |
| 1398 } | 1410 } |
| 1399 | 1411 |
| 1400 void FrameLoader::applyUserAgent(ResourceRequest& request) | 1412 void FrameLoader::applyUserAgent(ResourceRequest& request) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 // FIXME: We need a way to propagate insecure requests policy flags to | 1562 // FIXME: We need a way to propagate insecure requests policy flags to |
| 1551 // out-of-process frames. For now, we'll always use default behavior. | 1563 // out-of-process frames. For now, we'll always use default behavior. |
| 1552 if (!parentFrame->isLocalFrame()) | 1564 if (!parentFrame->isLocalFrame()) |
| 1553 return nullptr; | 1565 return nullptr; |
| 1554 | 1566 |
| 1555 ASSERT(toLocalFrame(parentFrame)->document()); | 1567 ASSERT(toLocalFrame(parentFrame)->document()); |
| 1556 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; | 1568 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; |
| 1557 } | 1569 } |
| 1558 | 1570 |
| 1559 } // namespace blink | 1571 } // namespace blink |
| OLD | NEW |