Chromium Code Reviews| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 m_documentLoader->stopLoading(); | 813 m_documentLoader->stopLoading(); |
| 817 | 814 |
| 818 if (m_provisionalDocumentLoader) | 815 if (m_provisionalDocumentLoader) |
| 819 m_provisionalDocumentLoader->detachFromFrame(); | 816 m_provisionalDocumentLoader->detachFromFrame(); |
| 820 m_provisionalDocumentLoader = 0; | 817 m_provisionalDocumentLoader = 0; |
| 821 | 818 |
| 822 m_checkTimer.stop(); | 819 m_checkTimer.stop(); |
| 823 | 820 |
| 824 m_inStopAllLoaders = false; | 821 m_inStopAllLoaders = false; |
| 825 | 822 |
| 826 m_client->didStopAllLoaders(); | 823 // detachFromParent() can be called multiple times on same Frame, which |
| 824 // means we may no longer have a FrameLoaderClient to talk to. | |
| 825 if (m_client) | |
| 826 m_client->didStopAllLoaders(); | |
| 827 } | 827 } |
| 828 | 828 |
| 829 DocumentLoader* FrameLoader::activeDocumentLoader() const | 829 DocumentLoader* FrameLoader::activeDocumentLoader() const |
| 830 { | 830 { |
| 831 if (m_state == FrameStateProvisional) | 831 if (m_state == FrameStateProvisional) |
| 832 return m_provisionalDocumentLoader.get(); | 832 return m_provisionalDocumentLoader.get(); |
| 833 return m_documentLoader.get(); | 833 return m_documentLoader.get(); |
| 834 } | 834 } |
| 835 | 835 |
| 836 void FrameLoader::didAccessInitialDocument() | 836 void FrameLoader::didAccessInitialDocument() |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1118 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren() | 1118 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren() |
| 1119 // will trigger the unload event handlers of any child frames, and those eve nt | 1119 // will trigger the unload event handlers of any child frames, and those eve nt |
| 1120 // handlers might start a new subresource load in this frame. | 1120 // handlers might start a new subresource load in this frame. |
| 1121 stopAllLoaders(); | 1121 stopAllLoaders(); |
| 1122 | 1122 |
| 1123 InspectorInstrumentation::frameDetachedFromParent(m_frame); | 1123 InspectorInstrumentation::frameDetachedFromParent(m_frame); |
| 1124 | 1124 |
| 1125 if (m_documentLoader) | 1125 if (m_documentLoader) |
| 1126 m_documentLoader->detachFromFrame(); | 1126 m_documentLoader->detachFromFrame(); |
| 1127 m_documentLoader = 0; | 1127 m_documentLoader = 0; |
| 1128 m_client->detachedFromParent(); | |
| 1129 | 1128 |
| 1130 m_progressTracker.clear(); | 1129 m_progressTracker.clear(); |
| 1131 | 1130 |
| 1131 if (m_client) | |
| 1132 m_client->willDetachParent(); | |
| 1133 | |
| 1132 // FIXME: All this code belongs up in Page. | 1134 // FIXME: All this code belongs up in Page. |
| 1133 if (Frame* parent = m_frame->tree().parent()) { | 1135 if (Frame* parent = m_frame->tree().parent()) { |
| 1134 parent->loader().closeAndRemoveChild(m_frame); | 1136 parent->loader().closeAndRemoveChild(m_frame); |
| 1135 parent->loader().scheduleCheckCompleted(); | 1137 parent->loader().scheduleCheckCompleted(); |
| 1136 } else { | 1138 } else { |
| 1137 m_frame->setView(0); | 1139 m_frame->setView(0); |
| 1138 m_frame->willDetachFrameHost(); | 1140 m_frame->willDetachFrameHost(); |
| 1139 m_frame->detachFromFrameHost(); | 1141 m_frame->detachFromFrameHost(); |
| 1140 } | 1142 } |
| 1143 | |
| 1144 if (m_client) { | |
| 1145 setOpener(0); | |
| 1146 | |
| 1147 // Close down the proxy. The purpose of this change is to make the call to | |
|
eseidel
2013/12/28 01:18:40
I think you mean "call" instead of change.
dcheng
2013/12/28 01:51:05
I don't have any clue what the original author mea
| |
| 1148 // ScriptController::clearWindowShell a no-op when called from Frame::pa geDestroyed. | |
| 1149 // Without this change, this call to clearWindowShell will cause a crash . If you | |
|
eseidel
2013/12/28 01:18:40
clearWindowShell is called by clearForClose? or di
dcheng
2013/12/28 01:51:05
This comment seems to have suffered from significa
| |
| 1150 // remove/modify this, just ensure that you can go to a page and then na vigate to a new | |
| 1151 // page without getting any asserts or crashes. | |
| 1152 m_frame->script().clearForClose(); | |
| 1153 | |
| 1154 // After this, we must no longer talk to the client since this clears | |
| 1155 // its owning reference back to us. | |
| 1156 m_client->detachedFromParent(); | |
| 1157 m_client = 0; | |
| 1158 } | |
| 1141 } | 1159 } |
| 1142 | 1160 |
| 1143 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt ring& origin) | 1161 void FrameLoader::addHTTPOriginIfNeeded(ResourceRequest& request, const AtomicSt ring& origin) |
| 1144 { | 1162 { |
| 1145 if (!request.httpOrigin().isEmpty()) | 1163 if (!request.httpOrigin().isEmpty()) |
| 1146 return; // Request already has an Origin header. | 1164 return; // Request already has an Origin header. |
| 1147 | 1165 |
| 1148 // Don't send an Origin header for GET or HEAD to avoid privacy issues. | 1166 // Don't send an Origin header for GET or HEAD to avoid privacy issues. |
| 1149 // For example, if an intranet page has a hyperlink to an external web | 1167 // For example, if an intranet page has a hyperlink to an external web |
| 1150 // site, we don't want to include the Origin of the request because it | 1168 // 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... | |
| 1283 return; | 1301 return; |
| 1284 | 1302 |
| 1285 // We skip dispatching the beforeload event on the frame owner if we've alre ady committed a real | 1303 // We skip dispatching the beforeload event on the frame owner if we've alre ady committed a real |
| 1286 // document load because the event would leak subsequent activity by the fra me which the parent | 1304 // document load because the event would leak subsequent activity by the fra me which the parent |
| 1287 // frame isn't supposed to learn. For example, if the child frame navigated to a new URL, the | 1305 // frame isn't supposed to learn. For example, if the child frame navigated to a new URL, the |
| 1288 // parent frame shouldn't learn the URL. | 1306 // parent frame shouldn't learn the URL. |
| 1289 const ResourceRequest& request = action.resourceRequest(); | 1307 const ResourceRequest& request = action.resourceRequest(); |
| 1290 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string()) ) | 1308 if (!m_stateMachine.committedFirstRealDocumentLoad() && m_frame->ownerElemen t() && !m_frame->ownerElement()->dispatchBeforeLoadEvent(request.url().string()) ) |
| 1291 return; | 1309 return; |
| 1292 | 1310 |
| 1311 // Dispatching the beforeload event could have blown away the frame. | |
| 1312 if (!m_client) | |
| 1313 return; | |
| 1314 | |
| 1293 if (!m_stateMachine.startedFirstRealLoad()) | 1315 if (!m_stateMachine.startedFirstRealLoad()) |
| 1294 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad); | 1316 m_stateMachine.advanceTo(FrameLoaderStateMachine::StartedFirstRealLoad); |
| 1295 | 1317 |
| 1296 // The current load should replace the history item if it is the first real | 1318 // The current load should replace the history item if it is the first real |
| 1297 // load of the frame. | 1319 // load of the frame. |
| 1298 bool replacesCurrentHistoryItem = false; | 1320 bool replacesCurrentHistoryItem = false; |
| 1299 if (type == FrameLoadTypeRedirectWithLockedBackForwardList | 1321 if (type == FrameLoadTypeRedirectWithLockedBackForwardList |
| 1300 || !m_stateMachine.committedFirstRealDocumentLoad()) { | 1322 || !m_stateMachine.committedFirstRealDocumentLoad()) { |
| 1301 replacesCurrentHistoryItem = true; | 1323 replacesCurrentHistoryItem = true; |
| 1302 } | 1324 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1502 { | 1524 { |
| 1503 SandboxFlags flags = m_forcedSandboxFlags; | 1525 SandboxFlags flags = m_forcedSandboxFlags; |
| 1504 if (Frame* parentFrame = m_frame->tree().parent()) | 1526 if (Frame* parentFrame = m_frame->tree().parent()) |
| 1505 flags |= parentFrame->document()->sandboxFlags(); | 1527 flags |= parentFrame->document()->sandboxFlags(); |
| 1506 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1528 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
| 1507 flags |= ownerElement->sandboxFlags(); | 1529 flags |= ownerElement->sandboxFlags(); |
| 1508 return flags; | 1530 return flags; |
| 1509 } | 1531 } |
| 1510 | 1532 |
| 1511 } // namespace WebCore | 1533 } // namespace WebCore |
| OLD | NEW |