| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 , m_shouldCallCheckCompleted(false) | 152 , m_shouldCallCheckCompleted(false) |
| 153 , m_opener(0) | 153 , m_opener(0) |
| 154 , m_didAccessInitialDocument(false) | 154 , m_didAccessInitialDocument(false) |
| 155 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) | 155 , m_didAccessInitialDocumentTimer(this, &FrameLoader::didAccessInitialDocume
ntTimerFired) |
| 156 , m_forcedSandboxFlags(SandboxNone) | 156 , m_forcedSandboxFlags(SandboxNone) |
| 157 { | 157 { |
| 158 } | 158 } |
| 159 | 159 |
| 160 FrameLoader::~FrameLoader() | 160 FrameLoader::~FrameLoader() |
| 161 { | 161 { |
| 162 setOpener(0); | |
| 163 | |
| 164 HashSet<Frame*>::iterator end = m_openedFrames.end(); | 162 HashSet<Frame*>::iterator end = m_openedFrames.end(); |
| 165 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it) | 163 for (HashSet<Frame*>::iterator it = m_openedFrames.begin(); it != end; ++it) |
| 166 (*it)->loader().m_opener = 0; | 164 (*it)->loader().m_opener = 0; |
| 167 | |
| 168 m_client->frameLoaderDestroyed(); | |
| 169 } | 165 } |
| 170 | 166 |
| 171 void FrameLoader::init() | 167 void FrameLoader::init() |
| 172 { | 168 { |
| 173 // This somewhat odd set of steps gives the frame an initial empty document. | 169 // This somewhat odd set of steps gives the frame an initial empty document. |
| 174 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest
(KURL(ParsedURLString, emptyString())), SubstituteData()); | 170 m_provisionalDocumentLoader = m_client->createDocumentLoader(ResourceRequest
(KURL(ParsedURLString, emptyString())), SubstituteData()); |
| 175 m_provisionalDocumentLoader->setFrame(m_frame); | 171 m_provisionalDocumentLoader->setFrame(m_frame); |
| 176 m_provisionalDocumentLoader->startLoadingMainResource(); | 172 m_provisionalDocumentLoader->startLoadingMainResource(); |
| 177 m_frame->document()->cancelParsing(); | 173 m_frame->document()->cancelParsing(); |
| 178 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); | 174 m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocu
ment); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 void FrameLoader::finishedParsing() | 407 void FrameLoader::finishedParsing() |
| 412 { | 408 { |
| 413 if (m_stateMachine.creatingInitialEmptyDocument()) | 409 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 414 return; | 410 return; |
| 415 | 411 |
| 416 // This can be called from the Frame's destructor, in which case we shouldn'
t protect ourselves | 412 // This can be called from the Frame's destructor, in which case we shouldn'
t protect ourselves |
| 417 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. | 413 // because doing so will cause us to re-enter the destructor when protector
goes out of scope. |
| 418 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. | 414 // Null-checking the FrameView indicates whether or not we're in the destruc
tor. |
| 419 RefPtr<Frame> protector = m_frame->view() ? m_frame : 0; | 415 RefPtr<Frame> protector = m_frame->view() ? m_frame : 0; |
| 420 | 416 |
| 421 m_client->dispatchDidFinishDocumentLoad(); | 417 if (m_client) |
| 418 m_client->dispatchDidFinishDocumentLoad(); |
| 422 | 419 |
| 423 checkCompleted(); | 420 checkCompleted(); |
| 424 | 421 |
| 425 if (!m_frame->view()) | 422 if (!m_frame->view()) |
| 426 return; // We are being destroyed by something checkCompleted called. | 423 return; // We are being destroyed by something checkCompleted called. |
| 427 | 424 |
| 428 // Check if the scrollbars are really needed for the content. | 425 // Check if the scrollbars are really needed for the content. |
| 429 // If not, remove them, relayout, and repaint. | 426 // If not, remove them, relayout, and repaint. |
| 430 m_frame->view()->restoreScrollbar(); | 427 m_frame->view()->restoreScrollbar(); |
| 431 scrollToFragmentWithParentBoundary(m_frame->document()->url()); | 428 scrollToFragmentWithParentBoundary(m_frame->document()->url()); |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 m_documentLoader->stopLoading(); | 814 m_documentLoader->stopLoading(); |
| 818 | 815 |
| 819 if (m_provisionalDocumentLoader) | 816 if (m_provisionalDocumentLoader) |
| 820 m_provisionalDocumentLoader->detachFromFrame(); | 817 m_provisionalDocumentLoader->detachFromFrame(); |
| 821 m_provisionalDocumentLoader = 0; | 818 m_provisionalDocumentLoader = 0; |
| 822 | 819 |
| 823 m_checkTimer.stop(); | 820 m_checkTimer.stop(); |
| 824 | 821 |
| 825 m_inStopAllLoaders = false; | 822 m_inStopAllLoaders = false; |
| 826 | 823 |
| 827 m_client->didStopAllLoaders(); | 824 // detachFromParent() can be called multiple times on same Frame, which |
| 825 // means we may no longer have a FrameLoaderClient to talk to. |
| 826 if (m_client) |
| 827 m_client->didStopAllLoaders(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 DocumentLoader* FrameLoader::activeDocumentLoader() const | 830 DocumentLoader* FrameLoader::activeDocumentLoader() const |
| 831 { | 831 { |
| 832 if (m_state == FrameStateProvisional) | 832 if (m_state == FrameStateProvisional) |
| 833 return m_provisionalDocumentLoader.get(); | 833 return m_provisionalDocumentLoader.get(); |
| 834 return m_documentLoader.get(); | 834 return m_documentLoader.get(); |
| 835 } | 835 } |
| 836 | 836 |
| 837 void FrameLoader::didAccessInitialDocument() | 837 void FrameLoader::didAccessInitialDocument() |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 // stopAllLoaders() needs to be called after detachChildren(), because detac
hedChildren() | 1119 // stopAllLoaders() needs to be called after detachChildren(), because detac
hedChildren() |
| 1120 // will trigger the unload event handlers of any child frames, and those eve
nt | 1120 // will trigger the unload event handlers of any child frames, and those eve
nt |
| 1121 // handlers might start a new subresource load in this frame. | 1121 // handlers might start a new subresource load in this frame. |
| 1122 stopAllLoaders(); | 1122 stopAllLoaders(); |
| 1123 | 1123 |
| 1124 InspectorInstrumentation::frameDetachedFromParent(m_frame); | 1124 InspectorInstrumentation::frameDetachedFromParent(m_frame); |
| 1125 | 1125 |
| 1126 if (m_documentLoader) | 1126 if (m_documentLoader) |
| 1127 m_documentLoader->detachFromFrame(); | 1127 m_documentLoader->detachFromFrame(); |
| 1128 m_documentLoader = 0; | 1128 m_documentLoader = 0; |
| 1129 m_client->detachedFromParent(); | |
| 1130 | 1129 |
| 1131 m_progressTracker.clear(); | 1130 m_progressTracker.clear(); |
| 1132 | 1131 |
| 1132 if (m_client) |
| 1133 m_client->willDetachParent(); |
| 1134 |
| 1133 // FIXME: All this code belongs up in Page. | 1135 // FIXME: All this code belongs up in Page. |
| 1134 if (Frame* parent = m_frame->tree().parent()) { | 1136 if (Frame* parent = m_frame->tree().parent()) { |
| 1135 parent->loader().closeAndRemoveChild(m_frame); | 1137 parent->loader().closeAndRemoveChild(m_frame); |
| 1136 parent->loader().scheduleCheckCompleted(); | 1138 parent->loader().scheduleCheckCompleted(); |
| 1137 } else { | 1139 } else { |
| 1138 m_frame->setView(0); | 1140 m_frame->setView(0); |
| 1139 m_frame->willDetachFrameHost(); | 1141 m_frame->willDetachFrameHost(); |
| 1140 m_frame->detachFromFrameHost(); | 1142 m_frame->detachFromFrameHost(); |
| 1141 } | 1143 } |
| 1144 |
| 1145 if (m_client) { |
| 1146 setOpener(0); |
| 1147 // After this, we must no longer talk to the client since this clears |
| 1148 // its owning reference back to us. |
| 1149 m_client->detachedFromParent(); |
| 1150 m_client = 0; |
| 1151 } |
| 1142 } | 1152 } |
| 1143 | 1153 |
| 1144 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt
ring& origin) | 1154 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt
ring& origin) |
| 1145 { | 1155 { |
| 1146 if (!request.httpOrigin().isEmpty()) | 1156 if (!request.httpOrigin().isEmpty()) |
| 1147 return; // Request already has an Origin header. | 1157 return; // Request already has an Origin header. |
| 1148 | 1158 |
| 1149 // Don't send an Origin header for GET or HEAD to avoid privacy issues. | 1159 // Don't send an Origin header for GET or HEAD to avoid privacy issues. |
| 1150 // For example, if an intranet page has a hyperlink to an external web | 1160 // For example, if an intranet page has a hyperlink to an external web |
| 1151 // site, we don't want to include the Origin of the request because it | 1161 // site, we don't want to include the Origin of the request because it |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 return; | 1294 return; |
| 1285 | 1295 |
| 1286 // We skip dispatching the beforeload event on the frame owner if we've alre
ady committed a real | 1296 // We skip dispatching the beforeload event on the frame owner if we've alre
ady committed a real |
| 1287 // document load because the event would leak subsequent activity by the fra
me which the parent | 1297 // document load because the event would leak subsequent activity by the fra
me which the parent |
| 1288 // frame isn't supposed to learn. For example, if the child frame navigated
to a new URL, the | 1298 // frame isn't supposed to learn. For example, if the child frame navigated
to a new URL, the |
| 1289 // parent frame shouldn't learn the URL. | 1299 // parent frame shouldn't learn the URL. |
| 1290 const ResourceRequest& request = action.resourceRequest(); | 1300 const ResourceRequest& request = action.resourceRequest(); |
| 1291 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen
t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string())
) | 1301 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen
t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string())
) |
| 1292 return; | 1302 return; |
| 1293 | 1303 |
| 1304 // Dispatching the beforeload event could have blown away the frame. |
| 1305 if (!m_client) |
| 1306 return; |
| 1307 |
| 1294 if (!m_stateMachine.startedFirstRealLoad()) | 1308 if (!m_stateMachine.startedFirstRealLoad()) |
| 1295 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad); | 1309 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad); |
| 1296 | 1310 |
| 1297 // The current load should replace the history item if it is the first real | 1311 // The current load should replace the history item if it is the first real |
| 1298 // load of the frame. | 1312 // load of the frame. |
| 1299 bool replacesCurrentHistoryItem = false; | 1313 bool replacesCurrentHistoryItem = false; |
| 1300 if (type == FrameLoadTypeRedirectWithLockedBackForwardList | 1314 if (type == FrameLoadTypeRedirectWithLockedBackForwardList |
| 1301 || !m_stateMachine.committedFirstRealDocumentLoad()) { | 1315 || !m_stateMachine.committedFirstRealDocumentLoad()) { |
| 1302 replacesCurrentHistoryItem = true; | 1316 replacesCurrentHistoryItem = true; |
| 1303 } | 1317 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1503 { | 1517 { |
| 1504 SandboxFlags flags = m_forcedSandboxFlags; | 1518 SandboxFlags flags = m_forcedSandboxFlags; |
| 1505 if (Frame* parentFrame = m_frame->tree().parent()) | 1519 if (Frame* parentFrame = m_frame->tree().parent()) |
| 1506 flags |= parentFrame->document()->sandboxFlags(); | 1520 flags |= parentFrame->document()->sandboxFlags(); |
| 1507 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1521 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
| 1508 flags |= ownerElement->sandboxFlags(); | 1522 flags |= ownerElement->sandboxFlags(); |
| 1509 return flags; | 1523 return flags; |
| 1510 } | 1524 } |
| 1511 | 1525 |
| 1512 } // namespace WebCore | 1526 } // namespace WebCore |
| OLD | NEW |