| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "core/dom/Element.h" | 43 #include "core/dom/Element.h" |
| 44 #include "core/dom/ViewportDescription.h" | 44 #include "core/dom/ViewportDescription.h" |
| 45 #include "core/editing/Editor.h" | 45 #include "core/editing/Editor.h" |
| 46 #include "core/editing/UndoStack.h" | 46 #include "core/editing/UndoStack.h" |
| 47 #include "core/events/PageTransitionEvent.h" | 47 #include "core/events/PageTransitionEvent.h" |
| 48 #include "core/fetch/FetchContext.h" | 48 #include "core/fetch/FetchContext.h" |
| 49 #include "core/fetch/ResourceFetcher.h" | 49 #include "core/fetch/ResourceFetcher.h" |
| 50 #include "core/fetch/ResourceLoader.h" | 50 #include "core/fetch/ResourceLoader.h" |
| 51 #include "core/frame/LocalDOMWindow.h" | 51 #include "core/frame/LocalDOMWindow.h" |
| 52 #include "core/frame/FrameHost.h" | 52 #include "core/frame/FrameHost.h" |
| 53 #include "core/frame/FrameProtector.h" |
| 53 #include "core/frame/FrameView.h" | 54 #include "core/frame/FrameView.h" |
| 54 #include "core/frame/LocalFrame.h" | 55 #include "core/frame/LocalFrame.h" |
| 55 #include "core/frame/PinchViewport.h" | 56 #include "core/frame/PinchViewport.h" |
| 56 #include "core/frame/csp/ContentSecurityPolicy.h" | 57 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 57 #include "core/html/HTMLFormElement.h" | 58 #include "core/html/HTMLFormElement.h" |
| 58 #include "core/html/HTMLFrameOwnerElement.h" | 59 #include "core/html/HTMLFrameOwnerElement.h" |
| 59 #include "core/html/parser/HTMLParserIdioms.h" | 60 #include "core/html/parser/HTMLParserIdioms.h" |
| 60 #include "core/inspector/ConsoleMessage.h" | 61 #include "core/inspector/ConsoleMessage.h" |
| 61 #include "core/inspector/InspectorController.h" | 62 #include "core/inspector/InspectorController.h" |
| 62 #include "core/inspector/InspectorInstrumentation.h" | 63 #include "core/inspector/InspectorInstrumentation.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 , m_didAccessInitialDocument(false) | 124 , m_didAccessInitialDocument(false) |
| 124 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) | 125 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) |
| 125 , m_forcedSandboxFlags(SandboxNone) | 126 , m_forcedSandboxFlags(SandboxNone) |
| 126 { | 127 { |
| 127 } | 128 } |
| 128 | 129 |
| 129 FrameLoader::~FrameLoader() | 130 FrameLoader::~FrameLoader() |
| 130 { | 131 { |
| 131 } | 132 } |
| 132 | 133 |
| 134 void FrameLoader::trace(Visitor* visitor) |
| 135 { |
| 136 visitor->trace(m_frame); |
| 137 visitor->trace(m_fetchContext); |
| 138 } |
| 139 |
| 133 void FrameLoader::init() | 140 void FrameLoader::init() |
| 134 { | 141 { |
| 135 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); | 142 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); |
| 136 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 143 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
| 137 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); | 144 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); |
| 138 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); | 145 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); |
| 139 m_provisionalDocumentLoader->startLoadingMainResource(); | 146 m_provisionalDocumentLoader->startLoadingMainResource(); |
| 140 m_frame->document()->cancelParsing(); | 147 m_frame->document()->cancelParsing(); |
| 141 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); | 148 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); |
| 142 } | 149 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 242 |
| 236 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results | 243 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results |
| 237 // from a subsequent window.document.open / window.document.write call. | 244 // from a subsequent window.document.open / window.document.write call. |
| 238 // Canceling redirection here works for all cases because document.open | 245 // Canceling redirection here works for all cases because document.open |
| 239 // implicitly precedes document.write. | 246 // implicitly precedes document.write. |
| 240 m_frame->navigationScheduler().cancel(); | 247 m_frame->navigationScheduler().cancel(); |
| 241 } | 248 } |
| 242 | 249 |
| 243 void FrameLoader::clear() | 250 void FrameLoader::clear() |
| 244 { | 251 { |
| 252 // clear() is called during (Local)Frame finalization and when creating |
| 253 // a new Document within it (DocumentLoader::createWriterFor().) |
| 254 |
| 245 if (m_stateMachine.creatingInitialEmptyDocument()) | 255 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 246 return; | 256 return; |
| 247 | 257 |
| 248 m_frame->editor().clear(); | 258 m_frame->editor().clear(); |
| 249 m_frame->document()->cancelParsing(); | 259 m_frame->document()->cancelParsing(); |
| 250 m_frame->document()->prepareForDestruction(); | 260 m_frame->document()->prepareForDestruction(); |
| 251 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); | 261 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); |
| 252 | 262 |
| 253 m_frame->selection().prepareForDestruction(); | 263 m_frame->selection().prepareForDestruction(); |
| 254 m_frame->eventHandler().clear(); | 264 m_frame->eventHandler().clear(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT
ype); | 360 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT
ype); |
| 351 | 361 |
| 352 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); | 362 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); |
| 353 m_frame->page()->didCommitLoad(m_frame); | 363 m_frame->page()->didCommitLoad(m_frame); |
| 354 dispatchDidClearDocumentOfWindowObject(); | 364 dispatchDidClearDocumentOfWindowObject(); |
| 355 } | 365 } |
| 356 | 366 |
| 357 static void didFailContentSecurityPolicyCheck(FrameLoader* loader) | 367 static void didFailContentSecurityPolicyCheck(FrameLoader* loader) |
| 358 { | 368 { |
| 359 // load event and stopAllLoaders can detach the LocalFrame, so protect it. | 369 // load event and stopAllLoaders can detach the LocalFrame, so protect it. |
| 360 RefPtr<LocalFrame> frame(loader->frame()); | 370 LocalFrame* frame = loader->frame(); |
| 371 FrameProtector protect(frame); |
| 361 | 372 |
| 362 // Move the page to a unique origin, and cancel the load. | 373 // Move the page to a unique origin, and cancel the load. |
| 363 frame->document()->enforceSandboxFlags(SandboxOrigin); | 374 frame->document()->enforceSandboxFlags(SandboxOrigin); |
| 364 loader->stopAllLoaders(); | 375 loader->stopAllLoaders(); |
| 365 | 376 |
| 366 // Fire a load event, as timing attacks would otherwise reveal that the | 377 // Fire a load event, as timing attacks would otherwise reveal that the |
| 367 // frame was blocked. This way, it looks like every other cross-origin | 378 // frame was blocked. This way, it looks like every other cross-origin |
| 368 // page. | 379 // page. |
| 369 if (FrameOwner* frameOwner = frame->owner()) | 380 if (FrameOwner* frameOwner = frame->owner()) |
| 370 frameOwner->dispatchLoad(); | 381 frameOwner->dispatchLoad(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 } | 424 } |
| 414 | 425 |
| 415 void FrameLoader::finishedParsing() | 426 void FrameLoader::finishedParsing() |
| 416 { | 427 { |
| 417 if (m_stateMachine.creatingInitialEmptyDocument()) | 428 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 418 return; | 429 return; |
| 419 | 430 |
| 420 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves | 431 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves |
| 421 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. | 432 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. |
| 422 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. | 433 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. |
| 423 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; | 434 FrameProtector protect(m_frame->view() ? m_frame : nullptr); |
| 424 | 435 |
| 425 if (client()) | 436 if (client()) |
| 426 client()->dispatchDidFinishDocumentLoad(); | 437 client()->dispatchDidFinishDocumentLoad(); |
| 427 | 438 |
| 428 checkCompleted(); | 439 checkCompleted(); |
| 429 | 440 |
| 430 if (!m_frame->view()) | 441 if (!m_frame->view()) |
| 431 return; // We are being destroyed by something checkCompleted called. | 442 return; // We are being destroyed by something checkCompleted called. |
| 432 | 443 |
| 433 // Check if the scrollbars are really needed for the content. | 444 // Check if the scrollbars are really needed for the content. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 457 { | 468 { |
| 458 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent
()) { | 469 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent
()) { |
| 459 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa
dEventFinished()) | 470 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa
dEventFinished()) |
| 460 return false; | 471 return false; |
| 461 } | 472 } |
| 462 return true; | 473 return true; |
| 463 } | 474 } |
| 464 | 475 |
| 465 void FrameLoader::checkCompleted() | 476 void FrameLoader::checkCompleted() |
| 466 { | 477 { |
| 467 RefPtr<LocalFrame> protect(m_frame); | 478 FrameProtector protect(m_frame); |
| 468 | 479 |
| 469 if (m_frame->view()) | 480 if (m_frame->view()) |
| 470 m_frame->view()->handleLoadCompleted(); | 481 m_frame->view()->handleLoadCompleted(); |
| 471 | 482 |
| 472 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR
ealDocumentLoad()) | 483 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR
ealDocumentLoad()) |
| 473 return; | 484 return; |
| 474 | 485 |
| 475 // Are we still parsing? | 486 // Are we still parsing? |
| 476 if (m_frame->document()->parsing()) | 487 if (m_frame->document()->parsing()) |
| 477 return; | 488 return; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // We need to scroll to the fragment whether or not a hash change occurred,
since | 610 // We need to scroll to the fragment whether or not a hash change occurred,
since |
| 600 // the user might have scrolled since the previous navigation. | 611 // the user might have scrolled since the previous navigation. |
| 601 scrollToFragmentWithParentBoundary(url); | 612 scrollToFragmentWithParentBoundary(url); |
| 602 checkCompleted(); | 613 checkCompleted(); |
| 603 | 614 |
| 604 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri
ptValue::nullValue()); | 615 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri
ptValue::nullValue()); |
| 605 } | 616 } |
| 606 | 617 |
| 607 void FrameLoader::completed() | 618 void FrameLoader::completed() |
| 608 { | 619 { |
| 609 RefPtr<LocalFrame> protect(m_frame); | 620 FrameProtector protect(m_frame); |
| 610 | 621 |
| 611 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant;
descendant = descendant->tree().traverseNext(m_frame)) { | 622 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant;
descendant = descendant->tree().traverseNext(m_frame)) { |
| 612 if (descendant->isLocalFrame()) | 623 if (descendant->isLocalFrame()) |
| 613 toLocalFrame(descendant)->navigationScheduler().startTimer(); | 624 toLocalFrame(descendant)->navigationScheduler().startTimer(); |
| 614 } | 625 } |
| 615 | 626 |
| 616 Frame* parent = m_frame->tree().parent(); | 627 Frame* parent = m_frame->tree().parent(); |
| 617 if (parent && parent->isLocalFrame()) | 628 if (parent && parent->isLocalFrame()) |
| 618 toLocalFrame(parent)->loader().checkCompleted(); | 629 toLocalFrame(parent)->loader().checkCompleted(); |
| 619 | 630 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 return WebURLRequest::RequestContextInternal; | 734 return WebURLRequest::RequestContextInternal; |
| 724 } | 735 } |
| 725 ASSERT_NOT_REACHED(); | 736 ASSERT_NOT_REACHED(); |
| 726 return WebURLRequest::RequestContextHyperlink; | 737 return WebURLRequest::RequestContextHyperlink; |
| 727 } | 738 } |
| 728 | 739 |
| 729 void FrameLoader::load(const FrameLoadRequest& passedRequest) | 740 void FrameLoader::load(const FrameLoadRequest& passedRequest) |
| 730 { | 741 { |
| 731 ASSERT(m_frame->document()); | 742 ASSERT(m_frame->document()); |
| 732 | 743 |
| 733 RefPtr<LocalFrame> protect(m_frame); | 744 FrameProtector protect(m_frame); |
| 734 | 745 |
| 735 if (m_inStopAllLoaders) | 746 if (m_inStopAllLoaders) |
| 736 return; | 747 return; |
| 737 | 748 |
| 738 FrameLoadRequest request(passedRequest); | 749 FrameLoadRequest request(passedRequest); |
| 739 if (!prepareRequestForThisFrame(request)) | 750 if (!prepareRequestForThisFrame(request)) |
| 740 return; | 751 return; |
| 741 | 752 |
| 742 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig
ation(AtomicString(request.frameName()), request.formState() ? request.formState
()->sourceDocument() : m_frame->document()); | 753 LocalFrame* targetFrame = request.formState() ? 0 : findFrameForNavigation(A
tomicString(request.frameName()), request.formState() ? request.formState()->sou
rceDocument() : m_frame->document()); |
| 754 FrameProtector protectTarget(targetFrame); |
| 743 if (targetFrame && targetFrame != m_frame) { | 755 if (targetFrame && targetFrame != m_frame) { |
| 744 request.setFrameName("_self"); | 756 request.setFrameName("_self"); |
| 745 targetFrame->loader().load(request); | 757 targetFrame->loader().load(request); |
| 746 if (Page* page = targetFrame->page()) | 758 if (Page* page = targetFrame->page()) |
| 747 page->chrome().focus(); | 759 page->chrome().focus(); |
| 748 return; | 760 return; |
| 749 } | 761 } |
| 750 | 762 |
| 751 FrameLoadType newLoadType = determineFrameLoadType(request); | 763 FrameLoadType newLoadType = determineFrameLoadType(request); |
| 752 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); | 764 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); |
| 753 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte
xtUnspecified) | 765 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte
xtUnspecified) |
| 754 action.mutableResourceRequest().setRequestContext(determineRequestContex
tFromNavigationType(action.type())); | 766 action.mutableResourceRequest().setRequestContext(determineRequestContex
tFromNavigationType(action.type())); |
| 755 if (shouldOpenInNewWindow(targetFrame.get(), request, action)) { | 767 if (shouldOpenInNewWindow(targetFrame, request, action)) { |
| 756 if (action.policy() == NavigationPolicyDownload) | 768 if (action.policy() == NavigationPolicyDownload) |
| 757 client()->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); | 769 client()->loadURLExternally(action.resourceRequest(), NavigationPoli
cyDownload); |
| 758 else | 770 else |
| 759 createWindowForRequest(request, *m_frame, action.policy(), request.s
houldSendReferrer()); | 771 createWindowForRequest(request, *m_frame, action.policy(), request.s
houldSendReferrer()); |
| 760 return; | 772 return; |
| 761 } | 773 } |
| 762 | 774 |
| 763 const KURL& url = request.resourceRequest().url(); | 775 const KURL& url = request.resourceRequest().url(); |
| 764 if (!action.shouldOpenInNewWindow() && shouldPerformFragmentNavigation(reque
st.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) { | 776 if (!action.shouldOpenInNewWindow() && shouldPerformFragmentNavigation(reque
st.formState(), request.resourceRequest().httpMethod(), newLoadType, url)) { |
| 765 m_documentLoader->setTriggeringAction(action); | 777 m_documentLoader->setTriggeringAction(action); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 { | 857 { |
| 846 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 858 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
| 847 return; | 859 return; |
| 848 | 860 |
| 849 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. | 861 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
| 850 if (m_inStopAllLoaders) | 862 if (m_inStopAllLoaders) |
| 851 return; | 863 return; |
| 852 | 864 |
| 853 // Calling stopLoading() on the provisional document loader can blow away | 865 // Calling stopLoading() on the provisional document loader can blow away |
| 854 // the frame from underneath. | 866 // the frame from underneath. |
| 855 RefPtr<LocalFrame> protect(m_frame); | 867 FrameProtector protect(m_frame); |
| 856 | 868 |
| 857 m_inStopAllLoaders = true; | 869 m_inStopAllLoaders = true; |
| 858 | 870 |
| 859 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) { | 871 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { |
| 860 if (child->isLocalFrame()) | 872 if (child->isLocalFrame()) |
| 861 toLocalFrame(child.get())->loader().stopAllLoaders(); | 873 toLocalFrame(child.get())->loader().stopAllLoaders(); |
| 862 } | 874 } |
| 863 if (m_provisionalDocumentLoader) | 875 if (m_provisionalDocumentLoader) |
| 864 m_provisionalDocumentLoader->stopLoading(); | 876 m_provisionalDocumentLoader->stopLoading(); |
| 865 if (m_documentLoader) | 877 if (m_documentLoader) |
| 866 m_documentLoader->stopLoading(); | 878 m_documentLoader->stopLoading(); |
| 867 | 879 |
| 868 if (m_provisionalDocumentLoader) | 880 if (m_provisionalDocumentLoader) |
| 869 m_provisionalDocumentLoader->detachFromFrame(); | 881 m_provisionalDocumentLoader->detachFromFrame(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 if (m_provisionalDocumentLoader) | 919 if (m_provisionalDocumentLoader) |
| 908 return true; | 920 return true; |
| 909 return m_documentLoader && m_documentLoader->isLoading(); | 921 return m_documentLoader && m_documentLoader->isLoading(); |
| 910 } | 922 } |
| 911 | 923 |
| 912 void FrameLoader::commitProvisionalLoad() | 924 void FrameLoader::commitProvisionalLoad() |
| 913 { | 925 { |
| 914 ASSERT(client()->hasWebView()); | 926 ASSERT(client()->hasWebView()); |
| 915 ASSERT(m_state == FrameStateProvisional); | 927 ASSERT(m_state == FrameStateProvisional); |
| 916 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; | 928 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; |
| 917 RefPtr<LocalFrame> protect(m_frame); | 929 FrameProtector protect(m_frame); |
| 918 | 930 |
| 919 // Check if the destination page is allowed to access the previous page's ti
ming information. | 931 // Check if the destination page is allowed to access the previous page's ti
ming information. |
| 920 if (m_frame->document()) { | 932 if (m_frame->document()) { |
| 921 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ
est().url()); | 933 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ
est().url()); |
| 922 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq
uest(m_frame->document()->url())); | 934 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq
uest(m_frame->document()->url())); |
| 923 } | 935 } |
| 924 | 936 |
| 925 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary | 937 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary |
| 926 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, | 938 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, |
| 927 // or the two will stomp each other. | 939 // or the two will stomp each other. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 if (document->processingLoadEvent()) | 994 if (document->processingLoadEvent()) |
| 983 return false; | 995 return false; |
| 984 if (document->hasActiveParser()) | 996 if (document->hasActiveParser()) |
| 985 return false; | 997 return false; |
| 986 return true; | 998 return true; |
| 987 } | 999 } |
| 988 | 1000 |
| 989 bool FrameLoader::checkLoadCompleteForThisFrame() | 1001 bool FrameLoader::checkLoadCompleteForThisFrame() |
| 990 { | 1002 { |
| 991 ASSERT(client()->hasWebView()); | 1003 ASSERT(client()->hasWebView()); |
| 992 RefPtr<LocalFrame> protect(m_frame); | 1004 FrameProtector protect(m_frame); |
| 993 | 1005 |
| 994 bool allChildrenAreDoneLoading = true; | 1006 bool allChildrenAreDoneLoading = true; |
| 995 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) { | 1007 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { |
| 996 if (child->isLocalFrame()) | 1008 if (child->isLocalFrame()) |
| 997 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che
ckLoadCompleteForThisFrame(); | 1009 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che
ckLoadCompleteForThisFrame(); |
| 998 } | 1010 } |
| 999 | 1011 |
| 1000 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { | 1012 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { |
| 1001 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr
ror(); | 1013 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr
ror(); |
| 1002 if (error.isNull()) | 1014 if (error.isNull()) |
| 1003 return false; | 1015 return false; |
| 1004 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; | 1016 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; |
| 1005 client()->dispatchDidFailProvisionalLoad(error); | 1017 client()->dispatchDidFailProvisionalLoad(error); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 String FrameLoader::userAgent(const KURL& url) const | 1125 String FrameLoader::userAgent(const KURL& url) const |
| 1114 { | 1126 { |
| 1115 String userAgent = client()->userAgent(url); | 1127 String userAgent = client()->userAgent(url); |
| 1116 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); | 1128 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); |
| 1117 return userAgent; | 1129 return userAgent; |
| 1118 } | 1130 } |
| 1119 | 1131 |
| 1120 void FrameLoader::detachFromParent() | 1132 void FrameLoader::detachFromParent() |
| 1121 { | 1133 { |
| 1122 // The caller must protect a reference to m_frame. | 1134 // The caller must protect a reference to m_frame. |
| 1135 #if !ENABLE(OILPAN) |
| 1123 ASSERT(m_frame->refCount() > 1); | 1136 ASSERT(m_frame->refCount() > 1); |
| 1137 #endif |
| 1124 | 1138 |
| 1125 InspectorInstrumentation::frameDetachedFromParent(m_frame); | 1139 InspectorInstrumentation::frameDetachedFromParent(m_frame); |
| 1126 | 1140 |
| 1127 if (m_documentLoader) | 1141 if (m_documentLoader) |
| 1128 m_documentLoader->detachFromFrame(); | 1142 m_documentLoader->detachFromFrame(); |
| 1129 m_documentLoader = nullptr; | 1143 m_documentLoader = nullptr; |
| 1130 | 1144 |
| 1131 if (!client()) | 1145 if (!client()) |
| 1132 return; | 1146 return; |
| 1133 | 1147 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1167 // After this, we must no longer talk to the client since this clears | 1181 // After this, we must no longer talk to the client since this clears |
| 1168 // its owning reference back to our owning LocalFrame. | 1182 // its owning reference back to our owning LocalFrame. |
| 1169 client()->detachedFromParent(); | 1183 client()->detachedFromParent(); |
| 1170 m_frame->clearClient(); | 1184 m_frame->clearClient(); |
| 1171 } | 1185 } |
| 1172 } | 1186 } |
| 1173 | 1187 |
| 1174 void FrameLoader::receivedMainResourceError(const ResourceError& error) | 1188 void FrameLoader::receivedMainResourceError(const ResourceError& error) |
| 1175 { | 1189 { |
| 1176 // Retain because the stop may release the last reference to it. | 1190 // Retain because the stop may release the last reference to it. |
| 1177 RefPtr<LocalFrame> protect(m_frame); | 1191 FrameProtector protect(m_frame); |
| 1178 | 1192 |
| 1179 if (m_frame->document()->parser()) | 1193 if (m_frame->document()->parser()) |
| 1180 m_frame->document()->parser()->stopParsing(); | 1194 m_frame->document()->parser()->stopParsing(); |
| 1181 | 1195 |
| 1182 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some | 1196 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some |
| 1183 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). | 1197 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). |
| 1184 ResourceError c(ResourceError::cancelledError(KURL())); | 1198 ResourceError c(ResourceError::cancelledError(KURL())); |
| 1185 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->owner()) { | 1199 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->owner()) { |
| 1186 // FIXME: For now, fallback content doesn't work cross process. | 1200 // FIXME: For now, fallback content doesn't work cross process. |
| 1187 ASSERT(m_frame->owner()->isLocal()); | 1201 ASSERT(m_frame->owner()->isLocal()); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1209 && !m_frame->document()->isFrameSet(); | 1223 && !m_frame->document()->isFrameSet(); |
| 1210 } | 1224 } |
| 1211 | 1225 |
| 1212 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) | 1226 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) |
| 1213 { | 1227 { |
| 1214 FrameView* view = m_frame->view(); | 1228 FrameView* view = m_frame->view(); |
| 1215 if (!view) | 1229 if (!view) |
| 1216 return; | 1230 return; |
| 1217 | 1231 |
| 1218 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. | 1232 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. |
| 1219 RefPtr<LocalFrame> boundaryFrame(url.hasFragmentIdentifier() ? m_frame->docu
ment()->findUnsafeParentScrollPropagationBoundary() : 0); | 1233 LocalFrame* boundaryFrame = url.hasFragmentIdentifier() ? m_frame->document(
)->findUnsafeParentScrollPropagationBoundary() : 0; |
| 1234 FrameProtector protect(boundaryFrame); |
| 1220 | 1235 |
| 1221 if (boundaryFrame) | 1236 if (boundaryFrame) |
| 1222 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); | 1237 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); |
| 1223 | 1238 |
| 1224 view->scrollToFragment(url); | 1239 view->scrollToFragment(url); |
| 1225 | 1240 |
| 1226 if (boundaryFrame) | 1241 if (boundaryFrame) |
| 1227 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); | 1242 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); |
| 1228 } | 1243 } |
| 1229 | 1244 |
| 1230 bool FrameLoader::shouldClose() | 1245 bool FrameLoader::shouldClose() |
| 1231 { | 1246 { |
| 1232 Page* page = m_frame->page(); | 1247 Page* page = m_frame->page(); |
| 1233 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) | 1248 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) |
| 1234 return true; | 1249 return true; |
| 1235 | 1250 |
| 1236 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame | 1251 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame |
| 1237 Vector<RefPtr<LocalFrame> > targetFrames; | 1252 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames; |
| 1238 targetFrames.append(m_frame); | 1253 targetFrames.append(m_frame); |
| 1239 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { | 1254 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { |
| 1240 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. | 1255 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. |
| 1241 if (child->isLocalFrame()) | 1256 if (child->isLocalFrame()) |
| 1242 targetFrames.append(toLocalFrame(child)); | 1257 targetFrames.append(toLocalFrame(child)); |
| 1243 } | 1258 } |
| 1244 | 1259 |
| 1245 bool shouldClose = false; | 1260 bool shouldClose = false; |
| 1246 { | 1261 { |
| 1247 NavigationDisablerForBeforeUnload navigationDisabler; | 1262 NavigationDisablerForBeforeUnload navigationDisabler; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); | 1329 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); |
| 1315 else if (m_documentLoader) | 1330 else if (m_documentLoader) |
| 1316 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); | 1331 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); |
| 1317 | 1332 |
| 1318 | 1333 |
| 1319 bool isTransitionNavigation = false; | 1334 bool isTransitionNavigation = false; |
| 1320 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) | 1335 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) |
| 1321 isTransitionNavigation = dispatchNavigationTransitionData(); | 1336 isTransitionNavigation = dispatchNavigationTransitionData(); |
| 1322 | 1337 |
| 1323 // stopAllLoaders can detach the LocalFrame, so protect it. | 1338 // stopAllLoaders can detach the LocalFrame, so protect it. |
| 1324 RefPtr<LocalFrame> protect(m_frame); | 1339 FrameProtector protect(m_frame); |
| 1325 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { | 1340 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { |
| 1326 m_policyDocumentLoader->detachFromFrame(); | 1341 m_policyDocumentLoader->detachFromFrame(); |
| 1327 m_policyDocumentLoader = nullptr; | 1342 m_policyDocumentLoader = nullptr; |
| 1328 checkCompleted(); | 1343 checkCompleted(); |
| 1329 return; | 1344 return; |
| 1330 } | 1345 } |
| 1331 | 1346 |
| 1332 if (m_provisionalDocumentLoader) { | 1347 if (m_provisionalDocumentLoader) { |
| 1333 m_provisionalDocumentLoader->stopLoading(); | 1348 m_provisionalDocumentLoader->stopLoading(); |
| 1334 if (m_provisionalDocumentLoader) | 1349 if (m_provisionalDocumentLoader) |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 { | 1450 { |
| 1436 ASSERT(activeDocument); | 1451 ASSERT(activeDocument); |
| 1437 Frame* frame = m_frame->tree().find(name); | 1452 Frame* frame = m_frame->tree().find(name); |
| 1438 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal
Frame(*frame))) | 1453 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal
Frame(*frame))) |
| 1439 return 0; | 1454 return 0; |
| 1440 return toLocalFrame(frame); | 1455 return toLocalFrame(frame); |
| 1441 } | 1456 } |
| 1442 | 1457 |
| 1443 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) | 1458 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) |
| 1444 { | 1459 { |
| 1445 RefPtr<LocalFrame> protect(m_frame); | 1460 FrameProtector protect(m_frame); |
| 1446 if (m_frame->page()->defersLoading()) { | 1461 if (m_frame->page()->defersLoading()) { |
| 1447 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); | 1462 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); |
| 1448 return; | 1463 return; |
| 1449 } | 1464 } |
| 1450 | 1465 |
| 1451 m_provisionalItem = item; | 1466 m_provisionalItem = item; |
| 1452 if (historyLoadType == HistorySameDocumentLoad) { | 1467 if (historyLoadType == HistorySameDocumentLoad) { |
| 1453 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo
rward, NotClientRedirect); | 1468 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo
rward, NotClientRedirect); |
| 1454 restoreScrollPositionAndViewState(); | 1469 restoreScrollPositionAndViewState(); |
| 1455 return; | 1470 return; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. | 1509 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. |
| 1495 Frame* parentFrame = m_frame->tree().parent(); | 1510 Frame* parentFrame = m_frame->tree().parent(); |
| 1496 if (parentFrame && parentFrame->isLocalFrame()) | 1511 if (parentFrame && parentFrame->isLocalFrame()) |
| 1497 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); | 1512 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); |
| 1498 if (FrameOwner* frameOwner = m_frame->owner()) | 1513 if (FrameOwner* frameOwner = m_frame->owner()) |
| 1499 flags |= frameOwner->sandboxFlags(); | 1514 flags |= frameOwner->sandboxFlags(); |
| 1500 return flags; | 1515 return flags; |
| 1501 } | 1516 } |
| 1502 | 1517 |
| 1503 } // namespace blink | 1518 } // namespace blink |
| OLD | NEW |