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

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

Issue 1642283002: Deal with frame removal by content scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more runScriptsAtDocumentElementAvailable + comments Created 4 years, 9 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "core/page/ChromeClient.h" 76 #include "core/page/ChromeClient.h"
77 #include "core/page/CreateWindow.h" 77 #include "core/page/CreateWindow.h"
78 #include "core/page/FrameTree.h" 78 #include "core/page/FrameTree.h"
79 #include "core/page/Page.h" 79 #include "core/page/Page.h"
80 #include "core/page/WindowFeatures.h" 80 #include "core/page/WindowFeatures.h"
81 #include "core/page/scrolling/ScrollingCoordinator.h" 81 #include "core/page/scrolling/ScrollingCoordinator.h"
82 #include "core/svg/graphics/SVGImage.h" 82 #include "core/svg/graphics/SVGImage.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/PluginScriptForbiddenScope.h" 85 #include "platform/PluginScriptForbiddenScope.h"
86 #include "platform/ScriptForbiddenScope.h"
86 #include "platform/UserGestureIndicator.h" 87 #include "platform/UserGestureIndicator.h"
87 #include "platform/network/HTTPParsers.h" 88 #include "platform/network/HTTPParsers.h"
88 #include "platform/network/ResourceRequest.h" 89 #include "platform/network/ResourceRequest.h"
89 #include "platform/scroll/ScrollAnimatorBase.h" 90 #include "platform/scroll/ScrollAnimatorBase.h"
90 #include "platform/weborigin/SecurityOrigin.h" 91 #include "platform/weborigin/SecurityOrigin.h"
91 #include "platform/weborigin/SecurityPolicy.h" 92 #include "platform/weborigin/SecurityPolicy.h"
92 #include "public/platform/WebURLRequest.h" 93 #include "public/platform/WebURLRequest.h"
93 #include "wtf/TemporaryChange.h" 94 #include "wtf/TemporaryChange.h"
94 #include "wtf/text/CString.h" 95 #include "wtf/text/CString.h"
95 #include "wtf/text/WTFString.h" 96 #include "wtf/text/WTFString.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 if (m_stateMachine.creatingInitialEmptyDocument()) 482 if (m_stateMachine.creatingInitialEmptyDocument())
482 return; 483 return;
483 484
484 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves 485 // This can be called from the LocalFrame's destructor, in which case we sho uldn't protect ourselves
485 // because doing so will cause us to re-enter the destructor when protector goes out of scope. 486 // because doing so will cause us to re-enter the destructor when protector goes out of scope.
486 // Null-checking the FrameView indicates whether or not we're in the destruc tor. 487 // Null-checking the FrameView indicates whether or not we're in the destruc tor.
487 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr); 488 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame->view() ? m_frame.get() : nul lptr);
488 489
489 m_progressTracker->finishedParsing(); 490 m_progressTracker->finishedParsing();
490 491
492 if (client()) {
493 ScriptForbiddenScope forbidScripts;
494 client()->dispatchDidFinishDocumentLoad(m_documentLoader ? m_documentLoa der->isCommittedButEmpty() : true);
495 }
496
491 if (client()) 497 if (client())
492 client()->dispatchDidFinishDocumentLoad(m_documentLoader ? m_documentLoa der->isCommittedButEmpty() : true); 498 client()->runScriptsAtDocumentReady();
493 499
494 checkCompleted(); 500 checkCompleted();
495 501
496 if (!m_frame->view()) 502 if (!m_frame->view())
497 return; // We are being destroyed by something checkCompleted called. 503 return; // We are being destroyed by something checkCompleted called.
498 504
499 // Check if the scrollbars are really needed for the content. 505 // Check if the scrollbars are really needed for the content.
500 // If not, remove them, relayout, and repaint. 506 // If not, remove them, relayout, and repaint.
501 m_frame->view()->restoreScrollbar(); 507 m_frame->view()->restoreScrollbar();
502 processFragment(m_frame->document()->url(), NavigationToDifferentDocument); 508 processFragment(m_frame->document()->url(), NavigationToDifferentDocument);
(...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 if (!url.isAboutSrcdocURL()) 1484 if (!url.isAboutSrcdocURL())
1479 return false; 1485 return false;
1480 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner(); 1486 HTMLFrameOwnerElement* ownerElement = m_frame->deprecatedLocalOwner();
1481 if (!isHTMLIFrameElement(ownerElement)) 1487 if (!isHTMLIFrameElement(ownerElement))
1482 return false; 1488 return false;
1483 return ownerElement->fastHasAttribute(srcdocAttr); 1489 return ownerElement->fastHasAttribute(srcdocAttr);
1484 } 1490 }
1485 1491
1486 void FrameLoader::dispatchDocumentElementAvailable() 1492 void FrameLoader::dispatchDocumentElementAvailable()
1487 { 1493 {
1494 ScriptForbiddenScope forbidScripts;
1488 client()->documentElementAvailable(); 1495 client()->documentElementAvailable();
1489 } 1496 }
1490 1497
1498 void FrameLoader::runScriptsAtDocumentElementAvailable()
1499 {
1500 client()->runScriptsAtDocumentElementAvailable();
1501 // The frame might be detached at this point.
1502 }
1503
1491 void FrameLoader::dispatchDidClearDocumentOfWindowObject() 1504 void FrameLoader::dispatchDidClearDocumentOfWindowObject()
1492 { 1505 {
1493 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1506 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
1494 return; 1507 return;
1495 1508
1496 InspectorInstrumentation::didClearDocumentOfWindowObject(m_frame); 1509 InspectorInstrumentation::didClearDocumentOfWindowObject(m_frame);
1497 1510
1498 if (m_dispatchingDidClearWindowObjectInMainWorld) 1511 if (m_dispatchingDidClearWindowObjectInMainWorld)
1499 return; 1512 return;
1500 TemporaryChange<bool> 1513 TemporaryChange<bool>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 // FIXME: We need a way to propagate insecure requests policy flags to 1574 // FIXME: We need a way to propagate insecure requests policy flags to
1562 // out-of-process frames. For now, we'll always use default behavior. 1575 // out-of-process frames. For now, we'll always use default behavior.
1563 if (!parentFrame->isLocalFrame()) 1576 if (!parentFrame->isLocalFrame())
1564 return nullptr; 1577 return nullptr;
1565 1578
1566 ASSERT(toLocalFrame(parentFrame)->document()); 1579 ASSERT(toLocalFrame(parentFrame)->document());
1567 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1580 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1568 } 1581 }
1569 1582
1570 } // namespace blink 1583 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698