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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 visitor->trace(m_documentLoader); | 187 visitor->trace(m_documentLoader); |
188 visitor->trace(m_provisionalDocumentLoader); | 188 visitor->trace(m_provisionalDocumentLoader); |
189 visitor->trace(m_currentItem); | 189 visitor->trace(m_currentItem); |
190 visitor->trace(m_provisionalItem); | 190 visitor->trace(m_provisionalItem); |
191 visitor->trace(m_deferredHistoryLoad); | 191 visitor->trace(m_deferredHistoryLoad); |
192 } | 192 } |
193 | 193 |
194 void FrameLoader::init() | 194 void FrameLoader::init() |
195 { | 195 { |
196 // init() may dispatch JS events, so protect a reference to m_frame. | 196 // init() may dispatch JS events, so protect a reference to m_frame. |
197 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 197 RawPtr<LocalFrame> protect(m_frame.get()); |
198 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); | 198 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); |
199 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 199 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
200 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); | 200 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); |
201 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); | 201 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); |
202 m_provisionalDocumentLoader->startLoadingMainResource(); | 202 m_provisionalDocumentLoader->startLoadingMainResource(); |
203 m_frame->document()->cancelParsing(); | 203 m_frame->document()->cancelParsing(); |
204 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); | 204 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); |
205 } | 205 } |
206 | 206 |
207 FrameLoaderClient* FrameLoader::client() const | 207 FrameLoaderClient* FrameLoader::client() const |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // This is only called by ScriptController::executeScriptIfJavaScriptURL | 317 // This is only called by ScriptController::executeScriptIfJavaScriptURL |
318 // and always contains the result of evaluating a javascript: url. | 318 // and always contains the result of evaluating a javascript: url. |
319 // This is the <iframe src="javascript:'html'"> case. | 319 // This is the <iframe src="javascript:'html'"> case. |
320 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc
e, Document* ownerDocument) | 320 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc
e, Document* ownerDocument) |
321 { | 321 { |
322 if (!m_frame->document()->loader() || m_frame->document()->pageDismissalEven
tBeingDispatched() != Document::NoDismissal) | 322 if (!m_frame->document()->loader() || m_frame->document()->pageDismissalEven
tBeingDispatched() != Document::NoDismissal) |
323 return; | 323 return; |
324 | 324 |
325 // DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL can cause the
DocumentLoader to get deref'ed and possible destroyed, | 325 // DocumentLoader::replaceDocumentWhileExecutingJavaScriptURL can cause the
DocumentLoader to get deref'ed and possible destroyed, |
326 // so protect it with a RefPtr. | 326 // so protect it with a RefPtr. |
327 RefPtrWillBeRawPtr<DocumentLoader> documentLoader(m_frame->document()->loade
r()); | 327 RawPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); |
328 | 328 |
329 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc
riptURL); | 329 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc
riptURL); |
330 | 330 |
331 // Prepare a DocumentInit before clearing the frame, because it may need to | 331 // Prepare a DocumentInit before clearing the frame, because it may need to |
332 // inherit an aliased security context. | 332 // inherit an aliased security context. |
333 DocumentInit init(ownerDocument, m_frame->document()->url(), m_frame); | 333 DocumentInit init(ownerDocument, m_frame->document()->url(), m_frame); |
334 init.withNewRegistrationContext(); | 334 init.withNewRegistrationContext(); |
335 | 335 |
336 stopAllLoaders(); | 336 stopAllLoaders(); |
337 // Don't allow any new child frames to load in this frame: attaching a new | 337 // Don't allow any new child frames to load in this frame: attaching a new |
(...skipping 16 matching lines...) Expand all Loading... |
354 void FrameLoader::receivedMainResourceRedirect(const KURL& newURL) | 354 void FrameLoader::receivedMainResourceRedirect(const KURL& newURL) |
355 { | 355 { |
356 client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); | 356 client()->dispatchDidReceiveServerRedirectForProvisionalLoad(); |
357 // If a back/forward navigation redirects cross-origin, don't reuse any stat
e from the HistoryItem. | 357 // If a back/forward navigation redirects cross-origin, don't reuse any stat
e from the HistoryItem. |
358 if (m_provisionalItem && !SecurityOrigin::create(m_provisionalItem->url())->
isSameSchemeHostPort(SecurityOrigin::create(newURL).get())) | 358 if (m_provisionalItem && !SecurityOrigin::create(m_provisionalItem->url())->
isSameSchemeHostPort(SecurityOrigin::create(newURL).get())) |
359 m_provisionalItem.clear(); | 359 m_provisionalItem.clear(); |
360 } | 360 } |
361 | 361 |
362 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, HistoryNavigationType navigationType) | 362 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, HistoryNavigationType navigationType) |
363 { | 363 { |
364 RefPtrWillBeRawPtr<HistoryItem> oldItem = m_currentItem; | 364 RawPtr<HistoryItem> oldItem = m_currentItem; |
365 if (historyCommitType == BackForwardCommit && m_provisionalItem) | 365 if (historyCommitType == BackForwardCommit && m_provisionalItem) |
366 m_currentItem = m_provisionalItem.release(); | 366 m_currentItem = m_provisionalItem.release(); |
367 else | 367 else |
368 m_currentItem = HistoryItem::create(); | 368 m_currentItem = HistoryItem::create(); |
369 m_currentItem->setURL(m_documentLoader->urlForHistory()); | 369 m_currentItem->setURL(m_documentLoader->urlForHistory()); |
370 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); | 370 m_currentItem->setDocumentState(m_frame->document()->formElementsState()); |
371 m_currentItem->setTarget(m_frame->tree().uniqueName()); | 371 m_currentItem->setTarget(m_frame->tree().uniqueName()); |
372 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader
->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request
().httpReferrer())); | 372 m_currentItem->setReferrer(SecurityPolicy::generateReferrer(m_documentLoader
->request().getReferrerPolicy(), m_currentItem->url(), m_documentLoader->request
().httpReferrer())); |
373 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); | 373 m_currentItem->setFormInfoFromRequest(m_documentLoader->request()); |
374 | 374 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 | 492 |
493 void FrameLoader::finishedParsing() | 493 void FrameLoader::finishedParsing() |
494 { | 494 { |
495 if (m_stateMachine.creatingInitialEmptyDocument()) | 495 if (m_stateMachine.creatingInitialEmptyDocument()) |
496 return; | 496 return; |
497 | 497 |
498 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves | 498 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves |
499 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. | 499 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. |
500 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. | 500 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. |
501 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul
lptr); | 501 RawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nullptr); |
502 | 502 |
503 m_progressTracker->finishedParsing(); | 503 m_progressTracker->finishedParsing(); |
504 | 504 |
505 if (client()) { | 505 if (client()) { |
506 ScriptForbiddenScope forbidScripts; | 506 ScriptForbiddenScope forbidScripts; |
507 client()->dispatchDidFinishDocumentLoad(); | 507 client()->dispatchDidFinishDocumentLoad(); |
508 } | 508 } |
509 | 509 |
510 if (client()) | 510 if (client()) |
511 client()->runScriptsAtDocumentReady(m_documentLoader ? m_documentLoader-
>isCommittedButEmpty() : true); | 511 client()->runScriptsAtDocumentReady(m_documentLoader ? m_documentLoader-
>isCommittedButEmpty() : true); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 // FIXME: We might have already sent stop notifications and be re-completing
. | 579 // FIXME: We might have already sent stop notifications and be re-completing
. |
580 if (!frame->isLoading()) | 580 if (!frame->isLoading()) |
581 return false; | 581 return false; |
582 // Only send didStopLoading() if there are no navigations in progress at all
, | 582 // Only send didStopLoading() if there are no navigations in progress at all
, |
583 // whether committed, provisional, or pending. | 583 // whether committed, provisional, or pending. |
584 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load
er().provisionalDocumentLoader() && !frame->loader().client()->hasPendingNavigat
ion(); | 584 return frame->loader().documentLoader()->sentDidFinishLoad() && !frame->load
er().provisionalDocumentLoader() && !frame->loader().client()->hasPendingNavigat
ion(); |
585 } | 585 } |
586 | 586 |
587 void FrameLoader::checkCompleted() | 587 void FrameLoader::checkCompleted() |
588 { | 588 { |
589 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 589 RawPtr<LocalFrame> protect(m_frame.get()); |
590 if (!shouldComplete(m_frame->document())) | 590 if (!shouldComplete(m_frame->document())) |
591 return; | 591 return; |
592 | 592 |
593 // OK, completed. | 593 // OK, completed. |
594 m_frame->document()->setReadyState(Document::Complete); | 594 m_frame->document()->setReadyState(Document::Complete); |
595 if (m_frame->document()->loadEventStillNeeded()) | 595 if (m_frame->document()->loadEventStillNeeded()) |
596 m_frame->document()->implicitClose(); | 596 m_frame->document()->implicitClose(); |
597 | 597 |
598 m_frame->navigationScheduler().startTimer(); | 598 m_frame->navigationScheduler().startTimer(); |
599 | 599 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
692 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { | 692 if (sameDocumentNavigationSource == SameDocumentNavigationHistoryApi) { |
693 m_currentItem->setStateObject(data); | 693 m_currentItem->setStateObject(data); |
694 m_currentItem->setScrollRestorationType(scrollRestorationType); | 694 m_currentItem->setScrollRestorationType(scrollRestorationType); |
695 } | 695 } |
696 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); | 696 client()->dispatchDidNavigateWithinPage(m_currentItem.get(), historyCommitTy
pe); |
697 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 697 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
698 if (m_frame->document()->loadEventFinished()) | 698 if (m_frame->document()->loadEventFinished()) |
699 client()->didStopLoading(); | 699 client()->didStopLoading(); |
700 } | 700 } |
701 | 701 |
702 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
r) | 702 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) |
703 { | 703 { |
704 if (!loader) | 704 if (!loader) |
705 return; | 705 return; |
706 | 706 |
707 loader->detachFromFrame(); | 707 loader->detachFromFrame(); |
708 loader = nullptr; | 708 loader = nullptr; |
709 } | 709 } |
710 | 710 |
711 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) | 711 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) |
712 { | 712 { |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent-
>shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); | 885 navigationPolicyFromMouseEvent(0, gestureEvent->ctrlKey(), gestureEvent-
>shiftKey(), gestureEvent->altKey(), gestureEvent->metaKey(), &policy); |
886 } | 886 } |
887 return policy; | 887 return policy; |
888 } | 888 } |
889 | 889 |
890 void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram
eLoadType, | 890 void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram
eLoadType, |
891 HistoryItem* historyItem, HistoryLoadType historyLoadType) | 891 HistoryItem* historyItem, HistoryLoadType historyLoadType) |
892 { | 892 { |
893 ASSERT(m_frame->document()); | 893 ASSERT(m_frame->document()); |
894 | 894 |
895 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 895 RawPtr<LocalFrame> protect(m_frame.get()); |
896 | 896 |
897 if (m_inStopAllLoaders) | 897 if (m_inStopAllLoaders) |
898 return; | 898 return; |
899 | 899 |
900 if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType)
) { | 900 if (m_frame->page()->defersLoading() && isBackForwardLoadType(frameLoadType)
) { |
901 m_deferredHistoryLoad = DeferredHistoryLoad::create(passedRequest.resour
ceRequest(), historyItem, frameLoadType, historyLoadType); | 901 m_deferredHistoryLoad = DeferredHistoryLoad::create(passedRequest.resour
ceRequest(), historyItem, frameLoadType, historyLoadType); |
902 return; | 902 return; |
903 } | 903 } |
904 | 904 |
905 FrameLoadRequest request(passedRequest); | 905 FrameLoadRequest request(passedRequest); |
906 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing
UserGesture()); | 906 request.resourceRequest().setHasUserGesture(UserGestureIndicator::processing
UserGesture()); |
907 | 907 |
908 if (!prepareRequestForThisFrame(request)) | 908 if (!prepareRequestForThisFrame(request)) |
909 return; | 909 return; |
910 | 910 |
911 RefPtrWillBeRawPtr<Frame> targetFrame = request.form() ? nullptr : m_frame->
findFrameForNavigation(AtomicString(request.frameName()), *m_frame); | 911 RawPtr<Frame> targetFrame = request.form() ? nullptr : m_frame->findFrameFor
Navigation(AtomicString(request.frameName()), *m_frame); |
912 | 912 |
913 if (isBackForwardLoadType(frameLoadType)) { | 913 if (isBackForwardLoadType(frameLoadType)) { |
914 ASSERT(historyItem); | 914 ASSERT(historyItem); |
915 m_provisionalItem = historyItem; | 915 m_provisionalItem = historyItem; |
916 } | 916 } |
917 | 917 |
918 if (targetFrame && targetFrame.get() != m_frame) { | 918 if (targetFrame && targetFrame.get() != m_frame) { |
919 bool wasInSamePage = targetFrame->page() == m_frame->page(); | 919 bool wasInSamePage = targetFrame->page() == m_frame->page(); |
920 | 920 |
921 request.setFrameName("_self"); | 921 request.setFrameName("_self"); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 void FrameLoader::stopAllLoaders() | 990 void FrameLoader::stopAllLoaders() |
991 { | 991 { |
992 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 992 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
993 return; | 993 return; |
994 | 994 |
995 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. | 995 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
996 if (m_inStopAllLoaders) | 996 if (m_inStopAllLoaders) |
997 return; | 997 return; |
998 | 998 |
999 // Stopping a document loader can blow away the frame from underneath. | 999 // Stopping a document loader can blow away the frame from underneath. |
1000 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1000 RawPtr<LocalFrame> protect(m_frame.get()); |
1001 | 1001 |
1002 m_inStopAllLoaders = true; | 1002 m_inStopAllLoaders = true; |
1003 | 1003 |
1004 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { | 1004 for (RawPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) { |
1005 if (child->isLocalFrame()) | 1005 if (child->isLocalFrame()) |
1006 toLocalFrame(child.get())->loader().stopAllLoaders(); | 1006 toLocalFrame(child.get())->loader().stopAllLoaders(); |
1007 } | 1007 } |
1008 | 1008 |
1009 m_frame->document()->suppressLoadEvent(); | 1009 m_frame->document()->suppressLoadEvent(); |
1010 if (m_documentLoader) | 1010 if (m_documentLoader) |
1011 m_documentLoader->fetcher()->stopFetching(); | 1011 m_documentLoader->fetcher()->stopFetching(); |
1012 m_frame->document()->cancelParsing(); | 1012 m_frame->document()->cancelParsing(); |
1013 if (!m_protectProvisionalLoader) | 1013 if (!m_protectProvisionalLoader) |
1014 detachDocumentLoader(m_provisionalDocumentLoader); | 1014 detachDocumentLoader(m_provisionalDocumentLoader); |
(...skipping 30 matching lines...) Expand all Loading... |
1045 { | 1045 { |
1046 if (m_didAccessInitialDocumentTimer.isActive()) { | 1046 if (m_didAccessInitialDocumentTimer.isActive()) { |
1047 m_didAccessInitialDocumentTimer.stop(); | 1047 m_didAccessInitialDocumentTimer.stop(); |
1048 didAccessInitialDocumentTimerFired(0); | 1048 didAccessInitialDocumentTimerFired(0); |
1049 } | 1049 } |
1050 } | 1050 } |
1051 | 1051 |
1052 bool FrameLoader::prepareForCommit() | 1052 bool FrameLoader::prepareForCommit() |
1053 { | 1053 { |
1054 PluginScriptForbiddenScope forbidPluginDestructorScripting; | 1054 PluginScriptForbiddenScope forbidPluginDestructorScripting; |
1055 RefPtrWillBeRawPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; | 1055 RawPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; |
1056 | 1056 |
1057 if (m_frame->document()) { | 1057 if (m_frame->document()) { |
1058 unsigned nodeCount = 0; | 1058 unsigned nodeCount = 0; |
1059 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext()
) { | 1059 for (Frame* frame = m_frame; frame; frame = frame->tree().traverseNext()
) { |
1060 if (frame->isLocalFrame()) { | 1060 if (frame->isLocalFrame()) { |
1061 LocalFrame* localFrame = toLocalFrame(frame); | 1061 LocalFrame* localFrame = toLocalFrame(frame); |
1062 nodeCount += localFrame->document()->nodeCount(); | 1062 nodeCount += localFrame->document()->nodeCount(); |
1063 } | 1063 } |
1064 } | 1064 } |
1065 unsigned totalNodeCount = InstanceCounters::counterValue(InstanceCounter
s::NodeCounter); | 1065 unsigned totalNodeCount = InstanceCounters::counterValue(InstanceCounter
s::NodeCounter); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 if (m_frame->document()) | 1101 if (m_frame->document()) |
1102 m_frame->document()->detach(); | 1102 m_frame->document()->detach(); |
1103 m_documentLoader = m_provisionalDocumentLoader.release(); | 1103 m_documentLoader = m_provisionalDocumentLoader.release(); |
1104 | 1104 |
1105 return true; | 1105 return true; |
1106 } | 1106 } |
1107 | 1107 |
1108 void FrameLoader::commitProvisionalLoad() | 1108 void FrameLoader::commitProvisionalLoad() |
1109 { | 1109 { |
1110 ASSERT(client()->hasWebView()); | 1110 ASSERT(client()->hasWebView()); |
1111 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1111 RawPtr<LocalFrame> protect(m_frame.get()); |
1112 | 1112 |
1113 // Check if the destination page is allowed to access the previous page's ti
ming information. | 1113 // Check if the destination page is allowed to access the previous page's ti
ming information. |
1114 if (m_frame->document()) { | 1114 if (m_frame->document()) { |
1115 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(m_provisi
onalDocumentLoader->request().url()); | 1115 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(m_provisi
onalDocumentLoader->request().url()); |
1116 m_provisionalDocumentLoader->timing().setHasSameOriginAsPreviousDocument
(securityOrigin->canRequest(m_frame->document()->url())); | 1116 m_provisionalDocumentLoader->timing().setHasSameOriginAsPreviousDocument
(securityOrigin->canRequest(m_frame->document()->url())); |
1117 } | 1117 } |
1118 | 1118 |
1119 if (!prepareForCommit()) | 1119 if (!prepareForCommit()) |
1120 return; | 1120 return; |
1121 | 1121 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 toLocalFrame(parent)->loader().scheduleCheckCompleted(); | 1229 toLocalFrame(parent)->loader().scheduleCheckCompleted(); |
1230 if (m_progressTracker) { | 1230 if (m_progressTracker) { |
1231 m_progressTracker->dispose(); | 1231 m_progressTracker->dispose(); |
1232 m_progressTracker.clear(); | 1232 m_progressTracker.clear(); |
1233 } | 1233 } |
1234 } | 1234 } |
1235 | 1235 |
1236 void FrameLoader::loadFailed(DocumentLoader* loader, const ResourceError& error) | 1236 void FrameLoader::loadFailed(DocumentLoader* loader, const ResourceError& error) |
1237 { | 1237 { |
1238 // Retain because the stop may release the last reference to it. | 1238 // Retain because the stop may release the last reference to it. |
1239 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1239 RawPtr<LocalFrame> protect(m_frame.get()); |
1240 RefPtrWillBeRawPtr<DocumentLoader> protectDocumentLoader(loader); | 1240 RawPtr<DocumentLoader> protectDocumentLoader(loader); |
1241 | 1241 |
1242 if (!error.isCancellation() && m_frame->owner()) { | 1242 if (!error.isCancellation() && m_frame->owner()) { |
1243 // FIXME: For now, fallback content doesn't work cross process. | 1243 // FIXME: For now, fallback content doesn't work cross process. |
1244 if (m_frame->owner()->isLocal()) | 1244 if (m_frame->owner()->isLocal()) |
1245 m_frame->deprecatedLocalOwner()->renderFallbackContent(); | 1245 m_frame->deprecatedLocalOwner()->renderFallbackContent(); |
1246 } | 1246 } |
1247 | 1247 |
1248 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); | 1248 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); |
1249 if (loader == m_provisionalDocumentLoader) { | 1249 if (loader == m_provisionalDocumentLoader) { |
1250 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); | 1250 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); |
(...skipping 30 matching lines...) Expand all Loading... |
1281 && !m_frame->document()->isFrameSet(); | 1281 && !m_frame->document()->isFrameSet(); |
1282 } | 1282 } |
1283 | 1283 |
1284 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) | 1284 void FrameLoader::processFragment(const KURL& url, LoadStartType loadStartType) |
1285 { | 1285 { |
1286 FrameView* view = m_frame->view(); | 1286 FrameView* view = m_frame->view(); |
1287 if (!view) | 1287 if (!view) |
1288 return; | 1288 return; |
1289 | 1289 |
1290 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. | 1290 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. |
1291 RefPtrWillBeRawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_fr
ame->findUnsafeParentScrollPropagationBoundary() : 0; | 1291 RawPtr<Frame> boundaryFrame = url.hasFragmentIdentifier() ? m_frame->findUns
afeParentScrollPropagationBoundary() : 0; |
1292 | 1292 |
1293 // FIXME: Handle RemoteFrames | 1293 // FIXME: Handle RemoteFrames |
1294 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1294 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
1295 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(false); | 1295 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(false); |
1296 | 1296 |
1297 // If scroll position is restored from history fragment then we should not o
verride it unless | 1297 // If scroll position is restored from history fragment then we should not o
verride it unless |
1298 // this is a same document reload. | 1298 // this is a same document reload. |
1299 bool shouldScrollToFragment = (loadStartType == NavigationWithinSameDocument
&& !isBackForwardLoadType(m_loadType)) | 1299 bool shouldScrollToFragment = (loadStartType == NavigationWithinSameDocument
&& !isBackForwardLoadType(m_loadType)) |
1300 || (documentLoader() && !documentLoader()->initialScrollState().didResto
reFromHistory); | 1300 || (documentLoader() && !documentLoader()->initialScrollState().didResto
reFromHistory); |
1301 | 1301 |
1302 view->processUrlFragment(url, shouldScrollToFragment ? | 1302 view->processUrlFragment(url, shouldScrollToFragment ? |
1303 FrameView::UrlFragmentScroll : FrameView::UrlFragmentDontScroll); | 1303 FrameView::UrlFragmentScroll : FrameView::UrlFragmentDontScroll); |
1304 | 1304 |
1305 if (boundaryFrame && boundaryFrame->isLocalFrame()) | 1305 if (boundaryFrame && boundaryFrame->isLocalFrame()) |
1306 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(true); | 1306 toLocalFrame(boundaryFrame.get())->view()->setSafeToPropagateScrollToPar
ent(true); |
1307 } | 1307 } |
1308 | 1308 |
1309 bool FrameLoader::shouldClose(bool isReload) | 1309 bool FrameLoader::shouldClose(bool isReload) |
1310 { | 1310 { |
1311 Page* page = m_frame->page(); | 1311 Page* page = m_frame->page(); |
1312 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel()) | 1312 if (!page || !page->chromeClient().canOpenBeforeUnloadConfirmPanel()) |
1313 return true; | 1313 return true; |
1314 | 1314 |
1315 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame | 1315 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame |
1316 WillBeHeapVector<RefPtrWillBeMember<LocalFrame>> targetFrames; | 1316 HeapVector<Member<LocalFrame>> targetFrames; |
1317 targetFrames.append(m_frame); | 1317 targetFrames.append(m_frame); |
1318 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { | 1318 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { |
1319 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. | 1319 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. |
1320 if (child->isLocalFrame()) | 1320 if (child->isLocalFrame()) |
1321 targetFrames.append(toLocalFrame(child)); | 1321 targetFrames.append(toLocalFrame(child)); |
1322 } | 1322 } |
1323 | 1323 |
1324 bool shouldClose = false; | 1324 bool shouldClose = false; |
1325 { | 1325 { |
1326 NavigationDisablerForBeforeUnload navigationDisabler; | 1326 NavigationDisablerForBeforeUnload navigationDisabler; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi
ngUserGesture()) | 1377 if (!LocalDOMWindow::allowPopUp(*m_frame) && !UserGestureIndicator::processi
ngUserGesture()) |
1378 return false; | 1378 return false; |
1379 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); | 1379 client()->loadURLExternally(request, policy, String(), replacesCurrentHistor
yItem); |
1380 return false; | 1380 return false; |
1381 } | 1381 } |
1382 | 1382 |
1383 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) | 1383 void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest, FrameLoadType ty
pe, NavigationPolicy navigationPolicy) |
1384 { | 1384 { |
1385 ASSERT(client()->hasWebView()); | 1385 ASSERT(client()->hasWebView()); |
1386 // Lots of things in this function can detach the LocalFrame (stopAllLoaders
, beforeunload handlers, etc.), so protect the frame. | 1386 // Lots of things in this function can detach the LocalFrame (stopAllLoaders
, beforeunload handlers, etc.), so protect the frame. |
1387 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1387 RawPtr<LocalFrame> protect(m_frame.get()); |
1388 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 1388 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
1389 return; | 1389 return; |
1390 | 1390 |
1391 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); | 1391 NavigationType navigationType = determineNavigationType(type, frameLoadReque
st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri
ggeringEvent()); |
1392 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); | 1392 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext
FromNavigationType(navigationType)); |
1393 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); | 1393 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web
URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); |
1394 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1394 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
1395 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na
vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo
adRequest.clientRedirect() == ClientRedirect)) | 1395 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD
ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na
vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo
adRequest.clientRedirect() == ClientRedirect)) |
1396 return; | 1396 return; |
1397 if (!shouldClose(navigationType == NavigationTypeReload)) | 1397 if (!shouldClose(navigationType == NavigationTypeReload)) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 break; | 1460 break; |
1461 } | 1461 } |
1462 } | 1462 } |
1463 return false; | 1463 return false; |
1464 } | 1464 } |
1465 case XFrameOptionsDeny: | 1465 case XFrameOptionsDeny: |
1466 return true; | 1466 return true; |
1467 case XFrameOptionsAllowAll: | 1467 case XFrameOptionsAllowAll: |
1468 return false; | 1468 return false; |
1469 case XFrameOptionsConflict: { | 1469 case XFrameOptionsConflict: { |
1470 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea
te(JSMessageSource, ErrorMessageLevel, "Multiple 'X-Frame-Options' headers with
conflicting values ('" + content + "') encountered when loading '" + url.elidedS
tring() + "'. Falling back to 'DENY'."); | 1470 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessage
Source, ErrorMessageLevel, "Multiple 'X-Frame-Options' headers with conflicting
values ('" + content + "') encountered when loading '" + url.elidedString() + "'
. Falling back to 'DENY'."); |
1471 consoleMessage->setRequestIdentifier(requestIdentifier); | 1471 consoleMessage->setRequestIdentifier(requestIdentifier); |
1472 m_frame->document()->addConsoleMessage(consoleMessage.release()); | 1472 m_frame->document()->addConsoleMessage(consoleMessage.release()); |
1473 return true; | 1473 return true; |
1474 } | 1474 } |
1475 case XFrameOptionsInvalid: { | 1475 case XFrameOptionsInvalid: { |
1476 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::crea
te(JSMessageSource, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encount
ered when loading '" + url.elidedString() + "': '" + content + "' is not a recog
nized directive. The header will be ignored."); | 1476 RawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(JSMessage
Source, ErrorMessageLevel, "Invalid 'X-Frame-Options' header encountered when lo
ading '" + url.elidedString() + "': '" + content + "' is not a recognized direct
ive. The header will be ignored."); |
1477 consoleMessage->setRequestIdentifier(requestIdentifier); | 1477 consoleMessage->setRequestIdentifier(requestIdentifier); |
1478 m_frame->document()->addConsoleMessage(consoleMessage.release()); | 1478 m_frame->document()->addConsoleMessage(consoleMessage.release()); |
1479 return false; | 1479 return false; |
1480 } | 1480 } |
1481 default: | 1481 default: |
1482 ASSERT_NOT_REACHED(); | 1482 ASSERT_NOT_REACHED(); |
1483 return false; | 1483 return false; |
1484 } | 1484 } |
1485 } | 1485 } |
1486 | 1486 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 // FIXME: We need a way to propagate insecure requests policy flags to | 1584 // FIXME: We need a way to propagate insecure requests policy flags to |
1585 // out-of-process frames. For now, we'll always use default behavior. | 1585 // out-of-process frames. For now, we'll always use default behavior. |
1586 if (!parentFrame->isLocalFrame()) | 1586 if (!parentFrame->isLocalFrame()) |
1587 return nullptr; | 1587 return nullptr; |
1588 | 1588 |
1589 ASSERT(toLocalFrame(parentFrame)->document()); | 1589 ASSERT(toLocalFrame(parentFrame)->document()); |
1590 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1590 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
1591 } | 1591 } |
1592 | 1592 |
1593 } // namespace blink | 1593 } // namespace blink |
OLD | NEW |