Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: Source/core/loader/FrameLoader.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r181764 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/ProgressTracker.h" 71 #include "core/loader/ProgressTracker.h"
71 #include "core/loader/UniqueIdentifier.h" 72 #include "core/loader/UniqueIdentifier.h"
72 #include "core/loader/appcache/ApplicationCacheHost.h" 73 #include "core/loader/appcache/ApplicationCacheHost.h"
73 #include "core/page/BackForwardClient.h" 74 #include "core/page/BackForwardClient.h"
74 #include "core/page/Chrome.h" 75 #include "core/page/Chrome.h"
75 #include "core/page/ChromeClient.h" 76 #include "core/page/ChromeClient.h"
76 #include "core/page/CreateWindow.h" 77 #include "core/page/CreateWindow.h"
77 #include "core/page/EventHandler.h" 78 #include "core/page/EventHandler.h"
78 #include "core/page/FrameTree.h" 79 #include "core/page/FrameTree.h"
79 #include "core/page/Page.h" 80 #include "core/page/Page.h"
80 #include "core/frame/Settings.h"
81 #include "core/page/WindowFeatures.h" 81 #include "core/page/WindowFeatures.h"
82 #include "core/page/scrolling/ScrollingCoordinator.h" 82 #include "core/page/scrolling/ScrollingCoordinator.h"
83 #include "core/xml/parser/XMLDocumentParser.h" 83 #include "core/xml/parser/XMLDocumentParser.h"
84 #include "platform/Logging.h" 84 #include "platform/Logging.h"
85 #include "platform/UserGestureIndicator.h" 85 #include "platform/UserGestureIndicator.h"
86 #include "platform/geometry/FloatRect.h" 86 #include "platform/geometry/FloatRect.h"
87 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" 87 #include "platform/network/ContentSecurityPolicyResponseHeaders.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"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 , m_didAccessInitialDocument(false) 123 , m_didAccessInitialDocument(false)
124 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired) 124 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume ntTimerFired)
125 , m_forcedSandboxFlags(SandboxNone) 125 , m_forcedSandboxFlags(SandboxNone)
126 { 126 {
127 } 127 }
128 128
129 FrameLoader::~FrameLoader() 129 FrameLoader::~FrameLoader()
130 { 130 {
131 } 131 }
132 132
133 void FrameLoader::trace(Visitor* visitor)
134 {
135 visitor->trace(m_frame);
136 visitor->trace(m_fetchContext);
137 }
138
133 void FrameLoader::init() 139 void FrameLoader::init()
134 { 140 {
135 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString())); 141 ResourceRequest initialRequest(KURL(ParsedURLString, emptyString()));
136 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal); 142 initialRequest.setRequestContext(WebURLRequest::RequestContextInternal);
137 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested); 143 initialRequest.setFrameType(m_frame->isMainFrame() ? WebURLRequest::FrameTyp eTopLevel : WebURLRequest::FrameTypeNested);
138 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData()); 144 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, initia lRequest, SubstituteData());
139 m_provisionalDocumentLoader->startLoadingMainResource(); 145 m_provisionalDocumentLoader->startLoadingMainResource();
140 m_frame->document()->cancelParsing(); 146 m_frame->document()->cancelParsing();
141 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment); 147 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu ment);
142 } 148 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!m_stateMachine.committedFirstRealDocumentLoad()) 239 if (!m_stateMachine.committedFirstRealDocumentLoad())
234 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 240 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
235 241
236 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results 242 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
237 // from a subsequent window.document.open / window.document.write call. 243 // from a subsequent window.document.open / window.document.write call.
238 // Canceling redirection here works for all cases because document.open 244 // Canceling redirection here works for all cases because document.open
239 // implicitly precedes document.write. 245 // implicitly precedes document.write.
240 m_frame->navigationScheduler().cancel(); 246 m_frame->navigationScheduler().cancel();
241 } 247 }
242 248
243 void FrameLoader::clear() 249 void FrameLoader::dispose(DisposeFrameContents disposeFrameContents)
244 { 250 {
251 // dispose() is called during (Local)Frame finalization and when creating
252 // a new Document within it (DocumentLoader::createWriterFor().)
245 if (m_stateMachine.creatingInitialEmptyDocument()) 253 if (m_stateMachine.creatingInitialEmptyDocument())
246 return; 254 return;
247 255
248 m_frame->editor().clear(); 256 if (disposeFrameContents == DoDisposeFrameContents) {
249 m_frame->document()->cancelParsing(); 257 m_frame->editor().clear();
250 m_frame->document()->prepareForDestruction(); 258 // FIXME: Oilpan: check if one or more of these Document-specific action s
251 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); 259 // now needs to be handled implicitly during Document finalization (and
260 // aren't already performed.)
261 m_frame->document()->cancelParsing();
262 m_frame->document()->prepareForDestruction();
263 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
264 // FIXME: Oilpan: the RenderView will not have its selection
265 // cleared when the frame is finalized. Verify that this
266 // is of no particular importance.
267 m_frame->selection().prepareForDestruction();
268 m_frame->eventHandler().clear();
269 }
252 270
253 m_frame->selection().prepareForDestruction(); 271 if (FrameView* view = m_frame->view())
254 m_frame->eventHandler().clear(); 272 view->clear();
255 if (m_frame->view())
256 m_frame->view()->clear();
257 273
258 m_frame->script().enableEval(); 274 m_frame->script().enableEval();
259 275
276 // Oilpan: this depends on NavigationScheduler being a part object
277 // of FrameLoader, i.e., the part object is still accessible.
278 //
279 // FIXME: Oilpan: verify this assumption.
260 m_frame->navigationScheduler().cancel(); 280 m_frame->navigationScheduler().cancel();
261 281
262 m_checkTimer.stop(); 282 m_checkTimer.stop();
263 283
264 if (m_stateMachine.isDisplayingInitialEmptyDocument()) 284 if (m_stateMachine.isDisplayingInitialEmptyDocument())
265 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 285 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
266 } 286 }
267 287
268 // This is only called by ScriptController::executeScriptIfJavaScriptURL 288 // This is only called by ScriptController::executeScriptIfJavaScriptURL
269 // and always contains the result of evaluating a javascript: url. 289 // and always contains the result of evaluating a javascript: url.
270 // This is the <iframe src="javascript:'html'"> case. 290 // This is the <iframe src="javascript:'html'"> case.
271 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument) 291 void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc e, Document* ownerDocument)
272 { 292 {
273 if (!m_frame->document()->loader()) 293 if (!m_frame->document()->loader())
274 return; 294 return;
275 295
276 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed, 296 // DocumentWriter::replaceDocumentWhileExecutingJavaScriptURL can cause the DocumentLoader to get deref'ed and possible destroyed,
277 // so protect it with a RefPtr. 297 // so protect it with a RefPtr.
278 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); 298 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader());
279 299
280 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); 300 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL);
281 301
282 // Prepare a DocumentInit before clearing the frame, because it may need to 302 // Prepare a DocumentInit before clearing the frame, because it may need to
283 // inherit an aliased security context. 303 // inherit an aliased security context.
284 DocumentInit init(m_frame->document()->url(), m_frame); 304 DocumentInit init(m_frame->document()->url(), m_frame);
285 init.withNewRegistrationContext(); 305 init.withNewRegistrationContext();
286 306
287 stopAllLoaders(); 307 stopAllLoaders();
288 clear(); 308 dispose(DoDisposeFrameContents);
289 309
290 // clear() potentially detaches the frame from the document. The 310 // dispose() potentially detaches the frame from the document. The
291 // loading cannot continue in that case. 311 // loading cannot continue in that case.
292 if (!m_frame->page()) 312 if (!m_frame->page())
293 return; 313 return;
294 314
295 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); 315 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument);
296 } 316 }
297 317
298 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) 318 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject)
299 { 319 {
300 if (m_provisionalItem) 320 if (m_provisionalItem)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT ype); 370 client()->dispatchDidCommitLoad(m_frame, m_currentItem.get(), historyCommitT ype);
351 371
352 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get()); 372 InspectorInstrumentation::didCommitLoad(m_frame, m_documentLoader.get());
353 m_frame->page()->didCommitLoad(m_frame); 373 m_frame->page()->didCommitLoad(m_frame);
354 dispatchDidClearDocumentOfWindowObject(); 374 dispatchDidClearDocumentOfWindowObject();
355 } 375 }
356 376
357 static void didFailContentSecurityPolicyCheck(FrameLoader* loader) 377 static void didFailContentSecurityPolicyCheck(FrameLoader* loader)
358 { 378 {
359 // load event and stopAllLoaders can detach the LocalFrame, so protect it. 379 // load event and stopAllLoaders can detach the LocalFrame, so protect it.
360 RefPtr<LocalFrame> frame(loader->frame()); 380 RefPtrWillBeRawPtr<LocalFrame> frame = loader->frame();
361 381
362 // Move the page to a unique origin, and cancel the load. 382 // Move the page to a unique origin, and cancel the load.
363 frame->document()->enforceSandboxFlags(SandboxOrigin); 383 frame->document()->enforceSandboxFlags(SandboxOrigin);
364 loader->stopAllLoaders(); 384 loader->stopAllLoaders();
365 385
366 // Fire a load event, as timing attacks would otherwise reveal that the 386 // 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 387 // frame was blocked. This way, it looks like every other cross-origin
368 // page. 388 // page.
369 if (FrameOwner* frameOwner = frame->owner()) 389 if (FrameOwner* frameOwner = frame->owner())
370 frameOwner->dispatchLoad(); 390 frameOwner->dispatchLoad();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 } 433 }
414 434
415 void FrameLoader::finishedParsing() 435 void FrameLoader::finishedParsing()
416 { 436 {
417 if (m_stateMachine.creatingInitialEmptyDocument()) 437 if (m_stateMachine.creatingInitialEmptyDocument())
418 return; 438 return;
419 439
420 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 440 // 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. 441 // 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. 442 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
423 RefPtr<LocalFrame> protector = m_frame->view() ? m_frame : 0; 443 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
424 444
425 if (client()) 445 if (client())
426 client()->dispatchDidFinishDocumentLoad(); 446 client()->dispatchDidFinishDocumentLoad();
427 447
428 checkCompleted(); 448 checkCompleted();
429 449
430 if (!m_frame->view()) 450 if (!m_frame->view())
431 return; // We are being destroyed by something checkCompleted called. 451 return; // We are being destroyed by something checkCompleted called.
432 452
433 // Check if the scrollbars are really needed for the content. 453 // Check if the scrollbars are really needed for the content.
(...skipping 23 matching lines...) Expand all
457 { 477 {
458 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { 478 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) {
459 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished()) 479 if (ancestor->isLocalFrame() && !toLocalFrame(ancestor)->document()->loa dEventFinished())
460 return false; 480 return false;
461 } 481 }
462 return true; 482 return true;
463 } 483 }
464 484
465 void FrameLoader::checkCompleted() 485 void FrameLoader::checkCompleted()
466 { 486 {
467 RefPtr<LocalFrame> protect(m_frame); 487 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
468 488
469 if (m_frame->view()) 489 if (m_frame->view())
470 m_frame->view()->handleLoadCompleted(); 490 m_frame->view()->handleLoadCompleted();
471 491
472 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad()) 492 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad())
473 return; 493 return;
474 494
475 // Are we still parsing? 495 // Are we still parsing?
476 if (m_frame->document()->parsing()) 496 if (m_frame->document()->parsing())
477 return; 497 return;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 549
530 void FrameLoader::setOpener(LocalFrame* opener) 550 void FrameLoader::setOpener(LocalFrame* opener)
531 { 551 {
532 // If the frame is already detached, the opener has already been cleared. 552 // If the frame is already detached, the opener has already been cleared.
533 if (client()) 553 if (client())
534 client()->setOpener(opener); 554 client()->setOpener(opener);
535 } 555 }
536 556
537 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason) 557 bool FrameLoader::allowPlugins(ReasonForCallingAllowPlugins reason)
538 { 558 {
559 // With Oilpan, a FrameLoader might be accessed after the
560 // FrameHost has been detached. FrameClient will not be
561 // accessible, so bail early.
562 if (!client())
563 return false;
539 Settings* settings = m_frame->settings(); 564 Settings* settings = m_frame->settings();
540 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() ); 565 bool allowed = client()->allowPlugins(settings && settings->pluginsEnabled() );
541 if (!allowed && reason == AboutToInstantiatePlugin) 566 if (!allowed && reason == AboutToInstantiatePlugin)
542 client()->didNotAllowPlugins(); 567 client()->didNotAllowPlugins();
543 return allowed; 568 return allowed;
544 } 569 }
545 570
546 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type) 571 void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume ntNavigationSource sameDocumentNavigationSource, PassRefPtr<SerializedScriptValu e> data, FrameLoadType type)
547 { 572 {
548 // Update the data source's request with the new URL to fake the URL change 573 // 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
599 // We need to scroll to the fragment whether or not a hash change occurred, since 624 // 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. 625 // the user might have scrolled since the previous navigation.
601 scrollToFragmentWithParentBoundary(url); 626 scrollToFragmentWithParentBoundary(url);
602 checkCompleted(); 627 checkCompleted();
603 628
604 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue()); 629 m_frame->domWindow()->statePopped(stateObject ? stateObject : SerializedScri ptValue::nullValue());
605 } 630 }
606 631
607 void FrameLoader::completed() 632 void FrameLoader::completed()
608 { 633 {
609 RefPtr<LocalFrame> protect(m_frame); 634 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
610 635
611 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) { 636 for (Frame* descendant = m_frame->tree().traverseNext(m_frame); descendant; descendant = descendant->tree().traverseNext(m_frame)) {
612 if (descendant->isLocalFrame()) 637 if (descendant->isLocalFrame())
613 toLocalFrame(descendant)->navigationScheduler().startTimer(); 638 toLocalFrame(descendant)->navigationScheduler().startTimer();
614 } 639 }
615 640
616 Frame* parent = m_frame->tree().parent(); 641 Frame* parent = m_frame->tree().parent();
617 if (parent && parent->isLocalFrame()) 642 if (parent && parent->isLocalFrame())
618 toLocalFrame(parent)->loader().checkCompleted(); 643 toLocalFrame(parent)->loader().checkCompleted();
619 644
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 return WebURLRequest::RequestContextInternal; 748 return WebURLRequest::RequestContextInternal;
724 } 749 }
725 ASSERT_NOT_REACHED(); 750 ASSERT_NOT_REACHED();
726 return WebURLRequest::RequestContextHyperlink; 751 return WebURLRequest::RequestContextHyperlink;
727 } 752 }
728 753
729 void FrameLoader::load(const FrameLoadRequest& passedRequest) 754 void FrameLoader::load(const FrameLoadRequest& passedRequest)
730 { 755 {
731 ASSERT(m_frame->document()); 756 ASSERT(m_frame->document());
732 757
733 RefPtr<LocalFrame> protect(m_frame); 758 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
734 759
735 if (m_inStopAllLoaders) 760 if (m_inStopAllLoaders)
736 return; 761 return;
737 762
738 FrameLoadRequest request(passedRequest); 763 FrameLoadRequest request(passedRequest);
739 if (!prepareRequestForThisFrame(request)) 764 if (!prepareRequestForThisFrame(request))
740 return; 765 return;
741 766
742 RefPtr<LocalFrame> targetFrame = request.formState() ? 0 : findFrameForNavig ation(AtomicString(request.frameName()), request.formState() ? request.formState ()->sourceDocument() : m_frame->document()); 767 RefPtrWillBeRawPtr<LocalFrame> targetFrame = request.formState() ? 0 : findF rameForNavigation(AtomicString(request.frameName()), request.formState() ? reque st.formState()->sourceDocument() : m_frame->document());
743 if (targetFrame && targetFrame != m_frame) { 768 if (targetFrame && targetFrame.get() != m_frame) {
744 request.setFrameName("_self"); 769 request.setFrameName("_self");
745 targetFrame->loader().load(request); 770 targetFrame->loader().load(request);
746 if (Page* page = targetFrame->page()) 771 if (Page* page = targetFrame->page())
747 page->chrome().focus(); 772 page->chrome().focus();
748 return; 773 return;
749 } 774 }
750 775
751 FrameLoadType newLoadType = determineFrameLoadType(request); 776 FrameLoadType newLoadType = determineFrameLoadType(request);
752 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent()); 777 NavigationAction action(request.resourceRequest(), newLoadType, request.form State(), request.triggeringEvent());
753 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified) 778 if (action.resourceRequest().requestContext() == WebURLRequest::RequestConte xtUnspecified)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 { 870 {
846 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 871 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
847 return; 872 return;
848 873
849 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 874 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
850 if (m_inStopAllLoaders) 875 if (m_inStopAllLoaders)
851 return; 876 return;
852 877
853 // Calling stopLoading() on the provisional document loader can blow away 878 // Calling stopLoading() on the provisional document loader can blow away
854 // the frame from underneath. 879 // the frame from underneath.
855 RefPtr<LocalFrame> protect(m_frame); 880 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
856 881
857 m_inStopAllLoaders = true; 882 m_inStopAllLoaders = true;
858 883
859 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 884 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
860 if (child->isLocalFrame()) 885 if (child->isLocalFrame())
861 toLocalFrame(child.get())->loader().stopAllLoaders(); 886 toLocalFrame(child.get())->loader().stopAllLoaders();
862 } 887 }
863 if (m_provisionalDocumentLoader) 888 if (m_provisionalDocumentLoader)
864 m_provisionalDocumentLoader->stopLoading(); 889 m_provisionalDocumentLoader->stopLoading();
865 if (m_documentLoader) 890 if (m_documentLoader)
866 m_documentLoader->stopLoading(); 891 m_documentLoader->stopLoading();
867 892
868 if (m_provisionalDocumentLoader) 893 if (m_provisionalDocumentLoader)
869 m_provisionalDocumentLoader->detachFromFrame(); 894 m_provisionalDocumentLoader->detachFromFrame();
(...skipping 14 matching lines...) Expand all
884 // We only need to notify the client once, and only for the main frame. 909 // We only need to notify the client once, and only for the main frame.
885 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { 910 if (isLoadingMainFrame() && !m_didAccessInitialDocument) {
886 m_didAccessInitialDocument = true; 911 m_didAccessInitialDocument = true;
887 // Notify asynchronously, since this is called within a JavaScript secur ity check. 912 // Notify asynchronously, since this is called within a JavaScript secur ity check.
888 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE); 913 m_didAccessInitialDocumentTimer.startOneShot(0, FROM_HERE);
889 } 914 }
890 } 915 }
891 916
892 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*) 917 void FrameLoader::didAccessInitialDocumentTimerFired(Timer<FrameLoader>*)
893 { 918 {
894 client()->didAccessInitialDocument(); 919 if (client())
920 client()->didAccessInitialDocument();
895 } 921 }
896 922
897 void FrameLoader::notifyIfInitialDocumentAccessed() 923 void FrameLoader::notifyIfInitialDocumentAccessed()
898 { 924 {
899 if (m_didAccessInitialDocumentTimer.isActive()) { 925 if (m_didAccessInitialDocumentTimer.isActive()) {
900 m_didAccessInitialDocumentTimer.stop(); 926 m_didAccessInitialDocumentTimer.stop();
901 didAccessInitialDocumentTimerFired(0); 927 didAccessInitialDocumentTimerFired(0);
902 } 928 }
903 } 929 }
904 930
905 void FrameLoader::commitProvisionalLoad() 931 void FrameLoader::commitProvisionalLoad()
906 { 932 {
907 ASSERT(client()->hasWebView()); 933 ASSERT(client()->hasWebView());
908 ASSERT(m_state == FrameStateProvisional); 934 ASSERT(m_state == FrameStateProvisional);
909 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; 935 RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader;
910 RefPtr<LocalFrame> protect(m_frame); 936 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
911 937
912 // Check if the destination page is allowed to access the previous page's ti ming information. 938 // Check if the destination page is allowed to access the previous page's ti ming information.
913 if (m_frame->document()) { 939 if (m_frame->document()) {
914 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url()); 940 RefPtr<SecurityOrigin> securityOrigin = SecurityOrigin::create(pdl->requ est().url());
915 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url())); 941 pdl->timing()->setHasSameOriginAsPreviousDocument(securityOrigin->canReq uest(m_frame->document()->url()));
916 } 942 }
917 943
918 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary 944 // The call to closeURL() invokes the unload event handler, which can execut e arbitrary
919 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load, 945 // JavaScript. If the script initiates a new load, we need to abandon the cu rrent load,
920 // or the two will stomp each other. 946 // or the two will stomp each other.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 if (document->processingLoadEvent()) 1001 if (document->processingLoadEvent())
976 return false; 1002 return false;
977 if (document->hasActiveParser()) 1003 if (document->hasActiveParser())
978 return false; 1004 return false;
979 return true; 1005 return true;
980 } 1006 }
981 1007
982 bool FrameLoader::checkLoadCompleteForThisFrame() 1008 bool FrameLoader::checkLoadCompleteForThisFrame()
983 { 1009 {
984 ASSERT(client()->hasWebView()); 1010 ASSERT(client()->hasWebView());
985 RefPtr<LocalFrame> protect(m_frame); 1011 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
986 1012
987 bool allChildrenAreDoneLoading = true; 1013 bool allChildrenAreDoneLoading = true;
988 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) { 1014 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
989 if (child->isLocalFrame()) 1015 if (child->isLocalFrame())
990 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 1016 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
991 } 1017 }
992 1018
993 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { 1019 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
994 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror(); 1020 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror();
995 if (error.isNull()) 1021 if (error.isNull())
996 return false; 1022 return false;
997 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; 1023 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader;
998 client()->dispatchDidFailProvisionalLoad(error); 1024 client()->dispatchDidFailProvisionalLoad(error);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1105 1131
1106 String FrameLoader::userAgent(const KURL& url) const 1132 String FrameLoader::userAgent(const KURL& url) const
1107 { 1133 {
1108 String userAgent = client()->userAgent(url); 1134 String userAgent = client()->userAgent(url);
1109 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); 1135 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent);
1110 return userAgent; 1136 return userAgent;
1111 } 1137 }
1112 1138
1113 void FrameLoader::detachFromParent() 1139 void FrameLoader::detachFromParent()
1114 { 1140 {
1141 #if !ENABLE(OILPAN)
1115 // The caller must protect a reference to m_frame. 1142 // The caller must protect a reference to m_frame.
1116 ASSERT(m_frame->refCount() > 1); 1143 ASSERT(m_frame->refCount() > 1);
1144 #endif
1117 1145
1118 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1146 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1119 1147
1120 if (m_documentLoader) 1148 if (m_documentLoader)
1121 m_documentLoader->detachFromFrame(); 1149 m_documentLoader->detachFromFrame();
1122 m_documentLoader = nullptr; 1150 m_documentLoader = nullptr;
1123 1151
1124 if (!client()) 1152 if (!client())
1125 return; 1153 return;
1126 1154
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 // After this, we must no longer talk to the client since this clears 1188 // After this, we must no longer talk to the client since this clears
1161 // its owning reference back to our owning LocalFrame. 1189 // its owning reference back to our owning LocalFrame.
1162 client()->detachedFromParent(); 1190 client()->detachedFromParent();
1163 m_frame->clearClient(); 1191 m_frame->clearClient();
1164 } 1192 }
1165 } 1193 }
1166 1194
1167 void FrameLoader::receivedMainResourceError(const ResourceError& error) 1195 void FrameLoader::receivedMainResourceError(const ResourceError& error)
1168 { 1196 {
1169 // Retain because the stop may release the last reference to it. 1197 // Retain because the stop may release the last reference to it.
1170 RefPtr<LocalFrame> protect(m_frame); 1198 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1171 1199
1172 if (m_frame->document()->parser()) 1200 if (m_frame->document()->parser())
1173 m_frame->document()->parser()->stopParsing(); 1201 m_frame->document()->parser()->stopParsing();
1174 1202
1175 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some 1203 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some
1176 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError(). 1204 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError().
1177 ResourceError c(ResourceError::cancelledError(KURL())); 1205 ResourceError c(ResourceError::cancelledError(KURL()));
1178 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) { 1206 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) {
1179 // FIXME: For now, fallback content doesn't work cross process. 1207 // FIXME: For now, fallback content doesn't work cross process.
1180 ASSERT(m_frame->owner()->isLocal()); 1208 ASSERT(m_frame->owner()->isLocal());
(...skipping 21 matching lines...) Expand all
1202 && !m_frame->document()->isFrameSet(); 1230 && !m_frame->document()->isFrameSet();
1203 } 1231 }
1204 1232
1205 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url) 1233 void FrameLoader::scrollToFragmentWithParentBoundary(const KURL& url)
1206 { 1234 {
1207 FrameView* view = m_frame->view(); 1235 FrameView* view = m_frame->view();
1208 if (!view) 1236 if (!view)
1209 return; 1237 return;
1210 1238
1211 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack. 1239 // Leaking scroll position to a cross-origin ancestor would permit the so-ca lled "framesniffing" attack.
1212 RefPtr<LocalFrame> boundaryFrame(url.hasFragmentIdentifier() ? m_frame->docu ment()->findUnsafeParentScrollPropagationBoundary() : 0); 1240 RefPtrWillBeRawPtr<LocalFrame> boundaryFrame = url.hasFragmentIdentifier() ? m_frame->document()->findUnsafeParentScrollPropagationBoundary() : 0;
1213 1241
1214 if (boundaryFrame) 1242 if (boundaryFrame)
1215 boundaryFrame->view()->setSafeToPropagateScrollToParent(false); 1243 boundaryFrame->view()->setSafeToPropagateScrollToParent(false);
1216 1244
1217 view->scrollToFragment(url); 1245 view->scrollToFragment(url);
1218 1246
1219 if (boundaryFrame) 1247 if (boundaryFrame)
1220 boundaryFrame->view()->setSafeToPropagateScrollToParent(true); 1248 boundaryFrame->view()->setSafeToPropagateScrollToParent(true);
1221 } 1249 }
1222 1250
1223 bool FrameLoader::shouldClose() 1251 bool FrameLoader::shouldClose()
1224 { 1252 {
1225 Page* page = m_frame->page(); 1253 Page* page = m_frame->page();
1226 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel()) 1254 if (!page || !page->chrome().canRunBeforeUnloadConfirmPanel())
1227 return true; 1255 return true;
1228 1256
1229 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame 1257 // Store all references to each subframe in advance since beforeunload's eve nt handler may modify frame
1230 Vector<RefPtr<LocalFrame> > targetFrames; 1258 WillBeHeapVector<RefPtrWillBeMember<LocalFrame> > targetFrames;
1231 targetFrames.append(m_frame); 1259 targetFrames.append(m_frame);
1232 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) { 1260 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) {
1233 // FIXME: There is not yet any way to dispatch events to out-of-process frames. 1261 // FIXME: There is not yet any way to dispatch events to out-of-process frames.
1234 if (child->isLocalFrame()) 1262 if (child->isLocalFrame())
1235 targetFrames.append(toLocalFrame(child)); 1263 targetFrames.append(toLocalFrame(child));
1236 } 1264 }
1237 1265
1238 bool shouldClose = false; 1266 bool shouldClose = false;
1239 { 1267 {
1240 NavigationDisablerForBeforeUnload navigationDisabler; 1268 NavigationDisablerForBeforeUnload navigationDisabler;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); 1335 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding);
1308 else if (m_documentLoader) 1336 else if (m_documentLoader)
1309 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding()); 1337 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding());
1310 1338
1311 1339
1312 bool isTransitionNavigation = false; 1340 bool isTransitionNavigation = false;
1313 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1341 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1314 isTransitionNavigation = dispatchNavigationTransitionData(); 1342 isTransitionNavigation = dispatchNavigationTransitionData();
1315 1343
1316 // stopAllLoaders can detach the LocalFrame, so protect it. 1344 // stopAllLoaders can detach the LocalFrame, so protect it.
1317 RefPtr<LocalFrame> protect(m_frame); 1345 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1318 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1346 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1319 m_policyDocumentLoader->detachFromFrame(); 1347 m_policyDocumentLoader->detachFromFrame();
1320 m_policyDocumentLoader = nullptr; 1348 m_policyDocumentLoader = nullptr;
1321 checkCompleted(); 1349 checkCompleted();
1322 return; 1350 return;
1323 } 1351 }
1324 1352
1325 if (m_provisionalDocumentLoader) { 1353 if (m_provisionalDocumentLoader) {
1326 m_provisionalDocumentLoader->stopLoading(); 1354 m_provisionalDocumentLoader->stopLoading();
1327 if (m_provisionalDocumentLoader) 1355 if (m_provisionalDocumentLoader)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 { 1456 {
1429 ASSERT(activeDocument); 1457 ASSERT(activeDocument);
1430 Frame* frame = m_frame->tree().find(name); 1458 Frame* frame = m_frame->tree().find(name);
1431 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame))) 1459 if (!frame || !frame->isLocalFrame() || !activeDocument->canNavigate(toLocal Frame(*frame)))
1432 return 0; 1460 return 0;
1433 return toLocalFrame(frame); 1461 return toLocalFrame(frame);
1434 } 1462 }
1435 1463
1436 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy) 1464 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy)
1437 { 1465 {
1438 RefPtr<LocalFrame> protect(m_frame); 1466 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1439 if (m_frame->page()->defersLoading()) { 1467 if (m_frame->page()->defersLoading()) {
1440 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy); 1468 m_deferredHistoryLoad = DeferredHistoryLoad(item, historyLoadType, cache Policy);
1441 return; 1469 return;
1442 } 1470 }
1443 1471
1444 m_provisionalItem = item; 1472 m_provisionalItem = item;
1445 if (historyLoadType == HistorySameDocumentLoad) { 1473 if (historyLoadType == HistorySameDocumentLoad) {
1446 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect); 1474 loadInSameDocument(item->url(), item->stateObject(), FrameLoadTypeBackFo rward, NotClientRedirect);
1447 restoreScrollPositionAndViewState(); 1475 restoreScrollPositionAndViewState();
1448 return; 1476 return;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1515 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1488 Frame* parentFrame = m_frame->tree().parent(); 1516 Frame* parentFrame = m_frame->tree().parent();
1489 if (parentFrame && parentFrame->isLocalFrame()) 1517 if (parentFrame && parentFrame->isLocalFrame())
1490 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1518 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1491 if (FrameOwner* frameOwner = m_frame->owner()) 1519 if (FrameOwner* frameOwner = m_frame->owner())
1492 flags |= frameOwner->sandboxFlags(); 1520 flags |= frameOwner->sandboxFlags();
1493 return flags; 1521 return flags;
1494 } 1522 }
1495 1523
1496 } // namespace blink 1524 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698