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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/FrameView.h" | 53 #include "core/frame/FrameView.h" |
54 #include "core/frame/LocalFrame.h" | 54 #include "core/frame/LocalFrame.h" |
55 #include "core/frame/PinchViewport.h" | 55 #include "core/frame/PinchViewport.h" |
| 56 #include "core/frame/Settings.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" |
63 #include "core/loader/DocumentLoadTiming.h" | 64 #include "core/loader/DocumentLoadTiming.h" |
64 #include "core/loader/DocumentLoader.h" | 65 #include "core/loader/DocumentLoader.h" |
65 #include "core/loader/FormState.h" | 66 #include "core/loader/FormState.h" |
66 #include "core/loader/FormSubmission.h" | 67 #include "core/loader/FormSubmission.h" |
67 #include "core/loader/FrameFetchContext.h" | 68 #include "core/loader/FrameFetchContext.h" |
68 #include "core/loader/FrameLoadRequest.h" | 69 #include "core/loader/FrameLoadRequest.h" |
69 #include "core/loader/FrameLoaderClient.h" | 70 #include "core/loader/FrameLoaderClient.h" |
70 #include "core/loader/MixedContentChecker.h" | 71 #include "core/loader/MixedContentChecker.h" |
71 #include "core/loader/ProgressTracker.h" | 72 #include "core/loader/ProgressTracker.h" |
72 #include "core/loader/UniqueIdentifier.h" | 73 #include "core/loader/UniqueIdentifier.h" |
73 #include "core/loader/appcache/ApplicationCacheHost.h" | 74 #include "core/loader/appcache/ApplicationCacheHost.h" |
74 #include "core/page/BackForwardClient.h" | 75 #include "core/page/BackForwardClient.h" |
75 #include "core/page/Chrome.h" | 76 #include "core/page/Chrome.h" |
76 #include "core/page/ChromeClient.h" | 77 #include "core/page/ChromeClient.h" |
77 #include "core/page/CreateWindow.h" | 78 #include "core/page/CreateWindow.h" |
78 #include "core/page/EventHandler.h" | 79 #include "core/page/EventHandler.h" |
79 #include "core/page/FrameTree.h" | 80 #include "core/page/FrameTree.h" |
80 #include "core/page/Page.h" | 81 #include "core/page/Page.h" |
81 #include "core/frame/Settings.h" | |
82 #include "core/page/WindowFeatures.h" | 82 #include "core/page/WindowFeatures.h" |
83 #include "core/page/scrolling/ScrollingCoordinator.h" | 83 #include "core/page/scrolling/ScrollingCoordinator.h" |
84 #include "core/xml/parser/XMLDocumentParser.h" | 84 #include "core/xml/parser/XMLDocumentParser.h" |
85 #include "platform/Logging.h" | 85 #include "platform/Logging.h" |
86 #include "platform/UserGestureIndicator.h" | 86 #include "platform/UserGestureIndicator.h" |
87 #include "platform/geometry/FloatRect.h" | 87 #include "platform/geometry/FloatRect.h" |
88 #include "platform/network/HTTPParsers.h" | 88 #include "platform/network/HTTPParsers.h" |
89 #include "platform/network/ResourceRequest.h" | 89 #include "platform/network/ResourceRequest.h" |
90 #include "platform/scroll/ScrollAnimator.h" | 90 #include "platform/scroll/ScrollAnimator.h" |
91 #include "platform/weborigin/SecurityOrigin.h" | 91 #include "platform/weborigin/SecurityOrigin.h" |
(...skipping 30 matching lines...) Expand all Loading... |
122 , m_didAccessInitialDocument(false) | 122 , m_didAccessInitialDocument(false) |
123 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) | 123 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) |
124 , m_forcedSandboxFlags(SandboxNone) | 124 , m_forcedSandboxFlags(SandboxNone) |
125 { | 125 { |
126 } | 126 } |
127 | 127 |
128 FrameLoader::~FrameLoader() | 128 FrameLoader::~FrameLoader() |
129 { | 129 { |
130 } | 130 } |
131 | 131 |
| 132 void FrameLoader::trace(Visitor* visitor) |
| 133 { |
| 134 visitor->trace(m_frame); |
| 135 visitor->trace(m_fetchContext); |
| 136 } |
| 137 |
132 void FrameLoader::init() | 138 void FrameLoader::init() |
133 { | 139 { |
134 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); | 140 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); |
135 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); | 141 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); |
136 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); | 142 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp
eTopLevel : WebURLRequest::FrameTypeNested); |
137 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); | 143 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia
lRequest, SubstituteData()); |
138 m_provisionalDocumentLoader->startLoadingMainResource(); | 144 m_provisionalDocumentLoader->startLoadingMainResource(); |
139 m_frame->document()->cancelParsing(); | 145 m_frame->document()->cancelParsing(); |
140 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); | 146 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); |
141 } | 147 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 238 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
233 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); | 239 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); |
234 | 240 |
235 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results | 241 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results |
236 // from a subsequent window.document.open / window.document.write call. | 242 // from a subsequent window.document.open / window.document.write call. |
237 // Canceling redirection here works for all cases because document.open | 243 // Canceling redirection here works for all cases because document.open |
238 // implicitly precedes document.write. | 244 // implicitly precedes document.write. |
239 m_frame->navigationScheduler().cancel(); | 245 m_frame->navigationScheduler().cancel(); |
240 } | 246 } |
241 | 247 |
242 void FrameLoader::clear() | 248 void FrameLoader::dispose(DisposeFrameContents disposeFrameContents) |
243 { | 249 { |
| 250 // dispose() is called during (Local)Frame finalization and when creating |
| 251 // a new Document within it (DocumentLoader::createWriterFor().) |
244 if (m_stateMachine.creatingInitialEmptyDocument()) | 252 if (m_stateMachine.creatingInitialEmptyDocument()) |
245 return; | 253 return; |
246 | 254 |
247 m_frame->editor().clear(); | 255 if (disposeFrameContents == DoDisposeFrameContents) { |
248 m_frame->document()->cancelParsing(); | 256 m_frame->editor().clear(); |
249 m_frame->document()->prepareForDestruction(); | 257 // FIXME: Oilpan: check if one or more of these Document-specific action
s |
250 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); | 258 // now needs to be handled implicitly during Document finalization (and |
| 259 // aren't already performed.) |
| 260 m_frame->document()->cancelParsing(); |
| 261 m_frame->document()->prepareForDestruction(); |
| 262 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); |
| 263 // FIXME: Oilpan: the RenderView will not have its selection |
| 264 // cleared when the frame is finalized. Verify that this |
| 265 // is of no particular importance. |
| 266 m_frame->selection().prepareForDestruction(); |
| 267 m_frame->eventHandler().clear(); |
| 268 } |
251 | 269 |
252 m_frame->selection().prepareForDestruction(); | 270 // Oilpan: as FrameLoader is a part of object of m_frame, it is |
253 m_frame->eventHandler().clear(); | 271 // assumed safe to access it from here (even when invoked during finalizatio
n.) |
254 if (m_frame->view()) | 272 |
255 m_frame->view()->clear(); | 273 if (FrameView* view = m_frame->view()) |
| 274 view->clear(); |
256 | 275 |
257 m_frame->script().enableEval(); | 276 m_frame->script().enableEval(); |
258 | 277 |
| 278 // Oilpan: this depends on NavigationScheduler being a part object |
| 279 // of FrameLoader, i.e., the part object is still accessible. |
| 280 // |
| 281 // FIXME: Oilpan: verify this assumption. |
259 m_frame->navigationScheduler().cancel(); | 282 m_frame->navigationScheduler().cancel(); |
260 | 283 |
261 m_checkTimer.stop(); | 284 m_checkTimer.stop(); |
262 | 285 |
263 if (m_stateMachine.isDisplayingInitialEmptyDocument()) | 286 if (m_stateMachine.isDisplayingInitialEmptyDocument()) |
264 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); | 287 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); |
265 } | 288 } |
266 | 289 |
267 // This is only called by ScriptController::executeScriptIfJavaScriptURL | 290 // This is only called by ScriptController::executeScriptIfJavaScriptURL |
268 // and always contains the result of evaluating a javascript: url. | 291 // and always contains the result of evaluating a javascript: url. |
269 // This is the <iframe src="javascript:'html'"> case. | 292 // This is the <iframe src="javascript:'html'"> case. |
270 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc
e, Document* ownerDocument) | 293 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc
e, Document* ownerDocument) |
271 { | 294 { |
272 if (!m_frame->document()->loader()) | 295 if (!m_frame->document()->loader()) |
273 return; | 296 return; |
274 | 297 |
275 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the
DocumentLoader to get deref'ed and possible destroyed, | 298 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the
DocumentLoader to get deref'ed and possible destroyed, |
276 // so protect it with a RefPtr. | 299 // so protect it with a RefPtr. |
277 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); | 300 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); |
278 | 301 |
279 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc
riptURL); | 302 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc
riptURL); |
280 | 303 |
281 // Prepare a DocumentInit before clearing the frame, because it may need to | 304 // Prepare a DocumentInit before clearing the frame, because it may need to |
282 // inherit an aliased security context. | 305 // inherit an aliased security context. |
283 DocumentInit init(m_frame->document()->url(), m_frame); | 306 DocumentInit init(m_frame->document()->url(), m_frame); |
284 init.withNewRegistrationContext(); | 307 init.withNewRegistrationContext(); |
285 | 308 |
286 stopAllLoaders(); | 309 stopAllLoaders(); |
287 clear(); | 310 dispose(DoDisposeFrameContents); |
288 | 311 |
289 // clear() potentially detaches the frame from the document. The | 312 // dispose() potentially detaches the frame from the document. The |
290 // loading cannot continue in that case. | 313 // loading cannot continue in that case. |
291 if (!m_frame->page()) | 314 if (!m_frame->page()) |
292 return; | 315 return; |
293 | 316 |
294 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own
erDocument); | 317 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own
erDocument); |
295 } | 318 } |
296 | 319 |
297 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) | 320 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy
pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) |
298 { | 321 { |
299 if (m_provisionalItem) | 322 if (m_provisionalItem) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 } | 414 } |
392 | 415 |
393 void FrameLoader::finishedParsing() | 416 void FrameLoader::finishedParsing() |
394 { | 417 { |
395 if (m_stateMachine.creatingInitialEmptyDocument()) | 418 if (m_stateMachine.creatingInitialEmptyDocument()) |
396 return; | 419 return; |
397 | 420 |
398 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves | 421 // This can be called from the LocalFrame's destructor, in which case we sho
uldn't protect ourselves |
399 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. | 422 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. |
400 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. | 423 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. |
401 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; | 424 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul
lptr); |
402 | 425 |
403 if (client()) | 426 if (client()) |
404 client()->dispatchDidFinishDocumentLoad(); | 427 client()->dispatchDidFinishDocumentLoad(); |
405 | 428 |
406 checkCompleted(); | 429 checkCompleted(); |
407 | 430 |
408 if (!m_frame->view()) | 431 if (!m_frame->view()) |
409 return; // We are being destroyed by something checkCompleted called. | 432 return; // We are being destroyed by something checkCompleted called. |
410 | 433 |
411 // Check if the scrollbars are really needed for the content. | 434 // Check if the scrollbars are really needed for the content. |
(...skipping 23 matching lines...) Expand all Loading... |
435 { | 458 { |
436 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent
()) { | 459 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent
()) { |
437 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa
dEventFinished()) | 460 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa
dEventFinished()) |
438 return false; | 461 return false; |
439 } | 462 } |
440 return true; | 463 return true; |
441 } | 464 } |
442 | 465 |
443 void FrameLoader::checkCompleted() | 466 void FrameLoader::checkCompleted() |
444 { | 467 { |
445 RefPtr<LocalFrame> protect(m_frame); | 468 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
446 | 469 |
447 if (m_frame->view()) | 470 if (m_frame->view()) |
448 m_frame->view()->handleLoadCompleted(); | 471 m_frame->view()->handleLoadCompleted(); |
449 | 472 |
450 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR
ealDocumentLoad()) | 473 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR
ealDocumentLoad()) |
451 return; | 474 return; |
452 | 475 |
453 // Are we still parsing? | 476 // Are we still parsing? |
454 if (m_frame->document()->parsing()) | 477 if (m_frame->document()->parsing()) |
455 return; | 478 return; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 530 |
508 void FrameLoader::setOpener(LocalFrame* opener) | 531 void FrameLoader::setOpener(LocalFrame* opener) |
509 { | 532 { |
510 // If the frame is already detached, the opener has already been cleared. | 533 // If the frame is already detached, the opener has already been cleared. |
511 if (client()) | 534 if (client()) |
512 client()->setOpener(opener); | 535 client()->setOpener(opener); |
513 } | 536 } |
514 | 537 |
515 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) | 538 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) |
516 { | 539 { |
| 540 // With Oilpan, a FrameLoader might be accessed after the |
| 541 // FrameHost has been detached. FrameClient will not be |
| 542 // accessible, so bail early. |
| 543 if (!client()) |
| 544 return false; |
517 Settings* settings = m_frame->settings(); | 545 Settings* settings = m_frame->settings(); |
518 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); | 546 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled()
); |
519 if (!allowed && reason == AboutToInstantiatePlugin) | 547 if (!allowed && reason == AboutToInstantiatePlugin) |
520 client()->didNotAllowPlugins(); | 548 client()->didNotAllowPlugins(); |
521 return allowed; | 549 return allowed; |
522 } | 550 } |
523 | 551 |
524 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, FrameLoadType type) | 552 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume
ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu
e> data, FrameLoadType type) |
525 { | 553 { |
526 // Update the data source's request with the new URL to fake the URL change | 554 // Update the data source's request with the new URL to fake the URL change |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 // We need to scroll to the fragment whether or not a hash change occurred,
since | 605 // We need to scroll to the fragment whether or not a hash change occurred,
since |
578 // the user might have scrolled since the previous navigation. | 606 // the user might have scrolled since the previous navigation. |
579 scrollToFragmentWithParentBoundary(url); | 607 scrollToFragmentWithParentBoundary(url); |
580 checkCompleted(); | 608 checkCompleted(); |
581 | 609 |
582 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri
ptValue::nullValue()); | 610 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri
ptValue::nullValue()); |
583 } | 611 } |
584 | 612 |
585 void FrameLoader::completed() | 613 void FrameLoader::completed() |
586 { | 614 { |
587 RefPtr<LocalFrame> protect(m_frame); | 615 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
588 | 616 |
589 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant;
descendant = descendant->tree().traverseNext(m_frame)) { | 617 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant;
descendant = descendant->tree().traverseNext(m_frame)) { |
590 if (descendant->isLocalFrame()) | 618 if (descendant->isLocalFrame()) |
591 toLocalFrame(descendant)->navigationScheduler().startTimer(); | 619 toLocalFrame(descendant)->navigationScheduler().startTimer(); |
592 } | 620 } |
593 | 621 |
594 Frame* parent = m_frame->tree().parent(); | 622 Frame* parent = m_frame->tree().parent(); |
595 if (parent && parent->isLocalFrame()) | 623 if (parent && parent->isLocalFrame()) |
596 toLocalFrame(parent)->loader().checkCompleted(); | 624 toLocalFrame(parent)->loader().checkCompleted(); |
597 | 625 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 return WebURLRequest::RequestContextInternal; | 729 return WebURLRequest::RequestContextInternal; |
702 } | 730 } |
703 ASSERT_NOT_REACHED(); | 731 ASSERT_NOT_REACHED(); |
704 return WebURLRequest::RequestContextHyperlink; | 732 return WebURLRequest::RequestContextHyperlink; |
705 } | 733 } |
706 | 734 |
707 void FrameLoader::load(const FrameLoadRequest& passedRequest) | 735 void FrameLoader::load(const FrameLoadRequest& passedRequest) |
708 { | 736 { |
709 ASSERT(m_frame->document()); | 737 ASSERT(m_frame->document()); |
710 | 738 |
711 RefPtr<LocalFrame> protect(m_frame); | 739 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
712 | 740 |
713 if (m_inStopAllLoaders) | 741 if (m_inStopAllLoaders) |
714 return; | 742 return; |
715 | 743 |
716 FrameLoadRequest request(passedRequest); | 744 FrameLoadRequest request(passedRequest); |
717 if (!prepareRequestForThisFrame(request)) | 745 if (!prepareRequestForThisFrame(request)) |
718 return; | 746 return; |
719 | 747 |
720 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig
ation(AtomicString(request.frameName()), request.formState() ? request.formState
()->sourceDocument() : m_frame->document()); | 748 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF
rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque
st.formState()->sourceDocument() : m_frame->document()); |
721 if (targetFrame && targetFrame != m_frame) { | 749 if (targetFrame && targetFrame.get() != m_frame) { |
722 request.setFrameName("_self"); | 750 request.setFrameName("_self"); |
723 targetFrame->loader().load(request); | 751 targetFrame->loader().load(request); |
724 if (Page* page = targetFrame->page()) | 752 if (Page* page = targetFrame->page()) |
725 page->chrome().focus(); | 753 page->chrome().focus(); |
726 return; | 754 return; |
727 } | 755 } |
728 | 756 |
729 FrameLoadType newLoadType = determineFrameLoadType(request); | 757 FrameLoadType newLoadType = determineFrameLoadType(request); |
730 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); | 758 NavigationAction action(request.resourceRequest(), newLoadType, request.form
State(), request.triggeringEvent()); |
731 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte
xtUnspecified) | 759 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte
xtUnspecified) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 { | 851 { |
824 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 852 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
825 return; | 853 return; |
826 | 854 |
827 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. | 855 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
828 if (m_inStopAllLoaders) | 856 if (m_inStopAllLoaders) |
829 return; | 857 return; |
830 | 858 |
831 // Calling stopLoading() on the provisional document loader can blow away | 859 // Calling stopLoading() on the provisional document loader can blow away |
832 // the frame from underneath. | 860 // the frame from underneath. |
833 RefPtr<LocalFrame> protect(m_frame); | 861 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
834 | 862 |
835 m_inStopAllLoaders = true; | 863 m_inStopAllLoaders = true; |
836 | 864 |
837 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) { | 865 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { |
838 if (child->isLocalFrame()) | 866 if (child->isLocalFrame()) |
839 toLocalFrame(child.get())->loader().stopAllLoaders(); | 867 toLocalFrame(child.get())->loader().stopAllLoaders(); |
840 } | 868 } |
841 if (m_provisionalDocumentLoader) | 869 if (m_provisionalDocumentLoader) |
842 m_provisionalDocumentLoader->stopLoading(); | 870 m_provisionalDocumentLoader->stopLoading(); |
843 if (m_documentLoader) | 871 if (m_documentLoader) |
844 m_documentLoader->stopLoading(); | 872 m_documentLoader->stopLoading(); |
845 | 873 |
846 if (m_provisionalDocumentLoader) | 874 if (m_provisionalDocumentLoader) |
847 m_provisionalDocumentLoader->detachFromFrame(); | 875 m_provisionalDocumentLoader->detachFromFrame(); |
(...skipping 14 matching lines...) Expand all Loading... |
862 // We only need to notify the client once, and only for the main frame. | 890 // We only need to notify the client once, and only for the main frame. |
863 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { | 891 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { |
864 m_didAccessInitialDocument = true; | 892 m_didAccessInitialDocument = true; |
865 // Notify asynchronously, since this is called within a JavaScript secur
ity check. | 893 // Notify asynchronously, since this is called within a JavaScript secur
ity check. |
866 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); | 894 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); |
867 } | 895 } |
868 } | 896 } |
869 | 897 |
870 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) | 898 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) |
871 { | 899 { |
872 client()->didAccessInitialDocument(); | 900 if (client()) |
| 901 client()->didAccessInitialDocument(); |
873 } | 902 } |
874 | 903 |
875 void FrameLoader::notifyIfInitialDocumentAccessed() | 904 void FrameLoader::notifyIfInitialDocumentAccessed() |
876 { | 905 { |
877 if (m_didAccessInitialDocumentTimer.isActive()) { | 906 if (m_didAccessInitialDocumentTimer.isActive()) { |
878 m_didAccessInitialDocumentTimer.stop(); | 907 m_didAccessInitialDocumentTimer.stop(); |
879 didAccessInitialDocumentTimerFired(0); | 908 didAccessInitialDocumentTimerFired(0); |
880 } | 909 } |
881 } | 910 } |
882 | 911 |
883 void FrameLoader::commitProvisionalLoad() | 912 void FrameLoader::commitProvisionalLoad() |
884 { | 913 { |
885 ASSERT(client()->hasWebView()); | 914 ASSERT(client()->hasWebView()); |
886 ASSERT(m_state == FrameStateProvisional); | 915 ASSERT(m_state == FrameStateProvisional); |
887 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; | 916 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; |
888 RefPtr<LocalFrame> protect(m_frame); | 917 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
889 | 918 |
890 // Check if the destination page is allowed to access the previous page's ti
ming information. | 919 // Check if the destination page is allowed to access the previous page's ti
ming information. |
891 if (m_frame->document()) { | 920 if (m_frame->document()) { |
892 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ
est().url()); | 921 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ
est().url()); |
893 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq
uest(m_frame->document()->url())); | 922 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq
uest(m_frame->document()->url())); |
894 } | 923 } |
895 | 924 |
896 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary | 925 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary |
897 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, | 926 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, |
898 // or the two will stomp each other. | 927 // or the two will stomp each other. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 if (document->processingLoadEvent()) | 982 if (document->processingLoadEvent()) |
954 return false; | 983 return false; |
955 if (document->hasActiveParser()) | 984 if (document->hasActiveParser()) |
956 return false; | 985 return false; |
957 return true; | 986 return true; |
958 } | 987 } |
959 | 988 |
960 bool FrameLoader::checkLoadCompleteForThisFrame() | 989 bool FrameLoader::checkLoadCompleteForThisFrame() |
961 { | 990 { |
962 ASSERT(client()->hasWebView()); | 991 ASSERT(client()->hasWebView()); |
963 RefPtr<LocalFrame> protect(m_frame); | 992 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
964 | 993 |
965 bool allChildrenAreDoneLoading = true; | 994 bool allChildrenAreDoneLoading = true; |
966 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) { | 995 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { |
967 if (child->isLocalFrame()) | 996 if (child->isLocalFrame()) |
968 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che
ckLoadCompleteForThisFrame(); | 997 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che
ckLoadCompleteForThisFrame(); |
969 } | 998 } |
970 | 999 |
971 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { | 1000 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { |
972 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr
ror(); | 1001 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr
ror(); |
973 if (error.isNull()) | 1002 if (error.isNull()) |
974 return false; | 1003 return false; |
975 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; | 1004 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; |
976 client()->dispatchDidFailProvisionalLoad(error); | 1005 client()->dispatchDidFailProvisionalLoad(error); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 | 1112 |
1084 String FrameLoader::userAgent(const KURL& url) const | 1113 String FrameLoader::userAgent(const KURL& url) const |
1085 { | 1114 { |
1086 String userAgent = client()->userAgent(url); | 1115 String userAgent = client()->userAgent(url); |
1087 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); | 1116 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); |
1088 return userAgent; | 1117 return userAgent; |
1089 } | 1118 } |
1090 | 1119 |
1091 void FrameLoader::detachFromParent() | 1120 void FrameLoader::detachFromParent() |
1092 { | 1121 { |
| 1122 #if !ENABLE(OILPAN) |
1093 // The caller must protect a reference to m_frame. | 1123 // The caller must protect a reference to m_frame. |
1094 ASSERT(m_frame->refCount() > 1); | 1124 ASSERT(m_frame->refCount() > 1); |
| 1125 #endif |
1095 | 1126 |
1096 InspectorInstrumentation::frameDetachedFromParent(m_frame); | 1127 InspectorInstrumentation::frameDetachedFromParent(m_frame); |
1097 | 1128 |
1098 if (m_documentLoader) | 1129 if (m_documentLoader) |
1099 m_documentLoader->detachFromFrame(); | 1130 m_documentLoader->detachFromFrame(); |
1100 m_documentLoader = nullptr; | 1131 m_documentLoader = nullptr; |
1101 | 1132 |
1102 if (!client()) | 1133 if (!client()) |
1103 return; | 1134 return; |
1104 | 1135 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 // After this, we must no longer talk to the client since this clears | 1169 // After this, we must no longer talk to the client since this clears |
1139 // its owning reference back to our owning LocalFrame. | 1170 // its owning reference back to our owning LocalFrame. |
1140 client()->detachedFromParent(); | 1171 client()->detachedFromParent(); |
1141 m_frame->clearClient(); | 1172 m_frame->clearClient(); |
1142 } | 1173 } |
1143 } | 1174 } |
1144 | 1175 |
1145 void FrameLoader::receivedMainResourceError(const ResourceError& error) | 1176 void FrameLoader::receivedMainResourceError(const ResourceError& error) |
1146 { | 1177 { |
1147 // Retain because the stop may release the last reference to it. | 1178 // Retain because the stop may release the last reference to it. |
1148 RefPtr<LocalFrame> protect(m_frame); | 1179 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
1149 | 1180 |
1150 if (m_frame->document()->parser()) | 1181 if (m_frame->document()->parser()) |
1151 m_frame->document()->parser()->stopParsing(); | 1182 m_frame->document()->parser()->stopParsing(); |
1152 | 1183 |
1153 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some | 1184 // FIXME: We really ought to be able to just check for isCancellation() here
, but there are some |
1154 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). | 1185 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr
or::cancelledError(). |
1155 ResourceError c(ResourceError::cancelledError(KURL())); | 1186 ResourceError c(ResourceError::cancelledError(KURL())); |
1156 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->owner()) { | 1187 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) &&
m_frame->owner()) { |
1157 // FIXME: For now, fallback content doesn't work cross process. | 1188 // FIXME: For now, fallback content doesn't work cross process. |
1158 ASSERT(m_frame->owner()->isLocal()); | 1189 ASSERT(m_frame->owner()->isLocal()); |
(...skipping 21 matching lines...) Expand all Loading... |
1180 && !m_frame->document()->isFrameSet(); | 1211 && !m_frame->document()->isFrameSet(); |
1181 } | 1212 } |
1182 | 1213 |
1183 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) | 1214 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) |
1184 { | 1215 { |
1185 FrameView* view = m_frame->view(); | 1216 FrameView* view = m_frame->view(); |
1186 if (!view) | 1217 if (!view) |
1187 return; | 1218 return; |
1188 | 1219 |
1189 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. | 1220 // Leaking scroll position to a cross-origin ancestor would permit the so-ca
lled "framesniffing" attack. |
1190 RefPtr<LocalFrame> boundaryFrame(url.hasFragmentIdentifier() ? m_frame->docu
ment()->findUnsafeParentScrollPropagationBoundary() : 0); | 1221 RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = url.hasFragmentIdentifier() ?
m_frame->document()->findUnsafeParentScrollPropagationBoundary() : 0; |
1191 | 1222 |
1192 if (boundaryFrame) | 1223 if (boundaryFrame) |
1193 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); | 1224 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); |
1194 | 1225 |
1195 view->scrollToFragment(url); | 1226 view->scrollToFragment(url); |
1196 | 1227 |
1197 if (boundaryFrame) | 1228 if (boundaryFrame) |
1198 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); | 1229 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); |
1199 } | 1230 } |
1200 | 1231 |
1201 bool FrameLoader::shouldClose() | 1232 bool FrameLoader::shouldClose() |
1202 { | 1233 { |
1203 Page* page = m_frame->page(); | 1234 Page* page = m_frame->page(); |
1204 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) | 1235 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) |
1205 return true; | 1236 return true; |
1206 | 1237 |
1207 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame | 1238 // Store all references to each subframe in advance since beforeunload's eve
nt handler may modify frame |
1208 Vector<RefPtr<LocalFrame> > targetFrames; | 1239 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames; |
1209 targetFrames.append(m_frame); | 1240 targetFrames.append(m_frame); |
1210 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { | 1241 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree
().traverseNext(m_frame)) { |
1211 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. | 1242 // FIXME: There is not yet any way to dispatch events to out-of-process
frames. |
1212 if (child->isLocalFrame()) | 1243 if (child->isLocalFrame()) |
1213 targetFrames.append(toLocalFrame(child)); | 1244 targetFrames.append(toLocalFrame(child)); |
1214 } | 1245 } |
1215 | 1246 |
1216 bool shouldClose = false; | 1247 bool shouldClose = false; |
1217 { | 1248 { |
1218 NavigationDisablerForBeforeUnload navigationDisabler; | 1249 NavigationDisablerForBeforeUnload navigationDisabler; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); | 1316 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); |
1286 else if (m_documentLoader) | 1317 else if (m_documentLoader) |
1287 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); | 1318 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); |
1288 | 1319 |
1289 | 1320 |
1290 bool isTransitionNavigation = false; | 1321 bool isTransitionNavigation = false; |
1291 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) | 1322 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) |
1292 isTransitionNavigation = dispatchNavigationTransitionData(); | 1323 isTransitionNavigation = dispatchNavigationTransitionData(); |
1293 | 1324 |
1294 // stopAllLoaders can detach the LocalFrame, so protect it. | 1325 // stopAllLoaders can detach the LocalFrame, so protect it. |
1295 RefPtr<LocalFrame> protect(m_frame); | 1326 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
1296 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { | 1327 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { |
1297 m_policyDocumentLoader->detachFromFrame(); | 1328 m_policyDocumentLoader->detachFromFrame(); |
1298 m_policyDocumentLoader = nullptr; | 1329 m_policyDocumentLoader = nullptr; |
1299 checkCompleted(); | 1330 checkCompleted(); |
1300 return; | 1331 return; |
1301 } | 1332 } |
1302 | 1333 |
1303 if (m_provisionalDocumentLoader) { | 1334 if (m_provisionalDocumentLoader) { |
1304 m_provisionalDocumentLoader->stopLoading(); | 1335 m_provisionalDocumentLoader->stopLoading(); |
1305 if (m_provisionalDocumentLoader) | 1336 if (m_provisionalDocumentLoader) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1406 { | 1437 { |
1407 ASSERT(activeDocument); | 1438 ASSERT(activeDocument); |
1408 Frame* frame = m_frame->tree().find(name); | 1439 Frame* frame = m_frame->tree().find(name); |
1409 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal
Frame(*frame))) | 1440 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal
Frame(*frame))) |
1410 return 0; | 1441 return 0; |
1411 return toLocalFrame(frame); | 1442 return toLocalFrame(frame); |
1412 } | 1443 } |
1413 | 1444 |
1414 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) | 1445 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad
Type, ResourceRequestCachePolicy cachePolicy) |
1415 { | 1446 { |
1416 RefPtr<LocalFrame> protect(m_frame); | 1447 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
1417 if (m_frame->page()->defersLoading()) { | 1448 if (m_frame->page()->defersLoading()) { |
1418 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); | 1449 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache
Policy); |
1419 return; | 1450 return; |
1420 } | 1451 } |
1421 | 1452 |
1422 m_provisionalItem = item; | 1453 m_provisionalItem = item; |
1423 if (historyLoadType == HistorySameDocumentLoad) { | 1454 if (historyLoadType == HistorySameDocumentLoad) { |
1424 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo
rward, NotClientRedirect); | 1455 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo
rward, NotClientRedirect); |
1425 restoreScrollPositionAndViewState(); | 1456 restoreScrollPositionAndViewState(); |
1426 return; | 1457 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. | 1496 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. |
1466 Frame* parentFrame = m_frame->tree().parent(); | 1497 Frame* parentFrame = m_frame->tree().parent(); |
1467 if (parentFrame && parentFrame->isLocalFrame()) | 1498 if (parentFrame && parentFrame->isLocalFrame()) |
1468 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); | 1499 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); |
1469 if (FrameOwner* frameOwner = m_frame->owner()) | 1500 if (FrameOwner* frameOwner = m_frame->owner()) |
1470 flags |= frameOwner->sandboxFlags(); | 1501 flags |= frameOwner->sandboxFlags(); |
1471 return flags; | 1502 return flags; |
1472 } | 1503 } |
1473 | 1504 |
1474 } // namespace blink | 1505 } // namespace blink |
OLD | NEW |